Skip to content

Instantly share code, notes, and snippets.

View christabor's full-sized avatar
😅
I may be slow to respond.

Chris Tabor christabor

😅
I may be slow to respond.
View GitHub Profile
// Python style
function Class() {
var self = this;
this.__init__ = function(x, y){
self.x = x;
self.y = y;
};
this.__str__ = function(){
log('<' + self.x + self.y + '>');
@christabor
christabor / gist:c94c527e1c7f7c41322a
Created May 9, 2014 17:50
Clean django field with specified file type
def clean_data(self):
filetype = self.cleaned_data['data'].content_type
if not filetype == 'application/pdf':
raise forms.ValidationError(
'"{}" is not a valid file. Please upload a valid .PDF.')
else:
return self.cleaned_data['data']
@christabor
christabor / chainable
Created July 1, 2014 20:26
Fake chaining practice - js
var d3 = function(){
var self = this;
this.foo = function() {
return this;
};
this.range = function(max) {
var x = [];
for(var i = 0 ; i < max; i++) {
x.push(i);
}
@christabor
christabor / gist:8d1313a29ee5323b7146
Created July 2, 2014 22:53
Boostrap bg status padding
/* Bootstrap overrides */
.bg-primary,
.bg-success,
.bg-info,
.bg-warning,
.bg-danger {
padding: 1em;
}
@christabor
christabor / gist:720c16ef57f2becfe5af
Created July 2, 2014 23:20
Apply widgets to many fields in django form easily and DRYly
class ...
class Meta:
_textarea = forms.Textarea(attrs={'cols': 40, 'rows': 5})
model = models.MyModel
widgets = {
'field1': _textarea,
'field2': _textarea,
'field3': _textarea,
'field4': _textarea,
}
@christabor
christabor / logolounge-trends-scraper
Created July 7, 2014 08:05
Pyquery scraper for logolounge.com Logo Trends data.
@christabor
christabor / hack-refactor
Created July 15, 2014 20:29
css refactor hack
// use @hack to specify all selectors that should be removed at a later point in time!
// @hack
#shitty-overqualified-id {
font-size: 12.em;
}
// @hack
#another-overqualified-id {
padding: 1.3m;
}
@christabor
christabor / django model fields
Last active August 29, 2015 14:04
Get all django model fields in one go...
from django.db import models
DJANGO_FIELDS = (
(str(field).upper(), field)
for field in dir(models) if field.endswith('Field')
)
@christabor
christabor / python stdlib -> js functions
Created August 8, 2014 07:11
python stdlib functions in js - incomplete
window.pyfuncs = pyfuncs || {};
pyfuncs.string.ascii_lowercase = function() {
return 'abcdefghijklmnopqrstuvwxyz';
};
pyfuncs.string.ascii_uppercase = function() {
return pyfuncs.string.ascii_lowercase().toUpperCase();
};
@christabor
christabor / gist:44fc545fb48e7f821118
Created August 16, 2014 09:34
sublime regex for svg path data
"([a-zA-Z][0-9],|.)+"