Skip to content

Instantly share code, notes, and snippets.

View AdamG's full-sized avatar

Adam Gomaa AdamG

  • San Francisco, CA
View GitHub Profile
a268e8b37be31c39e33cace27341fbc63406c0a0
http://disco.readthedocs.org/en/0.4.5/start/download.html
> deb http://discoproject.org/debian /
$ sudo apt-get update -q
[snip]
W: Failed to fetch http://discoproject.org/debian/Packages 404 Not Found
?:(
% python2
Python 2.7.4 (default, Apr 19 2013, 18:28:01)
[GCC 4.7.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import cgi
>>> data = 'next=/contact/200/106260296&next=/contact/200/106260296&next=/contact/200/106260296&next=/contact/200/106260296&'
>>> x = cgi.parse_qs(data)
>>> next_list = x['next']
>>> print next_list
['/contact/200/106260296', '/contact/200/106260296', '/contact/200/106260296', '/contact/200/106260296']
def main():
testobj_0 = MemoMethods('test0')
testobj_1 = MemoMethods('test1')
wrong0 = testobj_0.foo_borked
right0 = testobj_0.foo_fixed
wrong1 = testobj_1.foo_borked
right1 = testobj_1.foo_fixed
# this is the bug, wrong0's method is run with test1 as self
@AdamG
AdamG / gist:3796481
Created September 27, 2012 21:08
$HOME/bin/clean
#!/bin/sh
find -xdev -regextype posix-egrep -regex ".*\.(py[co]|orig|old|rej|bak)$" -print0 \
| xargs -0 rm -vf
$ du -sh srv/mysql-server
391M srv/mysql-server
$ # ^C the bzr branch lp:mysql-server
$ du -sh srv/mysql-server
84K srv/mysql-server
$ # ... for serious?
@AdamG
AdamG / imptest.py
Created July 28, 2012 13:23
Inner Import Overhead
import timeit
setup = """
import sys as sys_module_level
def outer_test():
return sys_module_level.version_info
def inner_test():
import sys
return sys.version_info
"""
from django.db import models
from django.db.models.fields import CharField
class ModelField(CharField):
__metaclass__ = models.SubfieldBase
def __init__(self, **kwargs):
kwargs['blank'] = True
kwargs['max_length'] = 255
super(ModelField, self).__init__(**kwargs)
@AdamG
AdamG / gist:1341479
Created November 5, 2011 13:00
NewsBlur reverse cron ordering
diff --git a/apps/reader/views.py b/apps/reader/views.py
index 1d7a89d..13c0a77 100644
--- a/apps/reader/views.py
+++ b/apps/reader/views.py
@@ -421,6 +421,10 @@ def load_single_feed(request, feed_id):
diff1, diff2, userstories_db and userstories_db.count() or '~SN0~SB', diff3))
FeedLoadtime.objects.create(feed=feed, loadtime=timediff)
+ prefs = json.decode(user.profile.preferences)
+ if prefs.get("chronological_ordering", "descending") == "ascending":
@AdamG
AdamG / tagtimed.py
Created October 24, 2011 20:00
python tagtimed
#!/usr/bin/env python
"""
TagTime daemon, in python.
Only trying to get to 'worksforme' here - the perl daemon just isn't
launching anything 3/4 of the time, and I have no idea how to debug
it.
"""