Skip to content

Instantly share code, notes, and snippets.

View drewtempelmeyer's full-sized avatar
👋

Drew Tempelmeyer drewtempelmeyer

👋
View GitHub Profile
@drewtempelmeyer
drewtempelmeyer / wedding.py
Created October 19, 2010 01:57
Barebones wedding site in web.py
import web
from web import form
urls = (
'/', 'index',
'/contact', 'contact',
)
app = web.application(urls, globals())
SELECT AddGeometryColumn('users_userprofile', 'point', 4326, 'POINT', 2);
CREATE INDEX "users_userprofile_point_id" ON "users_userprofile" USING GIST ( "point" GIST_GEOMETRY_OPS );
@drewtempelmeyer
drewtempelmeyer / Preferences.sublime-settings
Created October 17, 2012 20:15
Sublime Text 2 Configuration
{
// General Editing Configuration
"trim_trailing_white_space": true,
"trim_trailing_white_space_on_save": true,
"ensure_newline_at_eof": true,
"ensure_newline_at_eof_on_save": true,
"scroll_past_end": true,
"tab_size": 2,
"translate_tabs_to_spaces": true,
result = @transaction.lookup[:lookup_response][:lookup_result]
cart_item_response = result[:cart_items_response][:cart_item_response]
total_tax = cart_item_response.map { |item| item[:tax_amount].to_f }.inject(:+)
User.limit(1).first # User Load (0.5ms) SELECT `users`.* FROM `users` WHERE `users`.`deleted_at` IS NULL LIMIT 1
User.first # User Load (0.6ms) SELECT `users`.* FROM `users` WHERE `users`.`deleted_at` IS NULL LIMIT 1
User.first.class.to_s # => User
User.limit(1).all.class.to_s # => Array
@drewtempelmeyer
drewtempelmeyer / mixins.py
Created January 30, 2013 01:27
Django SSL Mixin
from django.conf import settings
from django.http import HttpResponseRedirect
class SSLRequiredMixin(object):
def dispatch(self, request, *args, **kwargs):
if settings.DEBUG is False and request.is_secure() is False:
host = request.get_host()
url = 'https://%s%s' % (host, request.get_full_path())
return HttpResponseRedirect(url)
return super(SSLRequiredMixin, self).dispatch(request, *args,**kwargs)
@drewtempelmeyer
drewtempelmeyer / settings.py
Created January 31, 2013 15:20
django-cumulus + easy-thumbnails
DEFAULT_FILE_STORAGE = 'cumulus.storage.CloudFilesStorage'
THUMBNAIL_DEFAULT_STORAGE = DEFAULT_FILE_STORAGE
@drewtempelmeyer
drewtempelmeyer / balanced-validators.js
Created January 11, 2014 20:57
jQuery Validation methods for Balanced.js
/**
* Balanced.js Validators
*
* jQuery Validation methods for use with Balanced.js
*/
;(function($) {
"use strict";
/**

Keybase proof

I hereby claim:

  • I am drewtempelmeyer on github.
  • I am tempelmeyer (https://keybase.io/tempelmeyer) on keybase.
  • I have a public key whose fingerprint is 9176 E981 1EF3 D6EB 4A79 9C89 3CCE 543A E3CC B9BC

To claim this, I am signing this object:

@drewtempelmeyer
drewtempelmeyer / devmux.sh
Created January 24, 2017 14:30
Automatically set up development environment for Rails/Ember applications
#!/bin/bash
# Set up variables
run_server=true
show_help=false
# Set up the server command
if [ -f 'ember-cli-build.js' ]; then
SERVER_CMD='ember server --proxy http://localhost:3000'
elif [ -f 'bin/rails' ]; then