This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"flag" | |
"log" | |
"os" | |
"os/exec" | |
"strings" | |
"github.com/nlopes/slack" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# coding: utf-8 | |
# | |
# start the server: | |
# python webtail.py /var/log/syslog | |
# | |
# point all your browsers to: | |
# http://localhost:8888 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"bytes" | |
"encoding/csv" | |
"encoding/json" | |
"encoding/xml" | |
"fmt" | |
"log" | |
"math/rand" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func RoundUp(v int) int { | |
return 10 * ((v + 9) / 10) | |
} | |
func RoundDown(v int) int { | |
return 10 * (v / 10) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import sys | |
import time | |
from getopt import getopt | |
from PIL import Image | |
from selenium import webdriver |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"encoding/json" | |
"errors" | |
"io" | |
"io/ioutil" | |
"log" | |
"os" | |
"os/exec" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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))) |