Skip to content

Instantly share code, notes, and snippets.

@wonderb0lt
wonderb0lt / gist:4996796
Created February 20, 2013 16:25
...and that's why I just bucking love git.
git clone ssh://company-repo
git remote add github git://github.com/awesomelibrary
git pull github
git push origin
javascript:(function(){function c(){var e=document.createElement("link");e.setAttribute("type","text/css");e.setAttribute("rel","stylesheet");e.setAttribute("href",f);e.setAttribute("class",l);document.body.appendChild(e)}function h(){var e=document.getElementsByClassName(l);for(var t=0;t<e.length;t++){document.body.removeChild(e[t])}}function p(){var e=document.createElement("div");e.setAttribute("class",a);document.body.appendChild(e);setTimeout(function(){document.body.removeChild(e)},100)}function d(e){return{height:e.offsetHeight,width:e.offsetWidth}}function v(i){var s=d(i);return s.height>e&&s.height<n&&s.width>t&&s.width<r}function m(e){var t=e;var n=0;while(!!t){n+=t.offsetTop;t=t.offsetParent}return n}function g(){var e=document.documentElement;if(!!window.innerWidth){return window.innerHeight}else if(e&&!isNaN(e.clientHeight)){return e.clientHeight}return 0}function y(){if(window.pageYOffset){return window.pageYOffset}return Math.max(document.documentElement.scrollTop,document.body.scrollTop)}funct
@wonderb0lt
wonderb0lt / TweetPonyMisbehaves.py
Last active December 17, 2015 06:39
Error ._.
import json
import pkgutil
import tweetpony
import modules
class DispatchingHandler(tweetpony.api.StreamProcessor):
def __init__(self, api):
tweetpony.api.StreamProcessor.__init__(self, api)
self.handlers = map(lambda h: h.inject_api(self.api), modules.active)
@wonderb0lt
wonderb0lt / gist:5631132
Created May 22, 2013 21:38
A new idea for an Raxacoricofallapatorius-bot-API
from raxa import on_tweet, on_mention
@on_mention(num_mentionees = 1,sender='shadowb0lt')
def on_ponies(tweet):
tweet.reply('Got a tweet from shadowb0lt with some mentionees ;-)!')
@wonderb0lt
wonderb0lt / raxa.py
Created May 22, 2013 21:53
The implementation for gist 5731132
funcs = []
USER_STREAM = '__userstream__'
class on_tweet(object):
def __init__(self, sender = None):
print 'In on_tweet ctor with sender =' + sender
self.sender = sender
@wonderb0lt
wonderb0lt / daemon.py
Last active December 17, 2015 16:19
The API starts working out!
import json
import tweetpony
import glob
import raxa
import inspect
import os.path
# Now it gets ugly:
import modules # Parent
import imp # Please don't beat me up.
@wonderb0lt
wonderb0lt / example.py
Created May 24, 2013 01:04
Another example for my beloved @Mezgrman
from raxa import config, every, api, on_mention
import re
import random
@config()
def config(c):
print 'Received config object: %s' % str(c)
def powersplit(s, seperators):
if not seperators:
return s
result = s.split(seperators[0])
temp = []
for sep in seperators[1:]:
for substring in result:
for subsplit in substring.split(sep):
stripped = subsplit.strip()
# chemicalFormulas.py
#
# Copyright (c) 2003, 2007, Paul McGuire
#
from pyparsing import Word, Optional, OneOrMore, Group, ParseException
# define a simple Python dict of atomic weights, with chemical symbols
# for keys
atomicWeight = {
@wonderb0lt
wonderb0lt / sign.py
Last active December 27, 2015 14:09
A cheap example of HMAC in python.
import base64
import urllib
import hashlib
import hmac
def sign_url(url, key='test'):
h = hmac.new(bytes(key), url, digestmod=hashlib.sha1)
hmacs = urllib.quote_plus(base64.b64encode(h.digest()))
return url + '&hmac=' + hmacs