Skip to content

Instantly share code, notes, and snippets.

View pote's full-sized avatar

pote pote

View GitHub Profile
@pote
pote / cli.sh
Last active August 29, 2015 13:56
Adventure in variable scoping
Hyrule ~/code/tmp
▸ go run scoping.go
./scoping.go:14: variable is shadowed during return
@pote
pote / Gemfile
Created February 5, 2014 20:14
ruby versioning
gem 'nokogiri', :git => 'git://github.com/sparklemotion/nokogiri.git', :tag => 'v1.6.0'
@pote
pote / active_record_hack.rb
Created February 5, 2014 20:17
Single Table Inheritance
# Use in subclasses like:
# delegate_details :win_ratio, :tanning_time, to: :wrestling_details
def self.delegate_details(*attributes)
options = attributes.extract_options!
association_name = options.fetch(:to) {
raise ArgumentError.new "You must specify the name of the details association"
}
define_method association_name do
super() || send("build_#{association_name}")
---
- hosts: web
sudo: yes
accelerate: true
vars:
app_dir: "/var/www/the_application_name_goes_here"
server_env:
RACK_ENV: "production"
SSO_SALT: "esta no es la salt de verdad"
REDIS_URL: "redis://rest_of_url"
@pote
pote / 0_reuse_code.js
Last active August 29, 2015 14:09
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@pote
pote / DiceApp.rb
Created October 11, 2009 22:26
Just a simple Dice throwing app - I plan on adding a Shoes GUI later :)
class Dice
def initialize(sides)
@sides = sides
end
def throw(times)
rolls = []
times.times do |c|
rolls << rand(@sides) + 1
@pote
pote / planet.yml
Created May 21, 2012 18:15
default planet.yml file to test planet.rb against different blogging engines
## Planet.rb default config file, modify it and spawn awesomeness!
planet:
posts_directory: source/_posts/
templates_directory: source/_layouts/
blogs:
- author: "Pablo Astigarraga"
feed: "http://blog.poteland.com/atom.xml"
image: "http://poteland.com/images/avatars/red_mage.png"
package main
import "fmt"
import uuid "github.com/nu7hatch/gouuid"
import (
"fmt"
uuid "github.com/nu7hatch/gouuid"
)
go func() {
for i := 1; i < 100; i++ {
fmt.Println(i)
}
}()
go SomeMotherfuckingExpensiveLoop()
go AnotherMotherfuckingLoop()
// app is keep going here...
@pote
pote / optimal_hours.rb
Created November 8, 2012 19:19
Simple script to calculate how far from my target hours whenever I want to.
require 'date'
today = Date.today
beginning_of_month = Date.parse("#{today.year}-#{today.month}-1")
workable_days_until_now = (beginning_of_month..today).reject { |d| d.saturday? || d.sunday? }.count
optimum_hours_until_now = workable_days_until_now * 6
puts "Workable days until now: #{ workable_days_until_now }"
puts "Optimum hours until now: #{ optimum_hours_until_now }"