Skip to content

Instantly share code, notes, and snippets.

View rsyring's full-sized avatar

Randy Syring rsyring

View GitHub Profile
@rsyring
rsyring / gist:9520549
Created March 13, 2014 01:50
parse python source for comments
def test_noqa_lines(codeString):
g = tokenize.generate_tokens(StringIO(codeString).readline) # tokenize the string
for toknum, tokval, srow, _, _ in g:
if toknum == N_TOKENS:
pass # do something
@rsyring
rsyring / gist:539797e18eada076bab1
Created July 23, 2014 15:20
autokeyed python dictionary using defaultdict
from collections import defaultdict
def autokeyed_dict():
return defaultdict(autokeyed_dict)
mydict = autokeyed_dict()
mydict['properties']['recent_conversion_event_name']['value'] = 'Test Drive Form'
@rsyring
rsyring / choosing.html
Last active August 29, 2015 14:21
FreeTDS: choosing a protocol version
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html data-ember-extension="1">
<head>
<title>Choosing a TDS protocol version</title>
<meta name="GENERATOR" content="Modular DocBook HTML Stylesheet Version 1.79">
<link rel="HOME" title="FreeTDS User Guide" href="http://www.freetds.org/userguide/index.htm">
<link rel="UP" title="Install FreeTDS" href="http://www.freetds.org/userguide/install.htm">
<link rel="PREVIOUS" title="Install FreeTDS" href="http://www.freetds.org/userguide/install.htm">
<link rel="NEXT" title="servername Lookup" href="http://www.freetds.org/userguide/name.lookup.htm">
<li>
<strong>tracker</strong>:
<span class="tracker">Tasks</span>
</li>
The issues I had with directions for passenger and RVM on ubuntu server 9.04 from this page: http://rvm.beginrescueend.com/integration/passenger/
1) The first issue I have is that it wasn't clear that I had to have a LoadModule after running passenger-install-apache2module. It says in the instructions to ignore what passengers says about passenger_ruby, so I just ignored everything. With that being true, PassengerRuby as a config item was an error, therefore I had to do LoadModule per the instructions from passenger-install-apache2-module.
2) Ditto for the PassengerRoot configuration. I didn't have it originally and I ended up needing to put in there what passenger-install-apache2-module told me to put in there.
3) The code snippet for setting GEM_HOME:
ENV["GEM_HOME"]=%x{"source ~/.bash_profile ; rvm ree%pancake ; rvm gemdir"}.strip
did not work. I got an error that 'source' was not found for the shell 'sh'. I tried the command without the source part, but `rvm gemdir` didn't give the correct gemset
rsyring@antec:~/dev/onebody$ rake onebody:load_sample_data
(in /home/rsyring/dev/onebody)
no such file to load -- bson
<...snip backtrace...>
Missing these required gems:
mongo >= 0.20
You're running:
rsyring@antec:~/dev/onebody$ rake onebody:load_sample_data
(in /home/rsyring/dev/onebody)
rake aborted!
undefined method `symbolize_keys!' for nil:NilClass
(See full trace by running task with --trace)
from isapi import isapicon, threaded_extension
import sys
import traceback
try:
from urllib import urlopen
except ImportError:
# py3k spelling...
from urllib.request import urlopen
import win32api
@rsyring
rsyring / _loader.py
Created February 15, 2011 20:21
Simplified isapi_wsgi
from os import path
from pprint import PrettyPrinter
import sys
from traceback import format_exc
class ErrorApp(object):
""" this will be used if an exception is caused by the iwhelper import """
def __init__(self, trace, debug_info):
self.debug_info = debug_info
self.trace = trace
import isapi_wsgi
from fakeecb import FakeECB
from random import random
import time
from profiledec import profile
def wsgiapp(environ, start_response):
'''Simple app as per PEP 333'''
status = '200 OK'
#time.sleep(.1)