Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am tanob on github.
  • I am tanob (https://keybase.io/tanob) on keybase.
  • I have a public key ASDVxZL8l05sn52Pu3LWoyWVgGyi8eN4NQIzNyvB6lSyygo

To claim this, I am signing this object:

@tanob
tanob / _README.md
Last active June 15, 2016 18:07 — forked from schickling/_README.md
Script to import and export docker-machine configurations to sync between hosts/collaborators

docker-machine import/export

Script to import and export docker-machine configurations to sync between hosts/collaborators

Export (on host A)

$ docker-machine ls
NAME       ACTIVE   DRIVER         STATE     URL                            SWARM   DOCKER    ERRORS
dev        -        digitalocean   Running   tcp://example.com:2376                 v1.10.1
@tanob
tanob / docker-compose.yml
Created December 2, 2015 15:40
Simple docker-compose to get GoCD server & agent running
server:
image: gocd/gocd-server
hostname: go-server # Needed so the go-agent can find the server
ports:
- '8153:8153'
- '8154:8154'
agent:
image: gocd/gocd-agent
links:
- server
@tanob
tanob / CommandRunner.groovy
Created March 2, 2015 19:12
A problem with Gradle's Instantiator and closures referencing class' private fields
import org.gradle.api.Project
class CommandRunner {
private final Project project
def CommandRunner(Project project) {
this.project = project
}
public String run(Object... args) {
@tanob
tanob / parser.rb
Created January 2, 2014 14:05
Uso: $ ../INPUTS/parser.rb ../INPUTS/TS_ESCOLA.map < TS_ESCOLA.TXT > indicadores_por_escola.csv
#!/usr/bin/env ruby
input_map = IO.readlines(ARGV[0]).inject({}) do |memo, line|
field_name, fstart, fend = line.match(/(\S+)\s+([0-9]+)-([0-9]+)/).captures
range = Range.new(fstart.to_i, fend.to_i)
memo.merge({field_name => range})
end
class Parser
attr_accessor :line
-- Make: ghc --make groups.hs
-- Run: echo -e "[4,3,3,2]\n[5,3,2,1,1,3,5]\n[4,5]" | ./groups
import System.IO
import Data.List
isSameSolution f (s1,s2) = f == (s2,s1)
discardDuplicated = nubBy isSameSolution
uniqueSubsequences = filter ((/=0).length) . nub . subsequences
solutionsFor list = discardDuplicated solutions
@tanob
tanob / Error when running mirahc
Created August 5, 2011 02:31
Trying to write a macro
Parsing...
macro.mirah
Inferring types...
Inference Error:
Could not infer typing for nodes:
FunctionalCall(find_class)
Call(parent)
Field(call) at line 14 (child of LocalAssignment(name = class_node, scope = MethodDefinition(_expand), captured = false))
macro.mirah:12: Could not infer typing for nodes:
FunctionalCall(find_class)
@tanob
tanob / gist:945821
Created April 28, 2011 04:46
AppleScript to open a new tab in iTerm2 from Finder
-- Stefan van den Oord, 2010-12-29
-- The "cd to" command for iTerm2
-- Original from: http://code.google.com/p/iterm2/wiki/AppleScript
-- Modified to open a new tab instead of a new window
tell application "Finder"
set _cwd to POSIX path of ((folder of (front window)) as alias)
end tell
tell application "iTerm"
@tanob
tanob / fizzbuzz.hs
Created November 27, 2010 18:35
Prints the first 100 fizzbuzz numbers, implemented in Haskell.
fizz n = n `mod` 3 == 0
buzz n = n `mod` 5 == 0
fizzbuzzFor n | fizz n && buzz n = "fizzbuzz"
| fizz n = "fizz"
| buzz n = "buzz"
| otherwise = show n
main = mapM_ (putStrLn . fizzbuzzFor) [1..100]
@tanob
tanob / happy.hs
Created August 13, 2010 05:44
Determines if a number is happy
import Data.Char;h 1 _=1;h x m|any(==x)m=0;h x m=h(sum$map((^2).digitToInt)$show x)(x:m);main=print$h 7 []