Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/python
#
# by Nathan Grigg http://nb.nathanamy.org
#
import sys
import argparse
import os.path
from subprocess import Popen,PIPE
@jachin
jachin / .gitignore
Last active February 25, 2016 21:22
Beverage-o-meter Server
*.pyc
*.db
@jachin
jachin / .gitignore
Last active December 10, 2015 13:28
bom.db
@jachin
jachin / gist:4271020
Created December 12, 2012 19:57 — forked from defiant/MacOsX Context Cleaner
This removed duplicated entries in the "Open with..." contextual menu in OS X.
/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user
@jachin
jachin / upgrade_pip_packages.sh
Created October 29, 2012 20:46
Upgrade all installed pip packages
pip freeze --local | grep -v '^\-e' | cut -d = -f 1 | xargs pip install -U
@jachin
jachin / Diff and Patch.rst
Last active December 14, 2022 05:52
diff and patch

First generate a patch for others to apply. For this we use diff where the first argument shall be the original file or directory where did you started making the modifications and the second should be a version of the file or directory with the modifications already made.:

diff -Naur old_file new_file > your_patch_filename.patch

or (if applied against directories):

diff -Naur old_dir new_dir > your_patch_filename.patch

The options on these diff commands are the following

@jachin
jachin / gist:2347981
Created April 10, 2012 02:30
subversion commands

List all the conflicts:

svn st | grep '^C'

To mark a file as executable:

svn propset svn:executable '' [filename]

Delete all unversioned files:

@jachin
jachin / default_arguments.js
Created February 22, 2012 21:53
Default values for function arguments in javascript.
function foo ( red, blue ) {
// default value for red is true.
red = typeof red !== 'undefined' ? red : true;
// default value for blue is 55.
blue = typeof blue !== 'undefined' ? blue : 55;
console.log( red );
console.log( blue );
}
@jachin
jachin / htpasswd_reference
Last active September 29, 2015 22:38
htpasswd reference
# This is a command line too for apache's basic authentication management.
# CAUTION: make sure /some/path/to/a/file/named/htpasswd is outside of any directory inside the web root.
# To initially create the password
htpasswd -c /some/path/to/a/file/named/htpasswd initialUsername
# To add another user to the same file
htpasswd /some/path/to/a/file/named/htpasswd newUsername