Write a new task using Capistrano

Capistrano can be a great tool to run a task on several servers. It can be a task like uploading a maintenance page or deleting some logs :

desc <<-DESC
This is my awesome task. Description appears in help so write it carefully.
run "rm -rf #{logs_folder}"
run "mkdir #{destination_folder}"
top.upload("index.html", "#{destination_folder}/index.html")

You can read more about writing Capistrano tasks here.


Create a copy of a Vagrant machine

1. Stop your vagrant machine

vagrant halt

2. Create the copy (it can take sometime)

vagrant package --base <name_of_your_machine>  --output path/to/newly/created/package

The machine name is on Virtual Box 🙂

Increase security on a WordPress site

WordPress is an extremely popular framework, which makes it easier to hack. Here are couple of ways to increase the security of your WordPress installation :

  • Hide your admin back-end to a list of whitelisted IPs through server rules on Apache / Nginx
  • Change the path to your admin back-end
  • Protect the wp-login.php script
  • Change the prefix of your tables
  • Use complicated passwords and change them often

For people who are not necessarily developers, the plugin “iThemes Security” does some of the steps I mentioned pretty well.


NoMethodError /Ruby/Gems/2.0.0/gems/sass-3.4.8/lib/sass/plugin/compiler.rb Undefined method start

I had the weirdest issue when initializing my compass project for Greenie.

kikoo:greenie leiluspocus$ sudo compass watch --trace
>>> Compass is watching for changes. Press Ctrl-C to Stop.
NoMethodError on line ["402"] of /Library/Ruby/Gems/2.0.0/gems/sass-3.4.8/lib/sass/plugin/compiler.rb: undefined method `start' for #<Thread:0x007f90d1afd098 sleep>
  /Library/Ruby/Gems/2.0.0/gems/sass-3.4.8/lib/sass/plugin/compiler.rb:402:in `map'
  /Library/Ruby/Gems/2.0.0/gems/sass-3.4.8/lib/sass/plugin/compiler.rb:402:in `listen_to'
  /Library/Ruby/Gems/2.0.0/gems/sass-3.4.8/lib/sass/plugin/compiler.rb:338:in `watch'
  /Library/Ruby/Gems/2.0.0/gems/compass-1.0.3/lib/compass/sass_compiler.rb:46:in `watch!'
  /Library/Ruby/Gems/2.0.0/gems/compass-1.0.3/lib/compass/commands/watch_project.rb:41:in `perform'
  /Library/Ruby/Gems/2.0.0/gems/compass-1.0.3/lib/compass/commands/base.rb:18:in `execute'
  /Library/Ruby/Gems/2.0.0/gems/compass-1.0.3/lib/compass/commands/project_base.rb:19:in `execute'
  /Library/Ruby/Gems/2.0.0/gems/compass-1.0.3/lib/compass/exec/sub_command_ui.rb:43:in `perform!'
  /Library/Ruby/Gems/2.0.0/gems/compass-1.0.3/lib/compass/exec/sub_command_ui.rb:15:in `run!'
  /Library/Ruby/Gems/2.0.0/gems/compass-1.0.3/bin/compass:30:in `block in <top (required)>'
  /Library/Ruby/Gems/2.0.0/gems/compass-1.0.3/bin/compass:44:in `call'
  /Library/Ruby/Gems/2.0.0/gems/compass-1.0.3/bin/compass:44:in `<top (required)>'
  /usr/local/bin/compass:23:in `load'
  /usr/local/bin/compass:23:in `<main>'

I solved it by using a more recent version of Ruby using RVM. RVM is pretty cool because you can switch your Ruby versions very easily. Note that I had to re-install compass afterwards.

VirtualBox CheatSheet

Here is a couple of commands I’ve used in a previous life while trying to resize a Vagrant machine.

List the virtual disk images used by Virtual Box

vboxmanage list hdds

Remove a hard disk from a Virtual Box registry

vboxmanage closemedium disk a5bad1ba-5ff7-4b83-87ff-adb18f05269a --delete 

How to resize a hard disk for a Virtual Machine – Tutorial