Skip to content

Instantly share code, notes, and snippets.

View foca's full-sized avatar

Nicolás Sanguinetti foca

View GitHub Profile
@foca
foca / wizard.html
Created July 10, 2012 05:12
Wizard navigation in CSS (using Twitter Bootstrap)
<ol class="wizard-nav">
<li class="done"><a href="#">Step 1</a></li>
<li class="done"><a href="#">Step 2</a></li>
<li class="active"><a href="#">Step 3</a></li>
<li><a href="#" data-disabled>Step 4</a></li>
<li><a href="#" data-disabled>Step 5</a></li>
</ol>
# :facepalm:
class User < ActiveRecord::Base
validate do |user|
if user.login.blank?
user.errors.add_to_base("User Name can't be blank")
else
user.errors.add_to_base("User Name is too short(Minimum is 3 characters)") if user.login.length<3 and user.login.length !=0
user.errors.add_to_base("User Name is too long(Maximum is 3 characters)") if user.login.length>40
user.errors.add_to_base("User Name has already been taken.") if User.find_by_login(user.login)
@foca
foca / 01_your_personal_manifest.pp
Last active December 22, 2015 10:10
Setting keyboard shortcuts with boxen
class people::foca {
shortcut {
"iTerm Full Screen":
app => "com.googlecode.iterm2",
key => "cmd-shift-f",
menu => "Toggle Full Screen";
"iTerm no-quitting":
app => "com.googlecode.iterm2",
key => nil,
menu => "Quit iTerm";
@foca
foca / get_average_color
Created April 24, 2013 17:37
Silly shellscript to get the average color of a photo using a random website I found on the interwebs
#!/usr/bin/env bash
curl -H "Expect:" -i "http://www.wisegeek.com/how-can-i-find-the-average-color-in-a-photograph.htm" -F mode=upload_image -F imagefile=@"$1" 2>/dev/null | ./inspect_image
require "benchmark"
remove = lambda { |c| Object.send(:remove_const, c) if Object.const_defined?(c) }
static = lambda { |i| name = "S#{i}"; remove[name]; eval "class #{name} < StandardError; end" }
dynamic = lambda { |i| name = "D#{i}"; remove[name]; eval "#{name} = Class.new(StandardError)" }
puts "Ruby #{RUBY_VERSION}"
Benchmark.bmbm do |x|
x.report("dynamic:") { 10_000.times &dynamic }
@foca
foca / README.txt
Created December 3, 2012 23:35
Data from Project Visa (http://projectisa.com) extracted so we can do "reverse lookups" (i.e. to which countries can I go without the hassle of getting a visa?)
$ curl https://gist.github.com/raw/4199075/d9ee698d4d8c8cc0c671bed7b7802d6157988270/visas.yml -o visas.yml
$ irb -ryaml
>> COUNTRIES = YAML.load_file('visas.yml');
?> COUNTRIES.select { |_,v| v.include? "Uruguay" }.keys
=> ["Argentina", "Austria", "Bahamas", "Belgium", "Belize", "Bolivia", "Bosnia-Herzegovina", "Botswana", "Brazil", "Bulgaria", "Chile", "Colombia", "Costa_Rica", "Croatia", "Cyprus", "Czech_Republic", "Denmark", "Dominican_Republic", "El_Salvador", "Estonia", "Falkland_Islands", "Fiji", "Finland", "France", "Georgia", "Germany", "Greece", "Guatemala", "Honduras", "Hungary", "Iceland", "Ireland", "Israel", "Italy", "Jamaica", "Japan", "Kenya", "Latvia", "Liechtenstein", "Lithuania", "Luxembourg", "Macau", "Macedonia", "Malta", "Martinique_(French)", "Mauritius", "Mexico", "Montenegro", "Netherlands", "New_Caledonia_(French)", "New_Zealand", "Norway", "Oman", "Panama", "Paraguay", "Peru", "Poland", "Portugal", "Romania", "Serbia", "Slovakia", "Slovenia", "South_Africa", "South_Korea", "Spain",
@foca
foca / gist:4075089
Created November 15, 2012 05:52
Tiny little shell function to create the layout for a new ruby project.
new-project() {
name="$1";
root="$HOME/Projects/self/$name";
templates="$HOME/Projects/self/_templates";
mkdir -p "$root";
cd $root;
mkdir -p "lib/$name" "test";
touch "lib/$name.rb";
@foca
foca / app.css
Created October 14, 2012 18:32
CSS linear gradient that kills firefox's performance :'(
body {
background-color: rgb(233,227,213);
background-image: linear-gradient(rgb(239,234,223) 50%, rgb(230,223,207) 50%);
background-image: -webkit-linear-gradient(rgb(239,234,223) 50%, rgb(230,223,207) 50%);
background-image: -moz-linear-gradient(rgb(239,234,223) 50%, rgb(230,223,207) 50%);
background-size: 6px 6px;
}
all: screenshot crop
screenshot:
phantomjs screenshot.js ${URL} tmp.png
img:
mkdir -p ./img
crop: img
convert -crop 1440x3000+0x0 tmp.png img/`date -u +%Y-%m-%dT%H:%M:%SZ`.png
@foca
foca / .vimrc
Created September 27, 2012 04:31
My .vimrc
" Use pathogen to manage plugins
call pathogen#infect()
call pathogen#helptags()
" colorscheme foca
" Per-directory .vimrc files
set exrc
set secure