Skip to content

Instantly share code, notes, and snippets.

View jsocol's full-sized avatar
🙃
for oss: hoping to get back to a monthly check-in/update cadence

James Socol jsocol

🙃
for oss: hoping to get back to a monthly check-in/update cadence
View GitHub Profile
@jsocol
jsocol / test.diff
Created December 11, 2015 17:14
failing test for jingo#76
diff --git a/jingo/tests/jinja_app/helpers.py b/jingo/tests/jinja_app/helpers.py
new file mode 100644
index 0000000..62f344d
--- /dev/null
+++ b/jingo/tests/jinja_app/helpers.py
@@ -0,0 +1,8 @@
+from __future__ import absolute_import, unicode_literals
+
+from jingo import register
+
@jsocol
jsocol / classes.py
Created July 20, 2015 21:00
why new-style classes?
>>> class NewStyle(object):
... def foo(self):
... return 'foo'
>>> class OldStyle():
... def foo(self):
... return 'foo'
>>> dir(NewStyle)
['__class__',
from boto.dynamodb2 import connect_to_region
from boto.provider import Provider
aws_settings_provider = Provider('aws')
def create_connection():
aws_region = # get the AWS region of the EC2 instance
# connect_to_region passes along the named arguments
# to the DynamoDBConnection class that gets created
@jsocol
jsocol / mymodel.py
Last active June 3, 2019 14:21
django caching pattern examples
from django.core.cache import cache
from django.db import models
EMPTY = '-' # Not "None"
class MyModel(models.Model):
@classmethod
def _cache_key(cls, key):
return 'mymodel:{}'.format(key)
@jsocol
jsocol / resources.md
Last active November 15, 2021 19:16
Choosing an Open Source License Wisely

Keybase proof

I hereby claim:

  • I am jsocol on github.
  • I am jamessocol (https://keybase.io/jamessocol) on keybase.
  • I have a public key whose fingerprint is B856 FE22 4F11 9DB0 F88E 3BDD 80F9 3DCE 9EBF CF1D

To claim this, I am signing this object:

@jsocol
jsocol / 1f.py
Last active August 29, 2015 14:15
def f1():
a = 0
a += 1
dis.dis(f1)
@jsocol
jsocol / gist:5ca69c9dd5761f55bfd4
Created February 12, 2015 17:57
python is less crazy than it seems
In [8]: def t():
f = ([],)
f[0] += [1]
return f
...:
In [9]: dis.dis(t)
2 0 BUILD_LIST 0
3 BUILD_TUPLE 1
6 STORE_FAST 0 (f)
@jsocol
jsocol / gist:7c2fbccab5a303bb724c
Created February 5, 2015 19:01
python gae sdk virtualenv: what to symlink where
ln -s /Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google /path/to/virtualenv/lib/python2.7/site-packages/google