Skip to content

Instantly share code, notes, and snippets.

View LucasArruda's full-sized avatar
🎯
Focusing

Lucas Arruda LucasArruda

🎯
Focusing
View GitHub Profile
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"
];

Description

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:

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

Results

@LucasArruda
LucasArruda / cup.py
Last active August 29, 2015 14:02
World Cup 2014 results on terminal
from urllib2 import urlopen
import json
resp = urlopen('http://worldcup.sfg.io/matches/?by_date=DESC').read()
for jogo in json.loads(resp):
complete = (jogo['status'] == 'completed')
current = (jogo['status'] == 'in progress')
if complete or current:
ht = jogo['home_team']
@LucasArruda
LucasArruda / create-iso-from-dvd.sh
Created November 5, 2014 01:58
Create iso - OSX
#!/bin/sh
# see what's the correct disk #
mount
# change disk2 to correct disc number
sudo diskutil unmount /dev/disk2
dd if=/dev/disk1 of=~/mydvd.iso bs=2048 conv=sync,notrunc
@LucasArruda
LucasArruda / quick-deploy-heroku-git.txt
Last active August 29, 2015 14:10
Quick deploy to Heroku from git repo
## summary
git remote add heroku git@heroku.com:heroku_app_name.git
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 (https://keybase.io/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:

@LucasArruda
LucasArruda / uri.js
Last active August 29, 2015 14:16 — forked from jlong/uri.js
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@LucasArruda
LucasArruda / add-css-vanilla.js
Last active August 29, 2015 14:25
Add CSS or JS on the fly
function loadCss(url) {
var link = document.createElement("link");
link.type = "text/css";
link.rel = "stylesheet";
link.href = url;
document.getElementsByTagName("head")[0].appendChild(link);
}
@LucasArruda
LucasArruda / fix_brew.sh
Created October 6, 2015 15:17
Fixing brew
#!/bin/sh
cd $(brew --prefix) && git fetch && git reset --hard origin/master
brew update
@LucasArruda
LucasArruda / friendly_urls.markdown
Created August 7, 2017 22:41 — forked from jcasimir/friendly_urls.markdown
Friendly URLs in Rails

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:

/people/6

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.