Skip to content

Instantly share code, notes, and snippets.

View mattd's full-sized avatar

Matt Dawson mattd

  • WillowTree Apps
  • Charlottesville, VA
View GitHub Profile
# BAD
{hosts, [<% @domains.each_with_index do |domain, i| -%>"<%= domain %>"<% if i == @domains.length - 1 -%>, <% end -%><% end -%>]}.
class RelayBot(ClientXMPP):
def __init__(self, jid, password) :
super(RelayBot, self).__init__(jid, password)
self.add_event_handler("session_start", self.handle_session_start)
self.add_event_handler("presence_subscribe",
self.handle_presence_subscribe)
self.add_event_handler("presence_unsubscribe",
self.handle_presence_unsubscribe)
self.add_event_handler("message", self.handle_message)
@app.route('/some_path/')
def some_path():
return render_template('some_template.html')
@mattd
mattd / gist:1006398
Created June 3, 2011 14:12
nginx try_files with a proxy_pass
server {
root /var/www/example.com/static;
server_name example.com;
access_log /var/log/nginx/example.com.access.log;
error_log /var/log/nginx/example.com.error.log;
try_files /maintenance.html @proxy;
location @proxy {
proxy_pass http://127.0.0.1:10001;
#!/bin/bash
unset GIT_DIR
cd /home/<username>/public_html/scripts
git checkout <branchname>
git stash
git reset --hard HEAD
git pull origin <branchname>
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
[remote "origin"]
url = [email protected]:willowtreeapps/mcwilliamsballard
fetch = +refs/heads/*:refs/remotes/origin/*
[remote "dev"]
@mattd
mattd / gist:1351546
Created November 9, 2011 14:15
An irssi growler script. Get notification of nick mentions!
#!/bin/sh
(ssh [email protected] -p 1984 -o PermitLocalCommand=no \
": > .irssi/fnotify ; tail -f .irssi/fnotify " | \
while read heading message; do \
growlnotify -s -t "${heading}" -m "${message}"; \
#say "${heading} says, ${message}"; \
done)&
@mattd
mattd / gist:1351565
Created November 9, 2011 14:22
My irssi config. Make sure to enter your password!
servers = (
{ address = "eu.irc6.net"; chatnet = "IRCnet"; port = "6667"; },
{
address = "irc.open-ircnet.net";
chatnet = "IRCnet";
port = "6667";
},
{ address = "irc.efnet.org"; chatnet = "EFNet"; port = "6667"; },
{
address = "irc.undernet.org";
from setuptools import setup, find_packages
setup(
name='spriggan',
version='0.1',
description="this. is. spriggan.",
long_description=__doc__,
packages=find_packages(),
zip_safe=False,
install_requires=[
db_password = "somepassword"
mysql_command = "mysql -u root -p#{node[:mysql][:server_root_password]} -e"
bash "setup_#{app}_db" do
code <<-EOH
#{mysql_command} "CREATE DATABASE #{app}"
#{mysql_command} "GRANT ALL PRIVILEGES ON #{app}.* \
TO '#{site}'@'localhost' \
IDENTIFIED BY '#{db_password}' \
WITH GRANT OPTION"