This place is a dump for learning online/offline resources. Aim is to create a curated list of resources.
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
from django import template | |
from django.core.urlresolvers import reverse | |
register = template.Library() | |
@register.simple_tag | |
def add_active(request, name, by_path=False): | |
""" Return the string 'active' current request.path is same as name | |
Keyword aruguments: |
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
$ mkvirtualenv test | |
New python executable in ./bin/python | |
Installing distribute....................................................................................................................................done. | |
Complete output from command /home/mir/test/bin/python /home/mir/test/bin/easy_install /usr/share/python-virtualenv/p...ar.gz: | |
/home/mir/test/bin/python: can't open file '/home/mir/test/bin/easy_install': [Errno 2] No such file or directory | |
---------------------------------------- | |
Traceback (most recent call last): | |
File "/usr/bin/virtualenv", line 3, in | |
virtualenv.main() | |
File "/usr/lib/pymodules/python2.6/virtualenv.py", line 534, in main |
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
from django import forms | |
list_of_choices = ( | |
(1, 'Choice 1'), | |
(2, 'Choice 2'), | |
(3, 'Choice 3'), | |
# ... | |
(n, 'Choice n'), | |
) | |
class MyForm(forms.Form): | |
my_choice_field = forms.ChoiceField(choices=list_of_choices) |
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 get_ordinal($num) { | |
$temp_num = ($num > 31) ? ($num % 31) + 1 : $num; | |
return $num . date('S', mktime(0, 0, 0, $temp_num, 0, 0)); | |
} |
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
var _ = require('underscore'), | |
exec = require('child_process').exec, | |
net = require('net'), | |
email = process.argv.splice(2)[0], | |
domain = email.split('@')[1]; | |
function verify(mxrecord) { | |
console.log('connecting to', mxrecord); | |
var conn = net.createConnection(25, mxrecord), | |
commands = [ |
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 () { | |
var Modular = function () { | |
this.VERSION = '0.0.1', | |
this.modules = {}, | |
this.activeModules = [], | |
this.currentPath = undefined, | |
this.registeredPaths = undefined, | |
this.host = undefined, | |
this.protocol = undefined; | |
}; |
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
import { Schema, arrayOf, normalize } from 'normalizr'; | |
import { camelizeKeys } from 'humps'; | |
import axios from 'axios'; | |
const API_ROOT = 'http://localhost:5555/api/v1/'; | |
// Fetches an API response. | |
// This makes every API response have the same shape, regardless of how nested it was. | |
function callApi(endpoint, method = 'get', data = {}, schema = null) { | |
const fullUrl = (endpoint.indexOf(API_ROOT) === -1) ? API_ROOT + endpoint : endpoint; |
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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
I hereby claim:
- I am mnazim on github.
- I am mnazim (https://keybase.io/mnazim) on keybase.
- I have a public key whose fingerprint is 8B03 3276 1EC5 CC3F D331 E169 A5F8 963F ABD5 0D0A
To claim this, I am signing this object:
OlderNewer