How to automatically install gulp dependencies
I created a website where I’m using gulp to create a minified version and had to switch to another computer. For whatever reason, gulp install wouldn’t install the dependencies automatically, even when using the “npm-install-missing” plugin.
Add this script to the beginning of your gulpfile.js before the requirements, and when you run gulp, it will install the dependencies automatically. Be aware you’ll need to rerun your gulp command after the script completes.
(function(){ var r=require; require=function (n){ try{ return r(n) } catch(e){ r('child_process').exec('npm i ' + n,function (err,body){ try{ console.log('Module "' +n + '"" not found, installing.\n' + body ) return r(n); } catch(e){ } }) } } console.log('""Please re-run gulp.\n' + body ) })()
How to fix “hacked by Moroccanwolf” WordPress site
A client of mine had their wordpress hacked and when you would load the site, it would simply display a message that said “hacked by Moroccanwolf”. I did some digging and luckily it wasn’t a major hack and they didn’t mess with the posts or other settings as a lot of the hacks do.
Quick Fix
- To fix it, you’ll need to connect to your database using an editor of some sort, such as PHPmyadmin.
- Once logged in, expand your database on the left.
- Click on ‘wp_options’.
- On the top right, click the ‘Browse’ tab.
- Look for ‘widget_text’ in the option_name field. (For my client, it was at row 90). You should see something similar to this:
<script>document.documentElement.innerHTML = unescape(''%48%61%63%6b%65%64%20%62%79%20%4d%6f%72%6f%63%63%61%6e%77%6f%6c%66%20%26%26%20%61%62%64%65%6c%6c%61%68%20%45%6c%6d%61%67%68%72%69%62%69'');</script>
Delete the entire tag and this  should restore your website. Now remember to change your logins and update wordpress.
How I Figured it Out
Most of the hacks I’ve seen are done through injecting javascript into the database somewhere which either force a redirect or something along those lines. Here’s the steps I followed to find it:
- To fix it, you’ll need to connect to your database using an editor of some sort, such as PHPmyadmin.
- Once logged in, click on your database on the left. Ensure you’re on the database and not a table.
- Click Export.
- Leave it to quick and click go.
- You should now see a textbox with a mess of SQL commands.
- Copy and paste into your favorite editor,
- Search for <script> and you should find something that doesn’t belong. Â In this instance, that was the only thing I found of note.
- You’ll want to scan the rest of the database for things that don’t belong. Additionally, you’ll want to replace all the wordpress files and confirm no .htaccess files were created that give hackers write access.
ASP.NET MVC Model Generator
In making the switch to ASP.NET MVC, I’ve moved away from using my old Data Access Layer that I’ve used for years and have opted to use Dapper as my ORM of choice in the quest for optimal performance. My DAL was actually pretty optimized for WinForms and WebForms (using straight SQL Queries and SQL parameters) but mapping it to models wasn’t something I had in mind when I created it. I’m finding Dapper takes some getting used too but it is still pretty fast. The downside is that writing the code for Models to wire it up is proving to be a little tedious.
To that effect, I wrote a little application that has helped me generate the models from a database dynamically. It’s in it’s infancy stages and something I cobbled together in less than 8 hours but it works. I’ll add more features too as time goes on if there’s enough interest or to satisfy my own needs. In the meantime, I’m open sourcing the project as it may help others and I’d love to see it become something grander if others are willing to contribute to it. There’s also some useful bits of code that others may find useful to reference like dynamically reading fields from a database, pluralization/singularization of words, amongst others.
You can find the repository on Github: https://github.com/gregvarghese/MVCModelGenerator