Infernal Affairs - Hong Kong
Les émotifs anonymes - France
This file contains 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
/** | |
* Returns a value or array of values by traversing the `object` using `path` | |
* | |
* @param object {Object} | |
* @param path {String} | |
* @returns value {String, Array} | |
* | |
* traverseObject({a: {b: [{c: {d: 'gotcha!'}}, {c: {d: 'yes!'}}]}}, 'a__b____c__d'); | |
* --> ['gotcha!', 'yes!'] | |
* traverseObject({a: {b: [{c: 'gotcha!'}, {c: 'yes!'}]}}, 'a__b____c'); |
View this code at http://livecoding.io/3981538
This file contains 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
// Self-calling named function which takes an array of elements | |
// calls an event on the first element in that array and passes | |
// the rest of the array to that function recursively until the | |
// array is empty. The recursive call is done in the callback of | |
// the previous element's event so that it nicely waits for the | |
// previous element to be done. | |
(function hidenext(jq) { | |
jq.eq(0).fadeOut("fast", function(){ |
This file contains 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
#!/usr/bin/env python | |
from distutils.core import setup | |
setup(name='Zachs script', | |
version='1.0', | |
description='Zach is the man', | |
author='Zach', | |
author_email='[email protected]', | |
packages=['mypackage'], |
This file contains 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
function Engineer () {} | |
Engineer.prototype = { | |
getYearsWorked: function () { | |
return this.yearsWorked; | |
} | |
}; | |
function UIEngineer (years) { | |
this.yearsWorked = years; |
This file contains 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
""" | |
This file enables email-based authentication for Django. The only steps required are | |
1. Add 'EmailAuthenticationBackend' to your settings' AUTHENTICATION_BACKENDS file | |
2. Add the {'authentication_form': EmailAuthenticationForm} to your login view (if using 'django.contrib.auth.views.login') | |
3. When saving a User instance, generate the username from the email using the 'generate_hash_from_email' function | |
""" | |
import hashlib | |
from django import forms |
This file contains 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
define([ | |
'jquery', | |
'underscore', | |
'backbone', | |
'mustache' | |
], function($, _, Backbone, Mustache){ | |
var view = Backbone.View.extend({ | |
model: null, | |
template: null, |
This file contains 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 iterative(n): | |
if n == 0 or n == 1: | |
return n | |
prev2 = 0 | |
prev1 = 1 | |
for index in xrange(2, n + 1): | |
ivalue = prev1 + prev2 | |
prev2 = prev1 | |
prev1 = ivalue | |
if index == n: |