Skip to content

Instantly share code, notes, and snippets.

@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
# 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
# Regular expression
&[^;]*; # find HTML entities  
<[^>]*> # select HTML tags <div>
# translate case
tr '[:upper:]' '[:lower:]' < input.txt > output.txt
:! <cmd> # executes a command
:! wc % # % means this file
:! sudo ./% # executes the script you're editing
:%s/^\n$//gc # remove whitespace from within vim
@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
@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)
# 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:2289249
Created April 3, 2012 04:09
Regex to parse apache error log
# Textmate regex that removes the end of apache error log
, referer:.+$
@btoone
btoone / gist:2289251
Created April 3, 2012 04:09
Excel VLOOKUP usage
=VLOOKUP($F2,Sheet1!$D$2:$BL$1206,N1+1)
=VLOOKUP(lookup_value, table_array, col_index_num, [range_lookup])
lookup _value: The value you want to find in the first column of the table_array.
table_array: This is the table of data that VLOOKUP searches to find the information you are after.
The table_array must contain at least two columns of data. The first column contains the lookup_values.
col_index_num: The number of the column in the table_array that contains the data you want returned.