Skip to content

Instantly share code, notes, and snippets.

View MachinesAreUs's full-sized avatar

Agustín Ramos MachinesAreUs

View GitHub Profile
@MachinesAreUs
MachinesAreUs / gist:1886189
Created February 22, 2012 17:27
4 software archaeologists: Find all solutions/projects in a .Net repository
find . -name '*.sln' > solutions.txt
while read line; do
name=`basename "$line"`;
grep '^Project.*\.csproj' "$line" |
awk -F'=' '{print $2}' |
awk -F',' -v sln="$name" '{print sln "," $1 "," $2}' ;
done < solutions.txt > solutionsAndProjects.csv
@MachinesAreUs
MachinesAreUs / gist:2029919
Created March 13, 2012 17:00
FizzBuzz en haskell
fizzbuzz x
| x `mod` 3 == 0 && x `mod` 5 == 0 = "fizzbuzz"
| x `mod` 3 == 0 = "fizz"
| x `mod` 5 == 0 = "buzz"
| otherwise = show x
fizzbuzz100 =
mapM_ putStrLn [ fizzbuzz x | x <- [1..100] ]
@MachinesAreUs
MachinesAreUs / gist:3014977
Created June 29, 2012 00:45 — forked from chrix2/gist:2232656
Get parent build Jenkins
def myJob = hudson.model.Hudson.instance.getItem("My_Job")
def lastBuild = myJob.getLastBuild()
def cause = lastBuild.getCause(hudson.model.Cause$UpstreamCause)
def parentBuildNum = cause.upstreamBuild
def parentJobName = cause.upstreamProject
def parentJobUrl = cause.upstreamUrl
println(parentBuildNum)
println(parentJobName)
println(parentJobUrl)
@MachinesAreUs
MachinesAreUs / servicios_medtzin.sh
Created August 17, 2012 21:29
Obtiene la lista de métodos de interfaces (C#)
for f in `ls -d *faces`; do ls $f/*.cs ; done > interfaces_servicios.txt
while read line; do
grep -e '.*(.*);' $line | sed -e 's/^ *//g' -e 's/;//g'|
awk -v file=$line '{
idxMethod=index($0," ")+1;
idxArgs=index($0,"(");
print file"|"$1"|"substr($0,idxMethod,idxArgs-idxMethod)"|"substr($0,idxArgs)
}'; done < interfaces_servicios.txt > servicios_medtzin.csv
@MachinesAreUs
MachinesAreUs / generate_batch.rb
Created August 20, 2012 04:42
Simple example to generate a batch process from ruby
require 'erb'
template = ERB.new <<-EOF
This is a greeting to <%= name %>.
EOF
File.readlines('names.txt').each do |line|
name = line.chomp
puts template.result(binding)
end
@MachinesAreUs
MachinesAreUs / HelloSwing.clj
Created September 4, 2012 01:08
Hello world in Clojure/Swing
(:use 'seesaw.core)
(def lbl (label "Swing App in Clojure/Seesaw"))
(def btn (button :text "Click me"))
(listen btn :action (fn [e] (config! lbl :text "You clicked me!" )))
(frame :title "Hello Swing in Clojure",
:content (border-panel
:center btn
:south lbl
@MachinesAreUs
MachinesAreUs / DropSPs.rb
Created September 6, 2012 12:40
Example for creating SQL script from a templat in Ruby
require 'fileutils'
require 'erb'
template = ERB.new <<-EOF
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'<%= sp_name %>') AND type in (N'P', N'PC'))
DROP PROCEDURE <%= sp_name %>
GO
EOF
@MachinesAreUs
MachinesAreUs / MyGitDailyWork
Created October 2, 2012 22:11
My work today on my Git repo
# "Executive" summary
git log --author="Agustin Ramos" --since="6am" --pretty=oneline
# With stats
git log --author="Agustin Ramos" --since="6am" --pretty=oneline --stat
# With timestamps
@MachinesAreUs
MachinesAreUs / remove_accents.rb
Created August 23, 2013 02:23
Cómo transformar acentos, diéresis, 'ñ' y otros caracteres a su símil más directo.
require 'I18n'
I18n.transliterate("Agustín") == "Agustin" # => true
I18n.transliterate("año") == "ano" # => true
I18n.transliterate("güero") == "guero" # => true
import Window
import Graphics.Collage
iterations = 8
middle (x,y) (x',y') = ((x + x') / 2, (y + y') / 2)
set n idx [p1, p2, p3] =
let [a,b,c] = [middle p1 p2, middle p2 p3, middle p1 p3]
subTriangles = [