Skip to content

Instantly share code, notes, and snippets.

View guilleiguaran's full-sized avatar
💭

Guillermo Iguaran guilleiguaran

💭
View GitHub Profile
@guilleiguaran
guilleiguaran / expiring.rb
Created August 4, 2011 17:02
Expiring values with Ohm
module Ohm
module Expiring
def self.included(base)
base.send(:extend, ClassMethods)
end
module ClassMethods
def expire(ttl)
@@expire = ttl.to_i
end
port java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.*;
public class Agente_Viajero extends JFrame implements Runnable
{
Container c;
Mapa mapa;
JList Caminos;
@guilleiguaran
guilleiguaran / carrito.php
Created October 24, 2010 04:23
Carrito de Compras Simple
<?php
/* se recupera el carrito de la variable de sesión */
$carrito = $_SESSION['carrito'];
/* acá se harian las operaciones de agregar/quitar del carrito */
/* se guardan las modificaciones en la variable de sesión */
$_SESSION['carrito'] = $carrito;
?>
@guilleiguaran
guilleiguaran / custom_compiler.rb
Created September 29, 2011 05:08 — forked from nhocki/assets.rake
Compile assets and push them automatically when run rake assets:precompile
class AssetsCompiler < Sprockets::StaticCompiler
def precompile(paths)
ensure_clean_git
Rake::Task["assets:clean"].invoke
super
commit_compiled_assets
push
end
def ensure_clean_git
@guilleiguaran
guilleiguaran / em-http-serv.rb
Created April 1, 2011 01:54
Node.js vs EventMachine
require 'eventmachine'
require 'evma_httpserver'
class MyHttpServer < EM::Connection
include EM::HttpServer
def post_init
super
no_environment_strings
end
@guilleiguaran
guilleiguaran / monoids.rb
Created February 22, 2019 20:25 — forked from KamilLelonek/monoids.rb
Monoids examples in Ruby
[1] (pry) main: 0> 1.class
=> Fixnum
[2] (pry) main: 0> 1.method(:+)
=> #<Method: Fixnum#+>
[3] (pry) main: 0> 1 + 0 == 0 + 1
=> true
[4] (pry) main: 0> 2.0.class
=> Float
[5] (pry) main: 0> 2.0.method(:*)
@guilleiguaran
guilleiguaran / custom_monoid.rb
Created February 22, 2019 20:25 — forked from KamilLelonek/custom_monoid.rb
An example of class monoid in Ruby
[1] (pry) main: 0> class AdditionMonoid
[1] (pry) main: 0* def identity
[1] (pry) main: 0* 0
[1] (pry) main: 0* end
[1] (pry) main: 0*
[1] (pry) main: 0* def operation(a, b)
[1] (pry) main: 0* a + b
[1] (pry) main: 0* end
[1] (pry) main: 0* end
=> :operation
@guilleiguaran
guilleiguaran / assets.rake
Created September 1, 2011 04:26
Fixed rake assets:precompile task
desc "Compile all the assets named in config.assets.precompile"
task :precompile do
# We need to do this dance because RAILS_GROUPS is used
# too early in the boot process and changing here is already too late.
if ENV["RAILS_GROUPS"].to_s.empty? || ENV["RAILS_ENV"].to_s.empty?
ENV["RAILS_GROUPS"] ||= "assets"
ENV["RAILS_ENV"] ||= "production"
Kernel.exec $0, *ARGV
else
Rake::Task["environment"].invoke
@guilleiguaran
guilleiguaran / disable_framework.md
Created October 10, 2012 21:35
Disabling frameworks in Rails 3+

Disabling frameworks in Rails 3+###

Replace in your config/application.rb

require "rails/all"

with:

require "rails"
@guilleiguaran
guilleiguaran / governmentify.sh
Created May 12, 2018 17:28 — forked from krusynth/governmentify.sh
Uses ImageMagick to read in a text file, transform it into an image, rotate it, add noise, and output as a pdf.
cat ./1-219.1.txt | convert \
-font Courier \
text:- \
-rotate `convert null: -format '%[fx:rand()*15-7]' info:` \
-attenuate 0.1247 +noise Gaussian \
-colorspace Gray \
1-219.1.pdf