Skip to content

Instantly share code, notes, and snippets.

View cmertayak's full-sized avatar

CM cmertayak

View GitHub Profile
@cmertayak
cmertayak / js_closure_example.js
Last active August 1, 2016 17:16
Caching Example with JS Closure
var cacheCreator = function() {
var memory_content = {};
return function(key, value) {
var operator = (value === undefined) ? 'get' : 'set';
if(operator == 'set') {
memory_content[key] = value;
}
return memory_content[key];
};
@cmertayak
cmertayak / locate-django.sh
Created February 24, 2014 21:26
Where Django is Located
python -c "
import sys
sys.path = sys.path[1:]
import django
print(django.__path__)"
@cmertayak
cmertayak / decorator.py
Created February 23, 2014 21:40
Python Decorator Example
def makebold(fn):
def wrapped():
return "<b>%s</b>" % fn()
return wrapped
def makeitalic(fn):
def cover():
return "<i>%s</i>" %fn()
return cover
@cmertayak
cmertayak / timer
Created July 23, 2013 21:14
Javascript update based on a timer
// schedule update in one second
function updateLater() {
// save the timeoutId for canceling
timeoutId = $timeout(function() {
updateTime(); // update DOM
updateLater(); // schedule another update
}, 1000);
}
// from: http://danpolant.com/want-to-run-xdebug-mamp-is-the-easiest-way/
// in /Applications/MAMP/conf/php5.x/php.ini
[xdebug]
zend_extension="/Applications/MAMP/bin/php5.2/lib/php/extensions/no-debug-non-zts-20060613/xdebug.so"
xdebug.remote_enable=1
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.remote_handler=dbgp
@cmertayak
cmertayak / gist:3517139
Created August 29, 2012 18:57
Comparison of Wrapping
class CourseController extends BaseController {
protected $_courseLinks;
public function __construct($params = NULL) {
parent::__construct($params);
$this->_courseLinks = new CourseLinks($this);
}
public function trial() {
...
@cmertayak
cmertayak / php-conditional.php
Created August 21, 2012 01:04
PHP Some Conditional Operators
if(NULL == "") {
DU::show('NULL == "" is true');
} else {
DU::show('NULL == "" is false');
}
if(NULL == array()) {
DU::show('NULL == array() is true');
} else {
DU::show('NULL == array() is false');