Skip to content

Instantly share code, notes, and snippets.

View mitgr81's full-sized avatar

Chris McGraw mitgr81

  • SONIFI Solutions
  • Sioux Falls, SD
View GitHub Profile
@mitgr81
mitgr81 / consumer.py
Created July 12, 2013 21:03
Just a bit of playing with Celery to see how to schedule tasks for the FUTURE!
from tasks import add
result = add.delay(425, 554)
result.ready()
# OUT: False
result.get()
# OUT: 979
result = add.apply_async((425, 554), countdown=3)
result.ready()
# OUT: False
result.ready()
#!/usr/bin/env python
import random
import redis_wrap
print "All hashes %s " % redis_wrap.SYSTEMS['default'].keys('*')
in_progress_pushes = redis_wrap.get_hash('http://pants.com/ribble')
print "I gotz %s" % in_progress_pushes.keys()
in_progress_pushes['channel'] = random.randint(1040, 1045)
#!/usr/bin/python
# Equivalent of "tail -f" as a webpage using websocket
# Usage: webtail.py PORT FILENAME
# Tested with tornado 2.1
# Thanks to Thomas Pelletier for it's great introduction to tornado+websocket
# http://thomas.pelletier.im/2010/08/websocket-tornado-redis/
import tornado.httpserver
@mitgr81
mitgr81 / drupal_models.py
Created May 10, 2013 18:18
Drupal authorization in django-tastypie
from django.db import models
class Sessions(models.Model):
id = models.IntegerField(primary_key=True, db_column='uid')
session_id = models.CharField(max_length=64, db_column='sid')
class Meta:
db_table = u'sessions'
managed = False # Don't let Django create the tables for this model.
@mitgr81
mitgr81 / servers.py
Created February 18, 2013 04:30
Just a little scriptlet that runs a frontend (in this case, node) web server alongside a backend (in this case, python) server. This should not be used in production unless otherwise proven.
#!/usr/bin/env python
import subprocess
import socket
from multiprocessing import Process
import sys
if sys.version_info < (3,):
range = xrange
BIND_IP = '0.0.0.0'
#showtooltip Misdirection
/focus [modifier: alt]
/stopmacro [modifier: alt]
/cast [target=focus, help, exists, nodead][help][target=pet, exists,nodead] Misdirection
@mitgr81
mitgr81 / Crash Log
Created July 20, 2012 04:46
CurseClient Logs
Process: Curse Client [30288]
Path: /Applications/Curse Client.app/Contents/MacOS/Curse Client
Identifier: com.curse.CurseClient
Version: 4.0.0.425 Beta (4.0.0.425)
Code Type: X86 (Native)
Parent Process: launchd [184]
Date/Time: 2012-07-19 23:22:27.755 -0500
OS Version: Mac OS X 10.7.4 (11E53)
Report Version: 9
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/lettuce/core.py", line 117, in __call__
ret = self.function(self.step, *args, **kw)
File "/src/portal/tests/lettuce/terrain/steps.py", line 86, in horizontal_dragon_drop
test.dragon_drop(source, dest, action_chains=True)
File "/src/portal/tests/python/lnet/testing/acceptance.py", line 2534, in dragon_drop
self.__dragon_drop(source_element, dest_element, action_chains, multiplier)
File "/src/portal/tests/python/lnet/testing/acceptance.py", line 2581, in __dragon_drop
source_element._execute(Command.DRAG_ELEMENT, {'x': drag_coord['x'], 'y': drag_coord['y'] * multiplier})
File "/Library/Python/2.7/site-packages/selenium/webdriver/remote/webelement.py", line 194, in _execute
Downloading/unpacking pytz==2014.1 (from mymodule==0.0.2-dev->-r requirements-ci.txt (line 6))
Running setup.py (path:/Users/buildbot/.virtualenvs/wonderboom_acceptance_happenings/build/pytz/setup.py) egg_info for package pytz
Traceback (most recent call last):
File "<string>", line 17, in <module>
File "/Users/buildbot/.virtualenvs/wonderboom_acceptance_happenings/build/pytz/setup.py", line 30, in <module>
long_description=open('README.txt','r').read(),
File "/Users/buildbot/.virtualenvs/wonderboom_acceptance_happenings/bin/../lib/python3.3/encodings/ascii.py", line 26, in decode
return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 14839: ordinal not in range(128)
Complete output from command python setup.py egg_info: