Skip to content

Instantly share code, notes, and snippets.

@drinks
drinks / keybase.md
Last active August 29, 2015 13:57
keybase.md

Keybase proof

I hereby claim:

  • I am drinks on github.
  • I am drinks (https://keybase.io/drinks) on keybase.
  • I have a public key whose fingerprint is 68C0 FD9E 9BC3 FD19 5EFA 74DC 78F4 888A 3AC6 14DD

To claim this, I am signing this object:

@drinks
drinks / gist:8293431
Created January 7, 2014 01:47
Choose your PKs wisely, kids.
class Migration(SchemaMigration):
def forwards(self, orm):
# OMFG Get ready, we're going to change the primary key!
# Doing bad things, disabling triggers
db.execute("ALTER TABLE brainstorm_idea DISABLE TRIGGER ALL;")
# Dropping foreign key constraint
db.delete_foreign_key('brainstorm_idea', 'subsite_id')
db.execute('DROP INDEX brainstorm_idea_subsite_id_like')
@drinks
drinks / markov-spam.txt
Last active December 30, 2015 04:39
Markov chain spam! It burns us.
ya i am totally agree that But here's the aim: the vast majority of the 41
bills in the CRS estimation were not actually polemic. It takes only one
senator to entity to point debate of a greenback and intensiveness the Senate
to stomach a end vote. So oftentimes a one senator give personnel a cloture
ballot on the event to locomote to a programme that is actually real fashionable
and nonpartizan. For instance, the most recent vote the Senate took on a
movement to cite cloture on a move to happen to debate was on an unemployment
benefits string note that finally ended up passing to play a order suffrage
on the happening to speak was the Snap Act, which ended up transient on an
overwhelming bipartizan franchise of 79-19. Before that it was the Omnibus
@drinks
drinks / gist:6953858
Last active December 25, 2015 09:29
sass build for sublime
{
"cmd": ["sass", "$file", "--stop-on-error", "--no-cache"],
"selector": "source.sass, source.scss",
"line_regex": "Line ([0-9]+):",
"osx":
{
"path": "/usr/local/bin:$PATH"
},
@drinks
drinks / CoffeeScript-scope.coffee
Created September 9, 2013 20:17
Note to future self: This is how scoping works in coffeescript.
class Foo
@_cattr =
"a": "apple"
"b": "banana"
"c": "cherry"
"d": "dragonfruit"
@classCattrGet: ->
@_cattr
@drinks
drinks / gist:6464743
Created September 6, 2013 14:38
Washington Post: Laziest. Paywall. Ever. Bookmarklet, obvi.
javascript:%24('#wp_Signin').remove()%3B%24('#exposeMask').remove()%3B%24(document).off("touchmove mousewheel mousemove scroll")%3B
@drinks
drinks / gist:6188712
Last active December 20, 2015 20:09
Paste this into your browser's console (view>developer>javascript console in chrome, tools>web developer>web console in firefox) each time you load the page to be walked through the steps of generating a YAML file in the contact-congress format. See comments in the script below for some caveats.
// ==ClosureCompiler==
// @output_file_name default.js
// @compilation_level SIMPLE_OPTIMIZATIONS
// ==/ClosureCompiler==
/*
**Notes**
In some cases, forms will still get submitted when you click the submit button.
@drinks
drinks / gist:5447540
Last active January 10, 2022 01:33
Regenerate permissions when they get out of sync with content types in a django project (will destroy all existing permissions) I swear there used to be a management command for this...
from django.db.models import get_apps, get_models
from django.contrib.auth.management import create_permissions
Permission.objects.all().delete()
[create_permissions(app, get_models(app), 2) for app in get_apps()]
@drinks
drinks / exportenv.py
Last active December 14, 2015 20:28
Django local_settings made friendly with Foreman's .env file
##
# appname/management/commands/exportenv.py
#
import re
import json
import sys
import StringIO
from importlib import import_module
from optparse import make_option
@drinks
drinks / deploy.rb
Created October 11, 2012 21:33
Cap recipe for wordpress using nginx, php-fpm and W3 Total Cache
default_run_options[:pty] = true
set :application, "<your-application-folder-name>"
set :domain, "<your-ip-addr>"
set :user, "<your-deploy-user>"
set :group, "<your-deploy-group>"
set :runner, "<your-deploy-user>"
set :use_sudo, true
set :scm, :git
set :deploy_via, :remote_cache
set :repository, "git@github.com:your-account/your-repo.git"