This file contains hidden or 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
| var getAll = function(url, page, acquired, deferred) { | |
| var self = this; | |
| page = page || 1; | |
| deferred = deferred || $q.defer(); | |
| var page_url = [url, '&page=', page].join(""); | |
| $http.get(page_url).then(function(results) { | |
| acquired = acquired ? acquired.concat(results.data) : results.data; | |
| if (results.data.length === 100) { // Assuming the max is 100 per page... | |
| return self.getAll(url, ++page, acquired, deferred); | |
| } else { |
This file contains hidden or 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
| .directive( [ 'focus', 'blur', 'keyup', 'keydown', 'keypress' ].reduce( function ( container, name ) { | |
| var directiveName = 'ng' + name[ 0 ].toUpperCase( ) + name.substr( 1 ); | |
| container[ directiveName ] = [ '$parse', function ( $parse ) { | |
| return function ( scope, element, attr ) { | |
| var fn = $parse( attr[ directiveName ] ); | |
| element.bind( name, function ( event ) { | |
| scope.$apply( function ( ) { | |
| fn( scope, { | |
| $event : event |
This file contains hidden or 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
| #! /bin/sh | |
| from_hash=$1 | |
| to_hash=$2 | |
| checkout_type=$3 | |
| ignored=("develop" "staging" "production") | |
| develop_hash=$(git rev-parse develop) | |
| branch_name=$(git rev-parse --abbrev-ref HEAD) | |
| containsElement () { |
This file contains hidden or 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.contrib import admin | |
| from tastypie.models import ApiKey, ApiAccess | |
| admin.site.unregister(ApiKey) | |
| admin.site.unregister(ApiAccess) |
This file contains hidden or 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 compressor.filters import CompilerFilter | |
| class UglifyFilter(CompilerFilter): | |
| command = "uglifyjs {infile} -o {outfile} -c -m" |
This file contains hidden or 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
| def xor(string, key): | |
| data = '' | |
| for char in string: | |
| for ch in key: | |
| char = chr(ord(char) ^ ord(ch)) | |
| data += char | |
| return data |
This file contains hidden or 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
| brew upgrade | |
| brew update | |
| brew install cairo | |
| brew install py2cairo | |
| ln -s ~/Developer/lib/python2.7/site-packages/cairo ~/.virtualenvs/wpd/lib/python2.7/site-packages/cairo | |
| # I needed to specify that my virtual environment uses python 2.7.3 because by default it used 2.7.2 | |
| # but brew compiled py2cairo with 2.7.3 | |
| mkvirtualenv --no-site-packages -p ~/Developer/bin/python wpd |
This file contains hidden or 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
| def return_it(): | |
| return ('first', 'second',) | |
| one, two = return_it() | |
| print one | |
| # first | |
| print two | |
| # second |
This file contains hidden or 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
| my_list = [('one','two',),('three','four',)] | |
| return [first + second for first, second in my_list] | |
| # ['onetwo', 'threefour'] |
This file contains hidden or 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
| // Assume that we are not using a redis session store | |
| // instead storing relevant information in redis. | |
| // client side | |
| // assume Cookie.get(name) returns the cookie | |
| // this can use jQuery's cookie plugin or | |
| // some regular expression on document.cookie | |
| var socket = new io.Socket(); |