Skip to content

Instantly share code, notes, and snippets.

Working from home

Lucas Arruda LucasArruda

Working from home
View GitHub Profile
View Gruntfile.js
module.exports = function(grunt) {
var config = {};
// Set all the tasks you want to load.
var tasks = [
, "grunt-contrib-concat"
, "grunt-contrib-uglify"
, "grunt-contrib-jshint"
, "grunt-contrib-watch"


This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

convert $1 -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 $2


LucasArruda /
Last active Aug 29, 2015
World Cup 2014 results on terminal
from urllib2 import urlopen
import json
resp = urlopen('').read()
for jogo in json.loads(resp):
complete = (jogo['status'] == 'completed')
current = (jogo['status'] == 'in progress')
if complete or current:
ht = jogo['home_team']
# see what's the correct disk #
# change disk2 to correct disc number
sudo diskutil unmount /dev/disk2
dd if=/dev/disk1 of=~/mydvd.iso bs=2048 conv=sync,notrunc
LucasArruda / quick-deploy-heroku-git.txt
Last active Aug 29, 2015
Quick deploy to Heroku from git repo
View quick-deploy-heroku-git.txt
## summary
git remote add heroku
git push heroku master
heroku open
## commented steps
# (if you haven't) add keys to heroku so you can push
heroku keys:add

Keybase proof

I hereby claim:

  • I am lucasarruda on github.
  • I am lucasarruda ( on keybase.
  • I have a public key whose fingerprint is F895 D87F A05A 3939 8E1D A9BF E6A0 E155 A547 ACD7

To claim this, I am signing this object:

View uri.js
var parser = document.createElement('a');
parser.href = "";
parser.protocol; // => "http:"
parser.hostname; // => ""
parser.port; // => "3000"
parser.pathname; // => "/pathname/"; // => "?search=test"
parser.hash; // => "#hash"; // => ""
LucasArruda / add-css-vanilla.js
Last active Aug 29, 2015
Add CSS or JS on the fly
View add-css-vanilla.js
function loadCss(url) {
var link = document.createElement("link");
link.type = "text/css";
link.rel = "stylesheet";
link.href = url;
cd $(brew --prefix) && git fetch && git reset --hard origin/master
brew update
View friendly_urls.markdown

Friendly URLs

By default, Rails applications build URLs based on the primary key -- the id column from the database. Imagine we have a Person model and associated controller. We have a person record for Bob Martin that has id number 6. The URL for his show page would be:


But, for aesthetic or SEO purposes, we want Bob's name in the URL. The last segment, the 6 here, is called the "slug". Let's look at a few ways to implement better slugs.