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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
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 time | |
from getpass import getpass | |
from textwrap import TextWrapper | |
import tweepy | |
class StreamWatcherListener(tweepy.StreamListener): |
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
import tweepy | |
import json | |
# Authentication details. To obtain these visit dev.twitter.com | |
consumer_key = '' | |
consumer_secret = '' | |
access_token = '' | |
access_token_secret = '' | |
# This is the listener, resposible for receiving data |
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 | |
# I wasn't happy with any of the GitHub libraries for Python that I tried so I | |
# just used the GitHub API directly. If someone would like to rewrite this | |
# using a library please be my guest | |
import argparse | |
import base64 | |
import getpass | |
import json |
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
import os | |
import cPickle as pickle | |
def cached_data(): | |
cache_path = "/tmp/cached-data.pickle" | |
if not os.path.exists(cache_path): | |
# The cache doesn't exist, create it and populate it | |
result = generate_data() | |
cache_file = open(cache_path,'wb') | |
# Write it to the result to the file as a pickled object |
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
import mechanize | |
br = mechanize.Browser() | |
br.add_password("http://blah.blah/", "adm", "mps") | |
response = br.open("http://blah.blah/somepage.html") | |
br.select_form(nr=1) | |
br["junk"]=["hatethis"] | |
response3=br.form.click(name="applybutton",nr=1) |
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
<form> <label>TestDynamicPanel</label> <fieldset submitButton="false"> <input type="dropdown" token="show1"> <label>Dropdown1</label> <populatingSearch fieldForLabel="temp" fieldForValue="temp">|gentimes start=-1 | eval temp="ColumnChart" | table temp</populatingSearch> </input> <input type="dropdown" token="show2"> <label>Dropdown2</label> <populatingSearch fieldForLabel="temp" fieldForValue="temp">|gentimes start=-1 | eval temp="LineChart" | table temp</populatingSearch> </input> <input type="dropdown" token="show3"> <label>Dropdown3</label> <populatingSearch fieldForLabel="temp" fieldForValue="temp">|gentimes start=-1 | eval temp="Table" | table temp</populatingSearch> </input> </fieldset> <row> <panel> <chart depends="$show1$"> <title>Details for $submitted:sourcetype|s$</title> <searchString>index=_internal | timechart count</searchString> <earliestTime>-15m</earliestTime> <latestTime>now</latestTime |
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 print_everything(*args): | |
for count, thing in enumerate(args): | |
... print '{0}. {1}'.format(count, thing) | |
... | |
>>> print_everything('apple', 'banana', 'cabbage') | |
0. apple | |
1. banana | |
2. cabbage |
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 table_things(**kwargs): | |
... for name, value in kwargs.items(): | |
... print '{0} = {1}'.format(name, value) | |
... | |
>>> table_things(apple = 'fruit', cabbage = 'vegetable') | |
cabbage = vegetable | |
apple = fruit |
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 f1(seq): | |
# not order preserving | |
set = {} | |
map(set.__setitem__, seq, []) | |
return set.keys() | |
def f2(seq): | |
# order preserving | |
checked = [] | |
for e in seq: |
OlderNewer