Skip to content

Instantly share code, notes, and snippets.

# Format Guidelines for Commit and Issue Notes #
## Commit Message ##
Summary on the first line of **what** you did ([fixes|adds] #00)
Give a brief description of **why** you made your changes. Be sure to include the link to the issue on the summary line. The goal is to be able to read this message later and know what it was regarding and more importantly to justify your decisions to change the code.
## Issue Notes ##
@btoone
btoone / gist:2289225
Created April 3, 2012 04:07
Regex to match parts of a domain
Regex to match parts of a domain
http://stackoverflow.com/questions/4636497/regular-expression-match-domain-in-uri
^[^\/]+:\/\/[^\/]*?\.?([^\/.]+)\.[^\/.]+(?::\d+)?\/
http://www.rubular.com/r/Uv5ON7eAz4
^ # Match the beginning of the string
[^\/]+:\/\/ # Match the protocol (e.g. http://)
[^\/]*? # Non-greedy match of the sub-domains
\.? # Optional . (for when a sub-domain is used)
@btoone
btoone / gist:2289221
Created April 3, 2012 04:05
Dump a table
mysqldump -h host -u username -ppasswd database_name table_name > export_file_name.sql
:! <cmd> # executes a command
:! wc % # % means this file
:! sudo ./% # executes the script you're editing
:%s/^\n$//gc # remove whitespace from within vim
# translate case
tr '[:upper:]' '[:lower:]' < input.txt > output.txt
# Regular expression
&[^;]*; # find HTML entities &nbsp;
<[^>]*> # select HTML tags <div>
# Split Select Pages from Multiple PDFs into a New Document
pdftk A=one.pdf B=two.pdf cat A1-7 B1-5 A8 output combined.pdf
@btoone
btoone / new-file.sh
Created April 3, 2012 03:54
Creating files with text from the command line
# Use ctrl + d to exit write mode when using cat
cat > file.txt # overwrites
cat >> file.txt # appends
echo "Text to write in file" > file.txt
echo "Text to write in file" >> file.txt
echo -e "line one\nline two\n\tindented text" > file.txt
# Using a list with the mv command
mv README.{txt,textile}
mv config{,.old}
mv foo{,bar}
mv {,~}foo
mv {~,}foo
# Create an iso from a mac
hdiutil makehybrid -iso -o Microsoft-Office-2011.iso /Volumes/Microsoft\ Office\ 2011/