Skip to content

Instantly share code, notes, and snippets.

View marshallds's full-sized avatar

Marshall Smith marshallds

View GitHub Profile
@marshallds
marshallds / Getter Setter
Created April 5, 2013 16:59
thanks to mrgenixus
(function(){ //don't work in the global scope
var double = function(a){ return a * 2; }
var process_validation = function(validation_params){
if (validation_params) return function(val){
// do magjiks
if (validation_params.filter) val = val.match(validation_params.filter)[0]
val = Math.round(val)
@marshallds
marshallds / gist:11062289
Created April 18, 2014 20:11
TastyPie nested resourceful routes mixin
from django.conf.urls import url
from tastypie.http import HttpGone, HttpMultipleChoices
from django.core.exceptions import ObjectDoesNotExist, MultipleObjectsReturned
from tastypie.resources import ModelResource
from recipes.models import Recipe, Ingredient
class NestedResourceMixin(object):
def prepend_urls(self):
resources = super(NestedResourceMixin, self).prepend_urls()
class Component extends React.Component {
onScroll(event) {
this.scrollPosition = getScrollPosition(event);
if (this.scrolling) return;
this.scrolling = true;
const processLongOperation = (beginPosition) => {
longOperation(beginPosition, (completionState) => {
this.setState(completionState, () => {
//rendered