Skip to content

Instantly share code, notes, and snippets.

Avatar
😅
I may be slow to respond.

Chris Tabor christabor

😅
I may be slow to respond.
View GitHub Profile
@christabor
christabor / my_context_processors.py
Created January 11, 2013 05:55
A cleaner way to manage production vs local static assets for django.
View my_context_processors.py
from django.conf import settings
def static_file(request):
"""
This static context processor makes the {{ STATIC_FILE }}
template tag available to any view you create, without explicitly having to add it.
Useful if you want to manage local vs. deployment assets without using the staticfiles
module provided by django ( and its default {{ STATIC_URL }} template tag ) -- which is
a haphazard way of managing things in a single application environment.
@christabor
christabor / gist:4601197
Created January 23, 2013 02:04
jQuery contextLoader - a DOM - contextual loader for your web app!
View gist:4601197
/*
======================
USAGE
======================
createLoadPane is a simple function that handles creation and positioning,
as well as text options for adding "contextual loaders" into the dom --
a loader that covers a certain area where content may be loading via ajax.
This works with the box-model and takes the basic discrepencies into account.
@christabor
christabor / dabblet.css
Created May 9, 2013 23:41
The first commented line is your dabblet’s title
View dabblet.css
/**
* The first commented line is your dabblet’s title
*/
background: #f06;
background: linear-gradient(45deg, #f06, yellow);
min-height: 100%;
@christabor
christabor / gist:5786034
Created June 14, 2013 23:21
Grab a list of all TLDs (or whatever newline separated item you want) from a text file with Python
View gist:5786034
#http://www.icann.org/en/resources/registries/tlds
text = open('tlds.txt')
arr = []
arr = [x.strip() for x in text]
print arr
# example usage: python split.py >> file.txt
@christabor
christabor / gist:5786042
Created June 14, 2013 23:22
All valid TLDs as an array, for javascript, or whatever else.
View gist:5786042
var tlds = ['AC', 'AD', 'AE', 'AERO', 'AF', 'AG', 'AI', 'AL', 'AM', 'AN', 'AO', 'AQ', 'AR', 'ARPA', 'AS', 'ASIA', 'AT', 'AU', 'AW', 'AX', 'AZ', 'BA', 'BB', 'BD', 'BE', 'BF', 'BG', 'BH', 'BI', 'BIZ', 'BJ', 'BM', 'BN', 'BO', 'BR', 'BS', 'BT', 'BV', 'BW', 'BY', 'BZ', 'CA', 'CAT', 'CC', 'CD', 'CF', 'CG', 'CH', 'CI', 'CK', 'CL', 'CM', 'CN', 'CO', 'COM', 'COOP', 'CR', 'CU', 'CV', 'CW', 'CX', 'CY', 'CZ', 'DE', 'DJ', 'DK', 'DM', 'DO', 'DZ', 'EC', 'EDU', 'EE', 'EG', 'ER', 'ES', 'ET', 'EU', 'FI', 'FJ', 'FK', 'FM', 'FO', 'FR', 'GA', 'GB', 'GD', 'GE', 'GF', 'GG', 'GH', 'GI', 'GL', 'GM', 'GN', 'GOV', 'GP', 'GQ', 'GR', 'GS', 'GT', 'GU', 'GW', 'GY', 'HK', 'HM', 'HN', 'HR', 'HT', 'HU', 'ID', 'IE', 'IL', 'IM', 'IN', 'INFO', 'INT', 'IO', 'IQ', 'IR', 'IS', 'IT', 'JE', 'JM', 'JO', 'JOBS', 'JP', 'KE', 'KG', 'KH', 'KI', 'KM', 'KN', 'KP', 'KR', 'KW', 'KY', 'KZ', 'LA', 'LB', 'LC', 'LI', 'LK', 'LR', 'LS', 'LT', 'LU', 'LV', 'LY', 'MA', 'MC', 'MD', 'ME', 'MG', 'MH', 'MIL', 'MK', 'ML', 'MM', 'MN', 'MO', 'MOBI', 'MP', 'MQ', 'MR', 'MS', '
@christabor
christabor / gist:5787168
Created June 15, 2013 06:35
Add an extra member to an Array, of your name choice. Utterly useless!
View gist:5787168
Array.prototype.foo = function(foo) { return this.push(foo); }
@christabor
christabor / input-number-visual-centering
Last active December 20, 2015 07:19
visually centering text on input:number
View input-number-visual-centering
// the input type = number looks uncentered, even with the standard text-align:center -- because of the width of the buttons on the right. This will not be technically centered, but appear visually so.
// percentages account for variable size
input[type="number"] {
text-align:center;
text-indent: 10%;
}
@christabor
christabor / gist:6141749
Created August 2, 2013 17:35
Create a bunch of jquery sliders by mapping over an object of enumerable properties
View gist:6141749
// you can put your functions outside (my preference) or inside the object itself.
function foo() {
console.log('foo!');
}
function bar() {
console.log('bar!');
}
@christabor
christabor / try-catch-js-design-pattern
Created September 24, 2013 18:06
JS Pattern: Try/catch a bunch of modules at once
View try-catch-js-design-pattern
// a global module and namespace, preferably separated by individual files for each sub-module
var myGlobalObject = {
category: {
function1: function() {alert('function 1!');},
function2: function() {alert('function 2!');},
function3: function() {alert('function 3!');},
function4: function() {alert('function 4!');}
}
};
@christabor
christabor / rebase-gh-pages
Created October 18, 2013 16:32
quickly rebase gh-pages (bash)
View rebase-gh-pages
alias rebpages="git checkout gh-pages && git rebase master && git push origin gh-pages && git checkout master"