Skip to content

Instantly share code, notes, and snippets.

View twitter_sentiment.py
USER = "your_twitter_user"
PASS = "your_twitter_pass"
if "your_twitter" in USER+PASS:
print "You didn't set your twitter username and password in the script!"
USER = raw_input("Username>")
PASS = raw_input("Password>")
import urllib2, json, base64, sys, os
@theepicsnail
theepicsnail / gist:864466
Created Mar 10, 2011
Overriding += to make a call.
View gist:864466
class Bar:
def __init__(self,inst,func,*args):
self.inst = inst
self.func = func
self.args = args
def __iadd__(self,*args,**kwargs):
return self.__call__(*args,**kwargs)
def __call__(self,*args,**kwargs):
self.func(self.inst,*(self.args+args),**kwargs)
View gist:875409
import socket
server = ''
port = 1235
def run():
while True:
i = raw_input("Enter a number!")
s = socket.socket()
s.connect((server,port))
s.send("activate %s"%i)
s.close()
View gist:875412
import socket,threading
from time import sleep
port = 1235
class DMX(threading.Thread):
running = True
life = [0,0,0,0,0,0]
def activate(self,num):
if num < 0 or num > 5:
return
self.life[num]=10
@theepicsnail
theepicsnail / gist:899241
Created Apr 2, 2011
Google via mechanize
View gist:899241
import mechanize
br = mechanize.Browser()
br.set_handle_equiv(True)
br.set_handle_redirect(True)
br.set_handle_referer(True)
br.set_handle_robots(False)
br.addheaders = [('User-agent', 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.1) Gecko/2008071615 Fedora/3.0.1-1.fc9 Firefox/3.0.1')]
def doSearch(term):
global br
@theepicsnail
theepicsnail / kaa.py
Created Nov 26, 2011 — forked from maxcountryman/kaa.py
A very simple non-blocking IRC bot using gevent
View kaa.py
import gevent
from gevent import socket, queue
from gevent.ssl import wrap_socket
import logging
logger = logging.getLogger('irc')
logger.setLevel(logging.DEBUG)
ch = logging.StreamHandler()
View gist:2360388
set x,0 ;x = fib[n-1]
set y,1 ;y = fib[n]
set j,24;number of loops
:loop
set z,x; z = fib[n]+fib[n-1]
add z,y
set x,y;Set X to the new fib[n-1] (the old fib[n])
set y,z;set Y to the new fib[n] (calculated.)
View gist:2363653
set x,0
set y,0
:row
jsr getVal
set c,32
shl z,4
add c,z
bor c,0xf000
set a,y
View gist:2364589
jsr init
jsr mainLoop
sub pc,1
;copy from 0x8200-0x83ff to 0x8000-0x81ff
:blit