Skip to content

Instantly share code, notes, and snippets.

View guilleiguaran's full-sized avatar
💭

Guillermo Iguaran guilleiguaran

💭
View GitHub Profile
@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 / 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
source :rubygems
# We are not loading Active Record, nor Active Resources etc.
# We can do this in any app by simply replacing the rails gem
# by the parts we want to use.
gem "actionpack", "~> 3.2"
gem "railties", "~> 3.2"
gem "tzinfo"
# Let's use thin
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Ant sim ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Copyright (c) Rich Hickey. All rights reserved.
; The use and distribution terms for this software are covered by the
; Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
; which can be found in the file CPL.TXT at the root of this distribution.
; By using this software in any fashion, you are agreeing to be bound by
; the terms of this license.
; You must not remove this notice, or any other, from this software.
;dimensions of square world
// 6,046 bytes jarred.
/*
Copyright 2012 Viktor Klang
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
@guilleiguaran
guilleiguaran / php
Created November 24, 2012 17:13 — forked from anonymous/php
<?php
function checkAno($AnoProd)
{
$reg = '/([1-9])([0-9]*)/';
return preg_match($reg, $AnoProd);
}
function checkEmail($Correo)
{
$reg = '#^(((([a-z\d][\.\-\+_]?)*)[a-z0-9])+)\@(((([a-z\d][\.\-_]?){0,62})[a-z\d])+)\.([a-z\d]{2,6})$#i';
return preg_match($reg, $Correo);
@guilleiguaran
guilleiguaran / benchmark.rb
Created July 25, 2012 22:21 — forked from siannopollo/benchmark.rb
Benchmark haml vs. erb
require 'rubygems'
require 'benchmark'
require 'haml'
require 'erubis'
engine = Haml::Engine.new(File.read('template.haml'))
erb_template = File.read('template.erb')
Benchmark.bm do |x|
x.report('haml:') { 1000.times{ engine.render } }
@guilleiguaran
guilleiguaran / juggernaut_channels.rb
Created July 9, 2012 03:16 — forked from lporras/juggernaut_channels.rb
Sinatra Server Side Event streaming with private channels.
# Usage: redis-cli publish message.achannel hello
require 'sinatra'
require 'redis'
conns = Hash.new {|h, k| h[k] = [] }
Thread.abort_on_exception = true
get '/' do
public class Connection {
String URL = "http://iwarn-staging.herokuapp.com/";
String result = "";
String deviceId = "xxxxx" ;
final String tag = "Your Logcat tag: ";
public void callWebServiceForSendData(String jsonData){
HttpClient httpclient = new DefaultHttpClient();