Skip to content

Instantly share code, notes, and snippets.

View amuino's full-sized avatar

Abel Muiño amuino

View GitHub Profile
require 'rspec'
class Fixnum
ROMANS = { M: 1000, CM: 900, D: 500, CD: 400, C: 100, XC: 90, L: 50, XL: 40, X: 10, IX: 9, V: 5, IV: 4, I: 1 }
def to_roman
remaining_number = self
ROMANS.inject ("") do | roman_str, current_number |
times,remaining_number = remaining_number.divmod current_number[1]
roman_str + current_number[0].to_s * times
@amuino
amuino / Quicksort interactivo.html
Created February 14, 2011 18:01
Partiendo del algoritmo de quicksort en javascript, modificarlo para que sea el usuario el que decida el resultado de la comparación (por ejemplo, para ordenar un ranking con "pocos" clicks enfrentando elementos dos a dos). http://en.literateprograms.org
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>untitled</title>
<meta name="generator" content="TextMate http://macromates.com/">
<meta name="author" content="Abel Muiño Vizcaino">
<!-- Date: 2011-02-14 -->
@amuino
amuino / trucos.css
Created March 23, 2011 09:21
Trucos de CSS vistos en webs reales para efectos "vistosos"
/* Texto elevado */
.elevado {
color: white;
text-shadow: 0 1px 4px rgba(0, 0, 0, 0.68);
}
/* Texto hundido (grabado) */
.hundido {
color: #243748;
text-shadow: 0 1px 1px rgba(255, 255, 255, 0.33);
@amuino
amuino / weird_date_calculation.rb
Created March 30, 2011 22:16
Rails does really funny things in the late hours
# It is 00:15
ruby-1.9.2-p180 :025 > Time.now
=> 2011-03-31 00:15:10 +0200
# Today is 31st of March
ruby-1.9.2-p180 :023 > Date.today
=> Thu, 31 Mar 2011
# Yesterday was 29 of March ????? WTF!!!
ruby-1.9.2-p180 :024 > Date.yesterday
@amuino
amuino / Link.txt
Created April 4, 2011 15:17
Resultado de rake stats para el proyecto pymeprivee del All Together Now
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>untitled</title>
<meta name="generator" content="TextMate http://macromates.com/">
<meta name="author" content="Abel Muiño Vizcaino">
<style type="text/css" media="screen">
body {
@amuino
amuino / example.html
Created June 1, 2011 20:32
Copy of "flash" effect in Ducksboard.com
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>untitled</title>
<meta name="generator" content="TextMate http://macromates.com/">
<meta name="author" content="Abel Muiño Vizcaino">
<style>
body {
@amuino
amuino / DefensiveProgramming.java
Created July 19, 2011 17:36
The wrong mindset
int numberOfThingsThatAreSorted = getCustomComparatorNumberOfKnownThingsForSorting();
int numberOfActualThings = getAllThings().size();
if (numberOfThingsThatAreSorted < numberOfActualThings)
throw new IllegalStateException(
"An implementation of ThisClass (whose abstract subclasses are ThatOtherClass and YetAnotherClass) "
+ "must ensure that all the Things it specifies are also passed in for custom sorting. Instead found only "
+ numberOfThingsThatAreSorted
+ " Things to be sorted, as implemented by getCustomComparatorNumberOfKnownThingsForSorting, but "
+ numberOfActualThings + " actual Things.");
@amuino
amuino / gist:3766049
Created September 22, 2012 12:31
Fast RSpec without Spork - avoid loading rails again and again
rails c test
ActiveRecord::Base.logger.level = Logger::WARN
require 'rspec'
reload! ; RSpec::Core::Runner.run ["spec"]
reload! ; RSpec::Core::Runner.run ["spec"]
reload! ; RSpec::Core::Runner.run ["spec"]
reload! ; RSpec::Core::Runner.run ["spec"]
reload! ; RSpec::Core::Runner.run ["spec"]
reload! ; RSpec::Core::Runner.run ["spec"]
@amuino
amuino / ping al router
Created March 16, 2013 15:29
Un ejemplo de mi vida con el router Scientific Atlanta de @ono_ono via WIFI
Request timeout for icmp_seq 219
Request timeout for icmp_seq 220
Request timeout for icmp_seq 221
Request timeout for icmp_seq 222
Request timeout for icmp_seq 223
Request timeout for icmp_seq 224
Request timeout for icmp_seq 225
Request timeout for icmp_seq 226
Request timeout for icmp_seq 227
Request timeout for icmp_seq 228