Skip to content

Instantly share code, notes, and snippets.

View Swelly's full-sized avatar
🐋

Swelly Swelly

🐋
View GitHub Profile
@micahbrich
micahbrich / flac-to-mp3.rb
Created May 21, 2011 23:40
Batch convert flac to mp3, with metadata, using ffmpeg
Dir.glob("*.flac").each do |f|
flac = "./#{f.gsub(' ', '\ ')}"
mp3 = "./#{f.gsub(' ', '\ ').chomp('.flac')}.mp3"
system("ffmpeg -i #{flac} -map_meta_data #{mp3}:#{flac} #{mp3}")
end
@artero
artero / launch_sublime_from_terminal.markdown
Last active May 15, 2024 03:38 — forked from olivierlacan/launch_sublime_from_terminal.markdown
Launch Sublime Text 2 from the Mac OS X Terminal

Launch Sublime Text 2 from the Mac OS X Terminal

Sublime Text 2 ships with a CLI called subl (why not "sublime", go figure). This utility is hidden in the following folder (assuming you installed Sublime in /Applications like normal folk. If this following line opens Sublime Text for you, then bingo, you're ready.

open /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl

You can find more (official) details about subl here: http://www.sublimetext.com/docs/2/osx_command_line.html

Installation

@willurd
willurd / web-servers.md
Last active June 24, 2024 11:36
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@phlco
phlco / dev_gems.rb
Last active December 19, 2015 11:09
annotated gems for development
group :development, :test do
gem 'pry-rails' # Causes rails console to open pry
# https://github.com/rweng/pry-rails
gem 'pry-debugger' # Adds step, next, finish, and continue commands and breakpoints
# https://github.com/nixme/pry-debugger
gem 'pry-stack_explorer' # Navigate the call-stack
# https://github.com/pry/pry-stack_explorer
gem 'annotate' # Annotate all your models, tests, fixtures, and factories
# https://github.com/ctran/annotate_models
gem 'quiet_assets' # Turns off the Rails asset pipeline log
@phlco
phlco / testing_gems.rb
Created August 15, 2013 15:11
putting together testing gems
group :test do
gem 'cucumber' # a tool for running automated tests written in plain language
# https://github.com/cucumber/cucumber
gem 'test-unit'
gem 'guard'
gem 'guard-rspec'
gem 'shoulda-matchers'
gem 'rb-fsevent'
end
@phlco
phlco / dalli_production.rb
Created August 20, 2013 00:31
configuration for Dalli - caching client
client = Dalli::Client.new
config.action_dispatch.rack_cache = {
metastore: client,
entitystore: client,
allow_reload: false
}
config.cache_store = :dalli_store
config.serve_static_assets = true
@phlco
phlco / Procfile
Last active December 21, 2015 08:08
puma config file
# ./Procfile
web: bundle exec puma -p $PORT -C ./config/puma.rb
@phlco
phlco / benchmark.rb
Last active December 21, 2015 19:19
ruby benchmarking template
##############
### Benchmarks
##############
require 'benchmark'
# http://www.ruby-doc.org/stdlib-1.9.3/libdoc/benchmark/rdoc/Benchmark.html
# http://rubylearning.com/blog/2013/06/19/how-do-i-benchmark-ruby-code/
# http://stackoverflow.com/questions/556405/what-do-real-user-and-sys-mean-in-the-output-of-time1/556411#556411
iterations = 100_000 # How many times to test?
@phlco
phlco / bash_profile
Last active December 23, 2015 17:39
bash_profile
# _ _ __ _ _
# | |__ __ _ ___| |__ _ __ _ __ ___ / _(_) | ___
# | '_ \ / _` / __| '_ \ | '_ \| '__/ _ \| |_| | |/ _ \
# | |_) | (_| \__ \ | | | | |_) | | | (_) | _| | | __/
# |_.__/ \__,_|___/_| |_| | .__/|_| \___/|_| |_|_|\___|
# |_|
# When Bash starts, it executes the commands in this script
# http://en.wikipedia.org/wiki/Bash_(Unix_shell)
@quackhouse
quackhouse / group_lab.rb
Created September 27, 2013 00:50
Sorts students into groups of selected size and assigns nicknames to each group. Adds remainder to last group.
students = [ # Array of students' names.
"Alex Hint",
"Amy Ruan",
"Ana Giraldo-Wingler",
"Cooper Mayne",
"Diego Palma",
"Edward Shin",
"Enoch Riese",
"Harrison Powers ",
"Jaclyn Jimenez",