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
" Install https://github.com/jmcantrell/vim-virtualenv | |
" If the appropriate environment variables are set this will automatically use | |
" the virtualenv's python within vim thus enabling omnicomplete. | |
let g:virtualenv_auto_activate = 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
# Using lists | |
def allcombinations(starters, endings): | |
result = [] | |
for s in starters: | |
for e in endings: | |
result.append(s+e) | |
return result | |
# Using a generator | |
def allcombinations(starters, endings): |
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
createuser cmprss | |
createdb --username cmprss cmprss |
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
# Rails parses this correctly in the controller i.e. params['_json] exists. | |
curl -v -H "Content-Type: application/json" -X POST -d '[{"changed_aspect": "media","subscription_id": 1939373,"object": "user","object_id": "181943333","time": 133939219}]' http://www.monogram.dev/plugins/instagram/handle_user_subscription |
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
from django.shortcuts import render_to_response | |
from django.template import RequestContext | |
def some_view(request): | |
# Request remote page and parse it | |
foo = 'Some template variable' | |
template_name = 'path/to/template.html' | |
return render_to_response(template_name, { |
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
# db/migrate/20120625030355_add_deleted_at_to_user.rb | |
class AddDeletedAtToUser < ActiveRecord::Migration | |
def change | |
add_column :users, :deleted_at, :time | |
end | |
end |
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
class GenerateCardsJob < Struct.new(:params) | |
include HerokuWorker | |
def perform | |
card_number = params[:cards][:number_of_cards] | |
card_number.to_i.times do |i| | |
card = Card.create!({ | |
season_id: params[:season_id], | |
batch: params[:cards][:batch].parameterize, | |
purchasable: params[:cards][:purchasable], |
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
from fabric.api import local | |
from fabric.colors import red, green | |
from fabric.context_managers import settings | |
def dumpdata(): | |
""" | |
Calls dumpdata for all apps. | |
Remember to add new dumpdata commands for new apps here so that you always | |
get a full initial dump when running this task. |
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
$(document).ready(function() { | |
var tz = jstz.determine(); // Determines the time zone of the browser client | |
$('#id_timezone').val(tz.name()); // Sets it in the form | |
}); |
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
SELECT "posts_post"."id", | |
"posts_post"."created_by_id", | |
"posts_post"."modified_by_id", | |
"posts_post"."created_at", | |
"posts_post"."modified_at", | |
"posts_post"."blog_id", | |
"posts_post"."author_id", | |
"posts_post"."title", | |
"posts_post"."body", | |
"posts_post"."tags", |