Prevent reload with BrowserSync and Laravel

I use BrowserSync with Laravel Elixir and I found that when I use cache busting it reloads the page instead of injecting the CSS into it. This is of course due to the way cache busting works. Still, this is quite annoying. However, there is a really simple solution to the issue. In your master blade template just make a check to see if you are on a local environment like so:

This is half the solution.

Read more

Remove node_modules folder on Windows without errors

I sometimes get errors when I run npm install for my Gulp or Grunt projects. To retry I need to remove the node_modules folder and sometimes that causes problems as when you are on Windows. I had a look around and found a Git repository named rimraf.

To remove a node_modules folder on your system, first install rimraf globally

Then, navigate to the folder just above the folder you want to remove and run

…and the node_modules folder will be removed.

Read more

Create additional databases in Laravel Homestead

It is really easy to ad more databases in Laravel Homested. Simply edit the Homestead.yaml file (in Windows under C:Usersyour-username.homesteadHomestead.yaml)

Under databases add your databases like this:

If you virtual machine is already running navigate to your Homestead folder and run the command  vagrant provision to create the new database(s). If it is not running simply run  vagrant up.

You should now be able to access your new database with the default credentials.

Read more

Solution to MySQL error “Error establishing a database connection” in WordPress on DigitalOcean

I’m hosting my sites with DigitalOcean (referral link) on the smallest VPS with 512 MB Ram. It’s a cheap way of hosting as I can have virtually as many sites I want on the VPS – and in case it is too slow I can easily upgrade it from the control panel. However, I occasionally get an error on my WordPress sites saying  “Error establishing a database connection”. I searched around for a solution and finally found that I needed to add a swap file to the server.

Read more

IIS only GZIPs some assets and only sometimes

I had an issue on a server running IIS 8 not consistently compressing my .js, .css and other files. It turned out the issue had something to do with the CPU load.

To this issue the solution was to open the applicationHost.config file (C:WindowsSystem32inetsrvconfig – remember to backup this file!). Remeber to open this in a 64 bit text editor like notepad.

In the   <httpCompression directory="%SystemDrive%inetpubtempIIS Temporary Compressed Files">  section I added  staticCompressionDisableCpuUsage="100" staticCompressionEnableCpuUsage="100"

This tells the server to not disable the compression of static assets.

Read more