Author: | Baiju Muthukadan |
---|---|
Email: | baiju.m.mail AT gmail.com |
Version: | 0.5.0 |
This file contains hidden or 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 tsplit(string, delimiters): | |
"""Behaves str.split but supports multiple delimiters.""" | |
delimiters = tuple(delimiters) | |
stack = [string,] | |
for delimiter in delimiters: | |
for i, substring in enumerate(stack): | |
substack = substring.split(delimiter) | |
stack.pop(i) |
This file contains hidden or 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
RegExp.prototype.findAll = function(str) { | |
var match = null, results = []; | |
while ((match = this.exec(str)) !== null) { | |
switch (match.length) { | |
case 1: | |
results[results.length] = match[0]; | |
break; | |
case 2: | |
results[results.length] = match[1]; | |
break; |
This file contains hidden or 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
#Dump | |
mysqldump db | gzip -c > db.sql.gz | |
pg_dump db | gzip -c > db.sql.gz | |
#use gzip --fast | |
#Restore | |
gunzip < db.sql.gz | mysql db | |
bunzip2 < db.sql.bz2 | mysql db |
This file contains hidden or 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 server will start a bash shell and expose it | |
// over socket.io to a browser. See ./term.html for the | |
// client side. | |
// | |
// You should probably: | |
// | |
// npm install socket.io | |
// curl -O https://github.com/LearnBoost/Socket.IO/raw/master/socket.io.min.js | |
// |
This file contains hidden or 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
# vi: ft=dosini | |
[user] | |
name = Pavan Kumar Sunkara | |
email = [email protected] | |
username = pksunkara | |
[core] | |
editor = nvim | |
whitespace = fix,-indent-with-non-tab,trailing-space,cr-at-eol | |
pager = delta | |
[column] |
This file contains hidden or 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 unittest | |
class TestProblem(unittest.TestCase): | |
def test_sample(self): | |
self.assertEqual(1, 1) | |
if __name__ == '__main__': | |
unittest.main() |
This file contains hidden or 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 subprocess | |
import time | |
import sys | |
if __name__ == "__main__": | |
if len(sys.argv) != 2: | |
exit("need an argument") | |
to_run = sys.argv[1] | |
proc = subprocess.Popen(to_run) | |
print "start process with pid %s" % proc.pid |
This file contains hidden or 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 fizzbuzz(n): | |
if n % 3 == 0 and n % 5 == 0: | |
return 'FizzBuzz' | |
elif n % 3 == 0: | |
return 'Fizz' | |
elif n % 5 == 0: | |
return 'Buzz' | |
else: | |
return str(n) |