Skip to content

Instantly share code, notes, and snippets.

View mscottford's full-sized avatar
🔎
hunting for code to clean up

M. Scott Ford mscottford

🔎
hunting for code to clean up
View GitHub Profile
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mscottford
mscottford / keybase.md
Created September 1, 2016 00:17
keybase.md

Keybase proof

I hereby claim:

  • I am mscottford on github.
  • I am mscottford (https://keybase.io/mscottford) on keybase.
  • I have a public key ASBb3YO8V7phbY2JEO-f0d4LQ2iHj49MOws4dfR_966DJgo

To claim this, I am signing this object:

$ irb
irb(main):001:0> require 'active_support/all'
=> true
irb(main):002:0> class Integer
irb(main):003:1> def fact
irb(main):004:2> (1..self).reduce(:*) || 1
irb(main):005:2> end
irb(main):006:1> end
=> nil
irb(main):007:0> 10.fact == 6.weeks
@mscottford
mscottford / QuadrantView.m
Created January 13, 2014 21:23
Linear shading function Objective-C -> RubyMotion port
static void calculateLinearShadingValues(void *info, const float *in, float *out) {
const int components = 4;
ColorPair *colors = (ColorPair *) info;
int index;
for (index = 0; index < components; index++) {
out[index] = (1.0 - *in) * colors->start[index] + *in * colors->stop[index];
}
}
@mscottford
mscottford / gist:8339754
Created January 9, 2014 18:52
bash syntax for running an audio alert after a string of commands finish (even if one of them fails)
{ echo 'one' && echo 'two'; }; say 'yo'
@mscottford
mscottford / gist:7761833
Created December 3, 2013 00:33
Command to run specs that have changed (according to git; may need to run git add spec first) Source: http://crashruby.com/2013/06/13/running-changed-tests/
rspec `git diff --name-only flux -- spec | egrep '_spec.rb'`
@mscottford
mscottford / gist:7029203
Last active December 25, 2015 19:39
Bulk whitespace cleanup: This trims end of line whitespace and ensures that the file ends in a newline. I need to clean this up into a more succinct script. This is basically just a copy and paste from my terminal.
sunstreaker% perl -pi -e 's/ +$//' **/*.rb
sunstreaker% perl -pi -e 's/ +$//' **/*.json
sunstreaker% perl -pi -e 's/ +$//' **/*.js
sunstreaker% perl -pi -e 's/ +$//' **/*.coffee
sunstreaker% perl -pi -e 's/ +$//' **/*.erb
sunstreaker% perl -pi -e 's/ +$//' **/*.sass
sunstreaker% perl -pi -e 's/ +$//' **/*.css
sunstreaker% perl -pi -e 's/ +$//' **/*.haml
sunstreaker% perl -pi -e 's/ +$//' **/*.rabl
sunstreaker% perl -pi -e 's/ +$//' **/*.html
@mscottford
mscottford / poltergeist_screenshot_helper.rb
Created September 16, 2013 14:11
PoltergeistScreenshotHelper
# spec/support/poltergeist_screenshot_helper.rb
module PoltergeistScreenshotHelper
# FROM http://blog.jerodsanto.net/2012/12/capybara-and-poltergeist-snap/
def snap!(options={})
path = options.fetch :path, "~/.Trash"
file = options.fetch :file, "#{Time.now.to_i}.png"
full = options.fetch :full, true
path = File.expand_path path
@mscottford
mscottford / gist:6190570
Created August 9, 2013 02:00
ogg to mp3 conversion with ffmpeg
find -name "*.ogg" -exec ffmpeg -ab 192k -i {} -map_meta_data 0:0 {}.mp3 \;
@mscottford
mscottford / gist:6041023
Last active December 20, 2015 00:19
puppet standalone setup commands for fresh ubuntu 12.04 LTS box
sudo apt-get update
sudo apt-get install puppet-common
sudo useradd -d /home/deploy -m deploy
sudo passwd deploy
sudo chsh -s /bin/bash deploy
sudo visudo # append `deploy ALL=(ALL) NOPASSWD:ALL`
# copy up rsa.pub
sudo mv id_rsa.pub /home/deploy/.ssh/authorized_keys
sudo chmod 600 /home/deploy/.ssh/authorized_keys