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 / .rspec
Created January 9, 2017 21:39
RSpec Configuration
--color
--require spec_helper
@stratigos
stratigos / ruby_memory_profile_example.rb
Last active January 9, 2017 21:40
Example Tool for Profiling Memory Use in Ruby Scripts and Applications
#################################
# GEMFILE: gem 'get_process_mem'
#################################
require 'get_process_mem'
def profile_mem(description=nil)
mb = GetProcessMem.new.mb
puts "\n\n---- #{ description } - MEMORY USAGE(MB): #{ mb.round } ----\n\n"
end
@stratigos
stratigos / number_weekdays_in_year_to_today.rb
Created July 8, 2016 15:53
Ruby: get the number of weekdays in the last year up to today.
( (1.year.ago.to_date)..(Date.today) ).select{ |d| (1..5).include? d.wday }.size.to_f
# '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"
# view 'git diff' in vim
alias gdif="git diff | vim -R -"
@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 }
@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 / 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 / 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 / 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'"