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 Module = (function() { | |
var privateMember = "secret"; | |
return { | |
publicMember: function() { | |
return privateMember; | |
} | |
}; | |
})(); |
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 warnings | |
warnings.filterwarnings( | |
'error', r"DateTimeField received a naive datetime", | |
RuntimeWarning, r'django\.db\.models\.fields') |
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
;; setting for auto-close brackets for electric-pair-mode regardless of current | |
;; major mode syntax table | |
(setq electric-pair-pairs '( | |
(?\" . ?\") | |
(?\{ . ?\}) | |
) ) | |
;; auto-close any kind of brackets | |
(add-hook 'after-change-major-mode-hook 'electric-pair-mode) |
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
# credits to http://glowingpython.blogspot.jp/2013/03/bubble-sort-visualized.html | |
import pylab | |
from random import shuffle | |
def bubblesort_anim(a): | |
x = range(len(a)) | |
imgidx = 0 | |
# bubble sort algorithm |
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
pb-kill-line () { | |
zle kill-line | |
echo -n $CUTBUFFER | pbcopy | |
} | |
pb-kill-whole-line () { | |
zle kill-whole-line | |
echo -n $CUTBUFFER | pbcopy | |
} |
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
User = Backbone.Model.extend({ | |
url: function() { | |
var origUrl = Backbone.Model.prototype.url.call(this); | |
return origUrl += origUrl.endsWith('/') ? '' : '/'; | |
} | |
}); |
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 logging | |
from StringIO import StringIO | |
import zlib | |
class UnzipRequestMiddleware(object): | |
"""A middleware that unzips POSTed data. | |
For this middleware to kick in, the client must provide a value | |
for the ``Content-Encoding`` header. The only accepted value is |
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
""" | |
Two things are wrong with Django's default `SECRET_KEY` system: | |
1. It is not random but pseudo-random | |
2. It saves and displays the SECRET_KEY in `settings.py` | |
This snippet | |
1. uses `SystemRandom()` instead to generate a random key | |
2. saves a local `secret.txt` |
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
$rootScope.$on "$stateChangeStart", (event, toState, toParams, fromState, fromParams) -> | |
console.log "$stateChangeStart to " + toState.to + "- fired when the transition begins. toState,toParams : \n", toState, toParams | |
$rootScope.$on "$stateChangeError", (event, toState, toParams, fromState, fromParams) -> | |
console.log "$stateChangeError - fired when an error occurs during transition." | |
console.log arguments_ | |
$rootScope.$on "$stateChangeSuccess", (event, toState, toParams, fromState, fromParams) -> | |
console.log "$stateChangeSuccess to " + toState.name + "- fired once the state transition is complete." |
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
class _Missing(object): | |
def __repr__(self): | |
return 'no value' | |
def __reduce__(self): | |
return '_missing' | |
_missing = _Missing() |