Skip to content

Instantly share code, notes, and snippets.

View juancarlospaco's full-sized avatar
👑
https://t.me/NimArgentina

Juan Carlos juancarlospaco

👑
https://t.me/NimArgentina
View GitHub Profile
@kennethreitz
kennethreitz / tsplit.py
Created March 20, 2011 20:36
Split Strings w/ Multiple Separators (Python)
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)
@insin
insin / RegExp-findall.js
Created April 8, 2011 11:12
findAll method for RegExps with results in the vein of Python's re.findall
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;
@kennethreitz
kennethreitz / dump_and_restore_DBs.sh
Created April 23, 2011 21:23 — forked from unbracketed/dump_and_restore_DBs.sh
Recipes for dumping and restoring different databases, using different compression formats
#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
@mixonic
mixonic / server.js
Created April 28, 2011 22:49
Node.js + Socket.io + Bash. A collaborative terminal for your browser.
//
// 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
//
@pksunkara
pksunkara / config
Last active August 4, 2025 14:48
Sample of git config file (Example .gitconfig) (Place them in $XDG_CONFIG_HOME/git)
# 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]
@icomkid
icomkid / gist:1028806
Created June 16, 2011 06:56
Python UnitTest Template
import unittest
class TestProblem(unittest.TestCase):
def test_sample(self):
self.assertEqual(1, 1)
if __name__ == '__main__':
unittest.main()
@virtix
virtix / selenium_with_python.rst
Created August 5, 2011 04:27 — forked from baijum/selenium_with_python.rst
Selenium with Python

Selenium with Python

Author: Baiju Muthukadan
Email:baiju.m.mail AT gmail.com
Version: 0.5.0
@japboy
japboy / README.markdown
Created August 27, 2011 06:49
CSS Property Sorter Script

CSS Property Sorter Script

Setup for Vim

  1. Create ~/.vim/ftplugin/css.vim if it's not existed yet.
  2. Open ~/.vim/ftplugin/css.vim and add new lines below:
" CSS Property Sorter Script (:SortCSS to run)
command! -range=% SortCSS :,!python /path/to/css_prop_sorter.py
@International
International / subproccess_example.py
Created September 9, 2011 12:06
python subprocess pid/kill example
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
@jaysonrowe
jaysonrowe / FizzBuzz.py
Created January 11, 2012 03:05
FizzBuzz Python Solution
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)