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 fib(x) { | |
if (x < 2) | |
return 1; | |
return fib(x-1) + fib(x-2); | |
} |
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 () { | |
function iterator(collection) { | |
var index = 0; | |
var length = collection.length; | |
function next() { | |
var item = collection[index++]; | |
return item; | |
} |
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 MainView = Backbone.View.extend({ | |
el: 'body', | |
events: { | |
'click #open': 'openModal' | |
}, | |
template: '<a id="open" class="btn">open modal</a>', | |
openModal: function() { | |
var view = new ModalView(); | |
var modal = new Backbone.BootstrapModal({ | |
content: view, |
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 ModalView = Backbone.View.extend({ | |
tagName: 'p', | |
template: 'this is modal content', | |
render: function() { | |
this.$el.html(this.template); | |
return this; | |
} | |
}); | |
$(document).ready(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
""" | |
Console module provide `copen` method for opening interactive python shell in | |
the runtime. | |
""" | |
import code | |
import readline | |
import rlcompleter | |
def copen(_globals, _locals): |
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/php -q | |
<?php | |
set_time_limit(0); | |
ob_implicit_flush(); | |
if ($argc != 2) | |
die("Simple Time Server (C) 2013 Tomasz Ducin\n" . | |
"Invalid parameters passed\n" . | |
"Run:\n\t./time-server.php <port>\n" . |
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/python | |
import sys, errno | |
if len(sys.argv) != 2: | |
print 'Required parameter not passed. Run:\n\n\t./chat-bomb.py <port>\n' | |
sys.exit(errno.EINVAL) | |
port = int(sys.argv[1]) |
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 Class = function(base){ | |
if (typeof base.construct !== "function") | |
throw new TypeError("class definition has to define 'construct' function"); | |
return function() { | |
// copy all methods | |
for (var prop in base) { | |
if (base.hasOwnProperty(prop) && base[prop] !== base.construct) { | |
this[prop] = base[prop]; | |
} | |
} |
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(root){ | |
root.getScript = function(url) { | |
var script = document.createElement('script'); | |
script.type = 'text/javascript'; | |
script.src = url; | |
document.head.appendChild(script); | |
} | |
}(window)); | |
getScript('http://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.js'); |
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 os | |
parent_pid = os.getpid() | |
print "[parent] starts PID: %d" % (parent_pid, ) | |
forked_pid = os.fork() | |
if forked_pid == 0: | |
print "[child] child process can't use os.fork() PID, since it's %d" % (forked_pid, ) | |
print "[child] but it can reevaluate os.getpid() to get it's own PID: %d" % (os.getpid(), ) | |
else: |