Skip to content

Instantly share code, notes, and snippets.

View mrsimo's full-sized avatar
💃
./do run hello

Albert Llop mrsimo

💃
./do run hello
View GitHub Profile
@mrsimo
mrsimo / hack.sh
Created April 4, 2012 08:34 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2299719/hack.sh | sh
#
branches = `git branch`.chomp.split("\n")
branches.map!(&:strip)
branches.each do |branch|
puts "================================"
puts "Considering: #{branch}"
puts
system "git log --color --stat -n 1 #{branch}"
@mrsimo
mrsimo / receta.md
Created November 13, 2011 21:55
Receta de pajaricas (palomitas dulces

Pajaricas

Las pajaricas son palomitas dulces, esta es la receta de mi abuela (de Teruel).

Poner en una olla una medida de maíz, una de azúcar, media de agua y media de aceite de oliva. Con una tacita de café pequeña sale cantidad para una persona, más o menos.

Remover un poquito para que quede uniforme (sino se deshace demasiado azúcar), y poner el fuego a tope. Cuando empiezan a explotar, mover la olla entera circularmente sin alejar del fuego, y no parar hasta que dejen de explotar.

Recomendaciones

# In ActiveRecord I'd usually do when I want to find the organization but only if the user belongs to it:
current_user.organizations.find(params[:id])
# With a has_and_belongs_to_many relationship with Mongoid, I have to do this:
Organization.where(:_id => params[:id], :user_ids => current_user.id).first
# => #<Organization _id: 4ea3302c2907207f5100000f ...
# Because:
current_user.organizations
# => [#<Organization _id: 4ea3302c2907207f5100000f ...>]
# With a typical synchronous API
Api::User.exists?('mrsimo') # => true / false
# With an async API
exists = Api::User.exists?('mrsimo')
API.run_queue
exists.result # => true / false
(rdb:1) cookies
{:intranet_id=>"4", :intranet_hash=>"$2a$10$byweo.aZfMGUpCjgoXjLD.exllI.K8PJ8LZZVnOuC6ve1TzT9Mg5y"}
(rdb:1) cookies[:intranet_id]
nil
(rdb:1) cookies.class
ActionDispatch::Cookies::CookieJar
$ geoffrey install adium
>> Adium is a free instant messaging application for Mac OS X that can connect to AIM, MSN, Jabber, Yahoo, and more.
>> Downloading http://adiumx.cachefly.net/Adium_1.3.10.dmg
: 100% |oooooooooooooooooooooooo| 21.3MB 451.6KB/s ETA: 00:00:00
>> Moving file to /Applications
>> Install successful
# gem install json --version=1.4.6
Successfully installed json_pure-1.4.2
1 gem installed
commit 2400f944f6b5d850c33158ae27f501e9ec8c1aba
Author: Albert Llop <mrsimo@gmail.com>
Date: Thu Aug 26 16:07:46 2010 +0200
First steps into the Package module
Allows the installation of packages from a url. For example:
require 'geoffrey'
Geoffrey.package do
# How to make this more legible?
# n and m are any natural number
n=1; m=12
(n..m).map{ |i| ["%02d"%i,i] }
#=> [["01", 1], ["02", 2], ["03", 3], ["04", 4], ["05", 5], ["06", 6], ["07", 7], ["08", 8], ["09", 9], ["10", 10], ["11", 11], ["12", 12]]