Skip to content

Instantly share code, notes, and snippets.

View richard-to's full-sized avatar

Richard To richard-to

View GitHub Profile
@richard-to
richard-to / gist:4433179
Created January 2, 2013 09:03
Capture print statements to help debug mongodb map reduce jobs. This was from a StackOverflow answer I found somewhere.
tail -f mongodb.log | grep "^SOME_KEY:"
@richard-to
richard-to / gist:4554158
Created January 17, 2013 06:34
My default sass command line options.
sass -E UTF-8 --style compressed --watch scss:css
@richard-to
richard-to / gist:4554162
Last active December 11, 2015 05:48
Recursively set file or directory permissions. Make sure to leave spaces between brackets.
find . -type d -exec chmod 755 {} \+
find . -type f -exec chmod 644 {} \+
@richard-to
richard-to / gist:4554190
Created January 17, 2013 06:43
Replace matches in multiple files. I need to replace snippet with an Xargs version.
for file in $(find . -type f -name '*.php'); do sed s/OLD/NEW/g $file > ../temp/test.php; mv ../temp/test.php $file; done;
@richard-to
richard-to / gist:4554226
Last active December 11, 2015 05:48
Create a development SSL certificate. Need to verify if this is the best way to do it or not, but for now just transferring my old Snipplr account.
#Create server key
openssl genrsa -des3 -out server.key 4096
#Remove password
openssl rsa -in server.key -out server.pem
#Create certificate
openssl req -new -key server.key -out server.csr
#Sign certificate
@richard-to
richard-to / gist:4554231
Created January 17, 2013 06:57
Tar and untar files. More commands that I can never remember...
tar -czf zipped_files.tar.gz file1 file2 file3
tar -zxvf zipped_files.tar.gz
sudo mount -t nfs -o resvport,soft,intr,rsize=8192,wsize=8192,timeo=900,retrans=3,proto=tcp hostname:/shared_dir /local_dir
@richard-to
richard-to / gist:5843052
Created June 22, 2013 23:16
Hadoop 1.1 installation instructions for Ubuntu 12 using Debian package
# Need this installed to use `add-apt-repository`
sudo apt-get install python-software-properties
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java7-installer
sudo update-java-alternatives -s java-7-oracle
# Download and install Hadoop 1.1 from one of the mirrors.
wget http://apache.mirrors.tds.net/hadoop/common/hadoop-1.1.2/hadoop_1.1.2-1_x86_64.deb
@richard-to
richard-to / gist:5843066
Created June 22, 2013 23:21
Random java command line compile and jar instructions
javac -classpath /full/path/to/file.jar -d class/output/dir src/*.java
jar -cvf outdir/program.jar -C class/output/dir/ .
@richard-to
richard-to / import_bookmarks_to_evernote.py
Created August 21, 2013 10:12
Quick and dirty script to import bookmarks into Evernote. Expected bookmarks file is in Delicious format. In my case, I needed to export Diigo bookmarks into Evernote.
from xml.sax.saxutils import escape
from datetime import datetime
from bs4 import BeautifulSoup
headerXml = """<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE en-export SYSTEM "http://xml.evernote.com/pub/evernote-export3.dtd">
<en-export application="Evernote" version="Evernote Mac">"""
footerXml = "</en-export>"