This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git diff --word-diff=color --word-diff-regex=[^,$]+ <file1> <file2> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import gc | |
from io import StringIO | |
import xml.etree.ElementTree as etree | |
import objgraph | |
def parse_xml(): | |
xml = """ | |
<LEVEL1> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Keybase proof | |
I hereby claim: | |
* I am grokcode on github. | |
* I am grokcode (https://keybase.io/grokcode) on keybase. | |
* I have a public key ASA01gbqLmX41b8VaBMJmHKo800oujS9A6ZHgBpovfVTtAo | |
To claim this, I am signing this object: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pytest | |
# Solution in Python 3.6 | |
def flatten(a): | |
""" | |
Flatten a list by removing nested lists while preserving their elements. | |
(Python doesn't have native arrays, we can use lists instead.) | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This Gist covers how to use Django's signing functions for one-click unsubscribes | |
# The following code can go in the UserProfile | |
from django.core.signing import TimestampSigner, BadSignature, SignatureExpired | |
def create_unsubscribe_link(self): | |
username, token = self.make_token().split(":", 1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ VAGRANT_LOG=debug vagrant halt web | |
INFO global: Vagrant version: 1.2.2 | |
DEBUG global: Loading core plugin: /Applications/Vagrant/embedded/gems/gems/vagrant-1.2.2/plugins/commands/box/plugin.rb | |
INFO manager: Registered plugin: box command | |
DEBUG global: Loading core plugin: /Applications/Vagrant/embedded/gems/gems/vagrant-1.2.2/plugins/commands/destroy/plugin.rb | |
INFO manager: Registered plugin: destroy command | |
DEBUG global: Loading core plugin: /Applications/Vagrant/embedded/gems/gems/vagrant-1.2.2/plugins/commands/halt/plugin.rb | |
INFO manager: Registered plugin: halt command | |
DEBUG global: Loading core plugin: /Applications/Vagrant/embedded/gems/gems/vagrant-1.2.2/plugins/commands/init/plugin.rb | |
INFO manager: Registered plugin: init command |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
year_ago = date.today() - timedelta(days=365) | |
q_new_books = Q(orig_pub_date=None) | Q(orig_pub_date__gt=year_ago) | |
q_multiple_books = Q(book__count__gt=1) | |
qs = Works.objects.all() | |
len(qs.annotate(Count('book')).filter(q_new_books)) # 14 | |
len(qs.annotate(Count('book')).filter(q_multiple_books)) # 72 | |
len(qs.annotate(Count('book')).filter(q_new_books | q_multiple_books)) # 8 WTF? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta http-equiv="Content-type" content="text/html; charset=utf-8" /> | |
<title>Stripe Getting Started Form</title> | |
<script type="text/javascript" src="https://js.stripe.com/v1/"></script> | |
<!-- jQuery is used only for this example; it isn't required to use Stripe --> | |
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script> | |
<script type="text/javascript"> | |
// this identifies your website in the createToken call below |