Skip to content

Instantly share code, notes, and snippets.

View raygunsix's full-sized avatar

Chris Reid raygunsix

  • Raygunsix Consulting Inc.
  • Vancouver, BC
View GitHub Profile
@raygunsix
raygunsix / model.py
Created April 12, 2010 22:01
sample pylons model with sa declarative syntax
from collector.model.meta import Base
# Using SQLAlchemy 0.5 optional declarative syntax
# More info here: http://pylonshq.com/docs/en/0.9.7/models/
# and here: http://pylonshq.com/pasties/1000
class Keyphrases(Base):
__tablename__ = "keyphrases"
__table_args__ = {'schema':'algo'}
@raygunsix
raygunsix / python_email_server.py
Created April 12, 2010 23:56
command to start built-in python mail server
python -m smtpd -n -c DebuggingServer localhost:1025
@raygunsix
raygunsix / indexcontroller.py
Created April 14, 2010 17:09
jsonified pylons index controller with search
def __before__(self):
self.q = Session.query(Keyphrases)
@jsonify
def index(self):
"""GET /keyphrases: All items in the collection"""
# url('keyphrases')
result = []
@raygunsix
raygunsix / add_pageviews_table.py
Created May 3, 2010 20:29
sqlalchemy migration with declaritive syntax
from sqlalchemy import *
from migrate import *
from sqlalchemy.ext.declarative import declarative_base
meta = MetaData(migrate_engine)
Base = declarative_base(metadata=meta)
class Pageviews(Base):
__tablename__ = "pageviews"
# Find connection string from config
eng = meta.engine
conn = str(eng).lstrip('Engine(').rstrip(')')
@raygunsix
raygunsix / lowerit.sh
Created April 18, 2011 19:20
Converts all file names in the current directory to lower case
#!/bin/sh
# lowerit
# convert all file names in the current directory to lower case
# only operates on plain files--does not change the name of directories
# will ask for verification before overwriting an existing file
# Copied from:
# http://www.linuxjournal.com/content/convert-filenames-lowercase
for x in `ls`
@raygunsix
raygunsix / s3it.rb
Created May 11, 2011 00:13
Scrapes URLs and puts the html into an S3 bucket
require 'rubygems'
require 'open-uri'
require 'aws/s3'
require 'json'
AWS::S3::Base.establish_connection!(
:access_key_id => '',
:secret_access_key => ''
)
@raygunsix
raygunsix / reader_test.rb
Created May 17, 2011 22:18
Sauce Labs selenium test with pass / fail status reporting
require "test/unit"
require "rubygems"
require "sauce"
# This should go in your test_helper.rb file if you have one
Sauce.config do |config|
config.browser_url = "http://www.suite101.com/"
config.browsers = [
#["Linux", "firefox", "3.6."],
["Windows 2003", "firefox", "3.6."]
@raygunsix
raygunsix / bashrc.sh
Created August 15, 2011 15:50
.bashrc
# Setup Git completion
source ~/.git-completion.bash
# Define bash colours
source ~/.bash_colors.bash
export CLICOLOR=1
export LSCOLORS=ExFxCxDxBxegedabagacad
# aliases
@raygunsix
raygunsix / .gvimrc
Created August 23, 2011 18:44
Config for MacVim
colorscheme darkblue
set guifont=Menlo:h14
set gcr=n:blinkon0
autocmd vimenter * NERDTree