Skip to content

Instantly share code, notes, and snippets.

View mattjbarlow's full-sized avatar
🎯
Focusing

Matt Barlow mattjbarlow

🎯
Focusing
View GitHub Profile
@mattjbarlow
mattjbarlow / gist:c1ccba3020293ba345db
Created May 3, 2014 13:46
start-statsd-graphite.sh
#!/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'
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):
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
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()
@mattjbarlow
mattjbarlow / 0_reuse_code.js
Created November 19, 2013 18:45
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
print
def hello():
print 'Hello!'
def area_rectangle(width, height):
return width * height
def area_square(side):
return side*side
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.
@mattjbarlow
mattjbarlow / gist:7379139
Last active December 27, 2015 19:39
Trying to match universe multiple times between START and END lines.
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.
import re
address = re.compile(
'''
# The regular name
(?P<first_name>\w+)
\s+
(([\w.]+)\s+)? # optional middle name or initial
(?P<last_name>\w+)
import re
address = re.compile(
r'''
# The regular name
(\w+) # first name
\s+
(([\w.]+)\s+)? # optional middle name or initial
(\w+) # last name