Skip to content

Instantly share code, notes, and snippets.

Alexandre Fiori fiorix

Block or report user

Report or block fiorix

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View walkstruct.go
package walkstruct
import (
"fmt"
"reflect"
"unicode"
)
// WalkStruct walks the exported fields of a struct using reflection,
// and calls fn for each field.
View mp4gif.sh
#!/bin/bash
FRAMES_DIR=frames.$$
trap "rm -rf ${FRAMES_DIR}" EXIT
FPS=10
WIDTH=480
FONT_COLOR=white
INPUT="$1"
@fiorix
fiorix / pct-diff-calc.py
Created Mar 10, 2017
Percentage Difference Calculator
View pct-diff-calc.py
#!/usr/bin/env python
# Implementation of http://www.calculatorsoup.com/calculators/algebra/percent-difference-calculator.php
v1=5067
v2=5733
def diff(v1, v2):
f1, f2 = float(v1), float(v2)
v = 1 - ((f1 - f2) / ((f1 + f2) / 2) * 100) - 1
return v
@fiorix
fiorix / groupcache.go
Last active Nov 8, 2019
Simple groupcache example
View groupcache.go
// Simple groupcache example: https://github.com/golang/groupcache
// Running 3 instances:
// go run groupcache.go -addr=:8080 -pool=http://127.0.0.1:8080,http://127.0.0.1:8081,http://127.0.0.1:8082
// go run groupcache.go -addr=:8081 -pool=http://127.0.0.1:8081,http://127.0.0.1:8080,http://127.0.0.1:8082
// go run groupcache.go -addr=:8082 -pool=http://127.0.0.1:8082,http://127.0.0.1:8080,http://127.0.0.1:8081
// Testing:
// curl localhost:8080/color?name=red
package main
import (
@fiorix
fiorix / freegeoip-httpmux.go
Created Mar 13, 2016
freegeoip web server using httpmux
View freegeoip-httpmux.go
package main
import (
"bytes"
"encoding/csv"
"encoding/json"
"encoding/xml"
"fmt"
"log"
"math/rand"
View round-int
func RoundUp(v int) int {
return 10 * ((v + 9) / 10)
}
func RoundDown(v int) int {
return 10 * (v / 10)
}
View website-screenshot.py
#!/usr/bin/env python
import sys
import time
from getopt import getopt
from PIL import Image
from selenium import webdriver
@fiorix
fiorix / tehcloud.go
Created Nov 19, 2015
Slack bot from da hood: tehcloud
View tehcloud.go
package main
import (
"flag"
"log"
"os"
"os/exec"
"strings"
"github.com/nlopes/slack"
View go-yeah.go
package main
import (
"flag"
"io"
"net/http"
"os"
"strings"
"github.com/gorilla/handlers"
@fiorix
fiorix / proxy.go
Last active Aug 29, 2015
proxy that can handle/modify html responses
View proxy.go
package main
import (
"io"
"net/http"
"strings"
)
func main() {
p := &proxy{}
You can’t perform that action at this time.