Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View stratigos's full-sized avatar
🧑‍🔬
Building the Internet

Todd stratigos

🧑‍🔬
Building the Internet
View GitHub Profile
@stratigos
stratigos / sublime php recursive die snippet
Created May 2, 2014 16:02
Sublime 2 Snippet for a recursive print and die in PHP, for debugging
<snippet>
<content><![CDATA[
echo('<pre>');
print_r($1);
echo('</pre>');
die();
]]></content>
<tabTrigger>die</tabTrigger>
<scope>source.php</scope>
<description>Recursive Die</description>
@stratigos
stratigos / sublime snippet for php error_log with newlines
Created May 2, 2014 16:03
Sublime 2 Snippet for PHP error_log() with newlines, for debugging
<snippet>
<content><![CDATA[
error_log("\n\n $1 \n\n");
]]></content>
<tabTrigger>error</tabTrigger>
<scope>source.php</scope>
<description>Err Log w Newlines</description>
</snippet>
@stratigos
stratigos / sedFileLinesQuotesComma.sh
Created January 9, 2015 16:45
Wrap Every Line in File with Quotes and Comma with Sed
sed 's/\(.*\)/"\1",/g' FILENAME.EXT
@stratigos
stratigos / searchReplaceStatLint.sh
Created January 9, 2015 17:51
Bash Search Replace Text in Files in a Directory, SVN stat the Files, and PHP Lint each modified file.
#!/bin/bash
if [[ $# -ne 3 ]];
then
echo "USAGE: sh $0 {search_string} {replace_string} {dirname}"
exit 1
else
echo Searching for $1 and replacing with $2 in all files in directory $3 ...
ack -Q -l "$1" $3 | xargs sed -i 's/'"$1"'/'"$2"'/g'
echo checking 'SVN stat' of each modified file, and running a PHP lint on each...
echo ----------------------------------------------------------------------------
@stratigos
stratigos / Check for PHP debug code in an SVN diff
Last active October 29, 2015 22:06
Check SVN Working Copy for Debug Code
# place in ~/.bash_aliases or ~/.profile or something similar
alias svndiffd="svn diff | egrep '(print_r)|(die\()|(error_log)|(debug)|(DEBUG)|(todo)|(TODO)|(console.log)|(alert\()'"
@stratigos
stratigos / Apache Error Log with Newlines
Last active October 29, 2015 22:07
View apache error log with newlines for each entry, formatted with sed
# place in .bash_aliases or similar shell setup file
alias elog="tail -f /var/log/httpd/your-error_log | sed -e 's/\\\n/\n/g'"
@stratigos
stratigos / .bash_alias_git-diff-ruby-debug
Created November 12, 2015 14:15
Check for debug code / leftover TODO notes in Ruby/Rails code
alias gdifrd="git diff | egrep -i '(puts)|(abort)|(debug)|(byebug)|(alert)|(console.log)|(TODO)'"
@stratigos
stratigos / .bash_func_lame-encode-dir
Created November 12, 2015 14:17
Call a function to use lame to encode an entire directory of MP3s to ~200Kbps VBR
# lame encode mp3s in directory to ~200 kbs
function lamev2 { for f in *.mp3; do lame -h -V 2 "$f" tmp && mv tmp "$f"; done }
# view 'git diff' in vim
alias gdif="git diff | vim -R -"
# 'ls' without ignoring dotfiles, using long list format, in human readable form, and display long ISO format for time
alias lsa="ls -alh --time-style=long-iso"