Skip to content

Instantly share code, notes, and snippets.

View ryazwinski's full-sized avatar

Rick Yazwinski ryazwinski

View GitHub Profile
Verifying my Blockstack ID is secured with the address 1E8A2cbd1sPbPwhj6Js7xyMctkNGxaPWUm https://explorer.blockstack.org/address/1E8A2cbd1sPbPwhj6Js7xyMctkNGxaPWUm
@ryazwinski
ryazwinski / gist:6322851
Created August 23, 2013 19:03
Django "invalid" model attributes?
class TestModel(models.Model):
my_field = models.CharField(max_length=20)
tm = TestModel.objects.create(my_field='test')
tm.foo = 'bar' # how do I make this fail?
@ryazwinski
ryazwinski / gist:946814
Created April 28, 2011 17:28
patching example
class Tester():
def a(self):
print 'a'
def b(self):
print 'b'
Visualizing Twitter Search Results with Protovis and/or Graphviz is this easy:
$ easy_install twitter # See https://github.com/sixohsix/twitter and http://pypi.python.org/pypi/setuptools
$ git clone https://github.com/ptwobrussell/Mining-the-Social-Web.git
$ cd Mining-the-Social-Web/python_code
$ python introduction__retweet_visualization.py TeaParty # or whatever you want to search for
Your browser should pop open and display the results as a force directed graph, but also check your console for some useful output.
You can create an image file from the DOT language output with a command like the following:
@ryazwinski
ryazwinski / gist:711879
Created November 23, 2010 14:59
weight_calc.py
def rcalc(w):
plates = [ 45, 35, 25, 10, 5, 2.5 ]
if w < plates[-1] * 2:
return (False, [])
for i in plates:
rem = w - (i * 2)
if rem > 0:
if [ "`echo $0 | grep bash`" != "" ] ; then
if [ -f /etc/bash_completion ] ; then
. /etc/bash_completion
export PS1='${IP} ${debian_chroot:+($debian_chroot)}\u@\h:$(__git_ps1) \w\$ '
fi
fi