Skip to content

Instantly share code, notes, and snippets.

View oinak's full-sized avatar

Fernando Martínez oinak

View GitHub Profile
#!/bin/env ruby
class Time
Days = Day = 24 * 60 * 60
FixHolidays = Hash.new([]).merge(1 => [1,6], 5 => [1], 10 => [12], 12 => [25])
def self.holidays
@@holidays ||= Hash.new(Hash.new([])) # Year Specific holidays { 2013 => { 1 => [7,8]} }
end
@oinak
oinak / two.rb
Last active August 29, 2015 14:01
segundo ejercicio del taller de metaprogramacón
module Atribulator
module ClassMethods
def my_attr_reader(name)
define_method("#{name}") do
instance_variable_get("@#{name}")
end
end
def my_attr_writer(name, my_type = nil)
if my_type.nil?
@oinak
oinak / three.rb
Last active August 29, 2015 14:01
Tercer ejercicio del taller de metaprogramación
module Donor
def foo(extra)
puts "bar #{extra}"
end
def not_foo
puts "not bar"
end
end
@oinak
oinak / keybase.md
Created January 7, 2015 07:24
keybase.md

Keybase proof

I hereby claim:

  • I am oinak on github.
  • I am oinak (https://keybase.io/oinak) on keybase.
  • I have a public key whose fingerprint is 02CA 3672 C423 0B10 014D 05F2 6668 B7D8 8FA5 D8AC

To claim this, I am signing this object:

@oinak
oinak / README.md
Created January 23, 2015 18:50
Guilded Rose Kata al WeArePeople

The Gilded Rose Code Kata

This is a Ruby version of the Gilded Rose Kata, found [here](http://www.iamnotmyself.com/2011/02/13/RefactorThisTheGildedRoseKata.aspx I Am Not Myself).

This is a refactorying kata, so you will be starting with a legacy code base. To work the Kata, clone this git repository and checkout the tag 'start-here'. Read the description below for the "rules" involving this kata.

@oinak
oinak / first.rb
Created June 10, 2015 09:34
Primer ejercicio del taller de metaprogramación
module Includeable
def have_module
"metodo desde Includeable"
end
def self.included(mod)
puts "Includeable incluido en #{mod}"
end
end
class First
@oinak
oinak / tic_tac_toe.rb
Last active August 29, 2015 14:23
As a meditation on https://practicingruby.com/articles/meditations-on-bad-and-good-code-1 artice, here is my first attempt at refactoring
module TicTacToe
class Game
def self.play
new.run
end
def players
@players ||= %w(X O).cycle
end
# Dieta para verano:
- desayuno: galletas de fibra + café/infusión (en mi caso limonada casera)
- media mañana: fruta (1 ó 2 melocotones o 3 rodajas piña al natural o 2 rodajas de sandía)
- comida: verdura hervida, a la plancha, en conserva o ensalada a tutiplén. Filete de vaca, de pollo o pescado blanco a la plancha. Sin límite de cantidad, cébate!
- media tarde: fruta, como a media mañana
- cena: como la comida + un yogur desnatado o infusión.
- Recomendaciones ;)
- si no la tienes, compra una sartén antiadherente de verdad y límpiala justo después de usarla: podrás hacer cosas a la plancha sin usar aceite y podrás usar más de este para aliñar ensaladas y verduras
- si echas de menos las salsas, prueba a combinar especias, cebolla, ajo, limón... sirven para animar cualquier plato, por insulso que sea
@oinak
oinak / hash_proc_abuse.rb
Created September 15, 2015 16:48
Meditation on ruby hashes with procs as "dinamic conditions" for keys
>> h = {true => '1 is odd', false => '1 is even'}
=> {true=>"1 is odd", false=>"1 is even"}
>> h[true]
=> "1 is odd"
>> h = {1.odd? => '1 is odd', 1.even? => '1 is even'}
=> {true=>"1 is odd", false=>"1 is even"}
>> h[true]
=> "1 is odd"
@oinak
oinak / jazzfonica.rb
Created July 3, 2011 10:10 — forked from christos/jazzfonica.rb
jazzfonica
#!/usr/bin/env ruby
# jazzfonica.rb for Mac OS X
# Scans the visible networks for JAZZTEL_XXXX or WLAN_XXXX and calculates the password
# Ported from PHP example at http://kz.ath.cx/wlan/codigo.txt
# Download and execute with ruby (e.g. ruby jazzfonica.rb) from a Terminal
require 'digest/md5'
messages = []
unless !File.exists?('/System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport')