This file contains hidden or 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
#!/bin/bash | |
# start carbon data collection daemon - default port: 2003 -------------------- | |
mkdir -p /var/log/carbon | |
/opt/graphite/bin/carbon-cache.py start --logdir=/var/log/carbon | |
# configure graphite ---------------------------------------------------------- | |
mkdir -p /var/log/graphite | |
cat << EOF > /opt/graphite/webapp/graphite/local_settings.py | |
LOG_DIR = '/var/log/graphite' |
This file contains hidden or 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
from sqlalchemy import Column, Integer, String | |
class Animal(Base): | |
__tablename__ = 'animals' | |
id = Column(Integer, primary_key=True) | |
common_name = Column(String) | |
latin_name = Column(String) | |
kingdom = Column(String) | |
def __init__(self, common_name, latin_name, kingdom): |
This file contains hidden or 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
class TweetSearch < ActiveRecord::Base | |
attr_accessible :status, :tweet_id, :user | |
def self.query(search_item="pizza") | |
starttime = Time.now | |
result = Twitter.search(search_item, :count => 10, :result_type => "recent").results.first | |
tweettime = ((Time.now - starttime) * 1000).to_i | |
METRICS.timing('tweetsearch.query', tweettime) | |
return result | |
end |
This file contains hidden or 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 subprocess | |
import statsd | |
import re | |
import argparse | |
parser = argparse.ArgumentParser(description='Send num processes to StatsD') | |
parser.add_argument('servername', metavar='S', type=str, | |
help='The server that is generating this process list.') | |
args = parser.parse_args() |
This file contains hidden or 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 hidden or 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 hello(): | |
print 'Hello!' | |
def area_rectangle(width, height): | |
return width * height | |
def area_square(side): | |
return side*side |
This file contains hidden or 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 re | |
re.compile( | |
''' | |
(\d{3}) # Search for 3 digits and group them. | |
\D* # Followed by 0 or more non digit characters. | |
(\d{3}) # Followed by 3 digits grouped. | |
\D* # Followed by 0 or more non digit characters. | |
(\d{4}) # Followed by 4 digits grouped. |
This file contains hidden or 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 re | |
divine_comedy = """ | |
Test word universe should not match. | |
*** START *** | |
His glory, by whose might all things are mov'd, | |
Pierces the universe, and in one part | |
One more universe. |
This file contains hidden or 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 re | |
address = re.compile( | |
''' | |
# The regular name | |
(?P<first_name>\w+) | |
\s+ | |
(([\w.]+)\s+)? # optional middle name or initial | |
(?P<last_name>\w+) |
This file contains hidden or 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 re | |
address = re.compile( | |
r''' | |
# The regular name | |
(\w+) # first name | |
\s+ | |
(([\w.]+)\s+)? # optional middle name or initial | |
(\w+) # last name |