Skip to content

Instantly share code, notes, and snippets.

View lxfontes's full-sized avatar
🌋

Lucas Fontes lxfontes

🌋
View GitHub Profile
@lxfontes
lxfontes / main.go
Created March 8, 2018 04:01
etcd internal state sync
package main
import (
"context"
"log"
"time"
"github.com/coreos/etcd/client"
)
package main
import (
"fmt"
"math/rand"
)
var (
left = [...]string{
"admiring",
package main
import (
"fmt"
"os"
"os/exec"
"os/signal"
"syscall"
)
// compile with
// gcc -o goodbye goodbye.c
#define w while
typedef char z; typedef z * zz;
z R(z d) { return isalpha(d)?tolower(d)<'n'?d+13:d-13:d; }
char buf[] = "\x59\x6f\x75\x20\x77\x69\x6c\x6c\x20\x68\x61\x76\x65\x20\x74\x6f\x20\x72\x75\x6e\x20\x69\x74\x20\x3b\x29\x00\x72\x66\x79\x72\x20\x72\x61\x62\x6c\x61\x6e\x20\x61\x6e\x75\x67\x20\x65\x72\x67\x67\x72\x6f\x20\x67\x76\x20\x62\x71\x20\x71\x61\x6e\x20\x2c\x74\x61\x76\x75\x67\x20\x72\x61\x62\x20\x65\x68\x62\x6c\x20\x71\x61\x76\x53\x00";
int main() {
z x; zz xx = buf; zz xy;
w(*xx)xx++;xx++;
@lxfontes
lxfontes / spotit.rb
Created October 15, 2015 01:40
Generate deck of cards with single link
#!/usr/bin/env ruby
# use prime numbers
def generate_deck(size = 7)
cards = []
(0...size).each do |i|
(0...size).each do |j|
card = []
(0...size).each do |k|
@lxfontes
lxfontes / proxy.conf
Created August 20, 2015 03:12
openresty jwt proxy
lua_package_path "/etc/nginx/lua/?.lua;;";
lua_shared_dict kids 10m;
server {
server_name google.com www.google.com;
location /_/token {
internal;
proxy_pass http://127.0.0.1:5000;
}
@lxfontes
lxfontes / sup.yml
Created August 18, 2015 14:50
sup.yml
env:
NAME: projectA
networks:
local:
env:
BRANCH: devel
hosts:
builder:
- localhost
@lxfontes
lxfontes / parser.rb
Last active August 29, 2015 14:23
parslet example
require 'parslet'
require 'pp'
class QueryParser < Parslet::Parser
rule(:space) { match('\s').repeat(1) }
rule(:space?) { space.maybe }
rule(:lparen) { str('(') >> space? }
rule(:lparen?) { lparen.maybe }
rule(:rparen) { str(')') >> space? }
import RPi.GPIO as GPIO
import time
import signal
import sys
def sig_handler(s,f):
print("Cleaning up")
GPIO.cleanup()
sys.exit(0)
@lxfontes
lxfontes / github_hook.go
Created January 11, 2015 17:59
Github Signature verification
import (
"crypto/hmac"
"crypto/sha1"
"encoding/hex"
"errors"
)
func verifyGithubSignature(secret string, payload []byte, signature string) error {
if len(signature) < 5 {
return errors.New("Github Signature is too small")