Skip to content

Instantly share code, notes, and snippets.

View fiorix's full-sized avatar

Alexandre Fiori fiorix

View GitHub Profile
@fiorix
fiorix / tehcloud.go
Created November 19, 2015 17:13
Slack bot from da hood: tehcloud
package main
import (
"flag"
"log"
"os"
"os/exec"
"strings"
"github.com/nlopes/slack"
@fiorix
fiorix / akinator.py
Created July 20, 2012 19:49
Interactive command line crawler to akinator.com
#!/usr/bin/env python
# coding: utf-8
#
# Interactive command line crawler to akinator.com
# http://musta.sh/2012-07-20/twisting-python-and-freeswitch.html
import re
import sys
from twisted.internet import defer
@fiorix
fiorix / webtail.py
Created February 27, 2012 00:16
tail -F and broadcast to all of your browsers via sse
#!/usr/bin/env python
# coding: utf-8
#
# start the server:
# python webtail.py /var/log/syslog
#
# point all your browsers to:
# http://localhost:8888
@fiorix
fiorix / freegeoip-httpmux.go
Created March 13, 2016 17:54
freegeoip web server using httpmux
package main
import (
"bytes"
"encoding/csv"
"encoding/json"
"encoding/xml"
"fmt"
"log"
"math/rand"
func RoundUp(v int) int {
return 10 * ((v + 9) / 10)
}
func RoundDown(v int) int {
return 10 * (v / 10)
}
#!/usr/bin/env python
import sys
import time
from getopt import getopt
from PIL import Image
from selenium import webdriver
@fiorix
fiorix / cmd-pipe.go
Last active November 7, 2015 23:00
Using command stdin/out/err to pipe stuff from and to Go.
package main
import (
"encoding/json"
"errors"
"io"
"io/ioutil"
"log"
"os"
"os/exec"
@fiorix
fiorix / test.py
Created August 30, 2012 03:03
twisted memcache client on cyclone web server
# coding: utf-8
# twistd -n cyclone -r test.Application
import cyclone.web
from twisted.internet import defer
from twisted.internet import protocol
from twisted.internet import reactor
from twisted.protocols.memcache import MemCacheProtocol
@fiorix
fiorix / txredisapi_inet_vs_unix.py
Created March 16, 2012 12:59
compare txredisapi's inet vs unix sockets
#!/usr/bin/env python
# coding: utf-8
#
# Compare txredisapi's inet vs unix sockets.
# Don't forget to enable redis' unix socket prior to executing this.
import time
import txredisapi as redis
from twisted.internet import defer
def checkQuota(method):
@defer.inlineCallbacks
@functools.wraps(method)
def wrapper(self, *args, **kwargs):
key = "ip:%s" % self.request.remote_ip
try:
n = yield self.redis.incr(key)
except Exception, e:
log.msg("Redis failed to incr('%s'): %s" % (key, str(e)))