Skip to content

Instantly share code, notes, and snippets.

View repejota's full-sized avatar

Raül Pérez repejota

View GitHub Profile
@repejota
repejota / signal.go
Created September 24, 2018 10:08 — forked from reiki4040/signal.go
signal handling example for golang
package main
import (
"fmt"
"os"
"os/signal"
"syscall"
)
func main() {
@repejota
repejota / Makefile
Created December 19, 2017 20:03 — forked from prwhite/Makefile
Add a help target to a Makefile that will allow all targets to be self documenting
# Add the following 'help' target to your Makefile
# And add help text after each target name starting with '\#\#'
help: ## Show this help.
@fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##//'
# Everything below is an example
target00: ## This message will show up when typing 'make help'
@echo does nothing
@repejota
repejota / functional-options.md
Created November 26, 2017 09:13 — forked from travisjeffery/functional-options.md
How to do functional options in Golang

Here's the simplest example showing how to do functional options in Golang.

They're a great way to enable users to set options and ease adding new options later.

package main

import (
	"flag"
	"fmt"
@repejota
repejota / functional-options.md
Created November 26, 2017 09:13 — forked from travisjeffery/functional-options.md
How to do functional options in Golang

Here's the simplest example showing how to do functional options in Golang.

They're a great way to enable users to set options and ease adding new options later.

package main

import (
	"flag"
	"fmt"
curl -s https://myurl.com/script.sh | bash /dev/stdin param1 param2
@repejota
repejota / pipes
Created May 3, 2017 21:05 — forked from msimpson/pipes
2D Bash version of the Pipes screensaver.
#!/bin/bash
declare -i f=75 s=13 r=2000 t=0 c=1 n=0 l=0
declare -ir w=$(tput cols) h=$(tput lines)
declare -i x=$((w/2)) y=$((h/2))
declare -ar v=( [00]="\x83" [01]="\x8f" [03]="\x93"
[10]="\x9b" [11]="\x81" [12]="\x93"
[21]="\x97" [22]="\x83" [23]="\x9b"
[30]="\x97" [32]="\x8f" [33]="\x81" )
OPTIND=1
@repejota
repejota / nodeschool_kids_translations.md
Last active November 27, 2015 18:57
NodeSchool Kids translations

Català

Barcelona NodeSchool és part de l'esforç global anomenat NodeSchool que ensenya voluntàriament Node.js a tothom! El codi font pels tallers és completament de codi obert i l'esforç es totalment dirigit per la comunitat. La millor part és, que és totalment gratuït!

NodeSchool per nens té un format especial on nosaltres programarem robots, Tessel2 i altres coses xules a part del programa habitual "Learn You Node" (Aprèn Node).


English

def authorize_key_for_root(config, *key_paths)
[*key_paths, nil].each do |key_path|
if key_path.nil?
fail "Public key not found at following paths: #{key_paths.join(', ')}"
end
full_key_path = File.expand_path(key_path)
if File.exists?(full_key_path)
config.vm.provision 'file',