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:242b66cdae6938d34419
Created December 22, 2014 15:40
Chef Shell in Test Kitchen
cd into /tmp/kitchen.
/opt/chef/embedded/bin/gem install chef-zero
/opt/chef/embedded/bin/chef-zero -d
knife cookbook upload -a -c client.rb
chef-shell -z -c client.rb -o '<YOUR RECIPE>'
Tue Jan 24 21:08:34 UTC 2017
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+)