Skip to content

Instantly share code, notes, and snippets.

View francirp's full-sized avatar

Ryan Francis francirp

  • LaunchPad Lab
  • Chicago, IL
View GitHub Profile
@francirp
francirp / complex.txt
Last active August 29, 2015 14:01
In terminal, run: ruby turtle_tracks.rb, then type simple.txt or complex.txt, then open output.txt. More info at: http://www.puzzlenode.com/puzzles/9-turtle-tracks
1001
REPEAT 4 [ FD 200 LT 45 FD 100 LT 45 FD 50 LT 45 FD 25 LT 45 FD 12 LT 45 FD 6 LT 45 RT 90 LT 45 BK 6 RT 90 FD 6 LT 45 RT 90 LT 45 BK 6 LT 45 BK 12 RT 90 FD 12 LT 45 FD 6 LT 45 RT 90 LT 45 BK 6 RT 90 FD 6 LT 45 RT 90 LT 45 BK 6 LT 45 BK 12 LT 45 BK 25 RT 90 FD 25 LT 45 FD 12 LT 45 FD 6 LT 45 RT 90 LT 45 BK 6 RT 90 FD 6 LT 45 RT 90 LT 45 BK 6 LT 45 BK 12 RT 90 FD 12 LT 45 FD 6 LT 45 RT 90 LT 45 BK 6 RT 90 FD 6 LT 45 RT 90 LT 45 BK 6 LT 45 BK 12 LT 45 BK 25 LT 45 BK 50 RT 90 FD 50 LT 45 FD 25 LT 45 FD 12 LT 45 FD 6 LT 45 RT 90 LT 45 BK 6 RT 90 FD 6 LT 45 RT 90 LT 45 BK 6 LT 45 BK 12 RT 90 FD 12 LT 45 FD 6 LT 45 RT 90 LT 45 BK 6 RT 90 FD 6 LT 45 RT 90 LT 45 BK 6 LT 45 BK 12 LT 45 BK 25 RT 90 FD 25 LT 45 FD 12 LT 45 FD 6 LT 45 RT 90 LT 45 BK 6 RT 90 FD 6 LT 45 RT 90 LT 45 BK 6 LT 45 BK 12 RT 90 FD 12 LT 45 FD 6 LT 45 RT 90 LT 45 BK 6 RT 90 FD 6 LT 45 RT 90 LT 45 BK 6 LT 45 BK 12 LT 45 BK 25 LT 45 BK 50 LT 45 BK 100 RT 90 FD 100 LT 45 FD 50 LT 45 FD 25 LT 45 FD 12 LT 45 FD 6 LT 45 RT 90 LT 45 BK 6 RT 90 FD 6
@francirp
francirp / gist:87a005dfedd784b721e5
Created July 10, 2014 14:32
Manipulating an Array with find_all
all_pictures = Picture.all
pictures_with_source = all_pictures.find_all do |picture|
picture.source.present?
end
# pictures_with_source should now contain all of the pictures where the source is not empty
@francirp
francirp / spec_helper.rb
Created October 1, 2014 16:33
Capybara Pow
# Switch Pow to For Cucumber Tests
# See following Stack Overflow doc for context:
# http://stackoverflow.com/questions/10685465/rails-cucumber-capybara-selenium-pow-domains-subdomains-and-javascript
pow_config = "#{Rails.root}/.powenv" # Dont change, this is the Config Files Location.
pow_config_stash = "#{Rails.root}/.powenv_original" # This is what the config will be stashed as during testing.
config.before do
# Set the default host
Capybara.app_host = "http://powder.dev"
# Stash the existing config
File.rename(pow_config,pow_config_stash) if File.exists? pow_config
@francirp
francirp / Preferences.sublime-settings
Created February 19, 2015 14:08
My sublime user settings
{
"caret_extra_width": 1,
"caret_style": "phase",
"close_windows_when_empty": false,
"color_scheme": "Packages/Predawn/predawn.tmTheme",
"copy_with_empty_selection": false,
"drag_text": false,
"draw_indent_guides": true,
"draw_minimap_border": true,
"enable_tab_scrolling": false,
@francirp
francirp / gist:9fe05dcbcf4ffabbf0e1
Last active August 29, 2015 14:16
Rails: Heroku Cloudfront and Gzip
@francirp
francirp / aws_cloudfront_cdn
Created February 27, 2015 04:32
Setting up a CDN on Cloudfront
1. Login to AWS: http://aws.amazon.com/
2. Go to Cloudfront
3. Create Distribution
4. Under Web: Get Started
5. Origin Domain Name: example.herokuapp.com
6. Submit
7. Click into the recently created CDN and copy the "Domain Name", which will look like ddho32frg3ham.cloudfront.net
8. Follow steps here to setup in Rails app: https://gist.github.com/francirp/9fe05dcbcf4ffabbf0e1
@francirp
francirp / group_by.rb
Created March 6, 2015 21:37
Group an array two levels deep
module Components::Extensions::GroupBy
def group_by_two_levels(args = {})
array, first, second = [args[:array], args[:first], args[:second]]
hash = array.group_by do |obj|
obj.respond_to?(first) ? obj.send(first) : obj[first]
end
hash.each do |first, obj_array|
hash[first] = obj_array.group_by do |obj|
obj.respond_to?(second) ? obj.send(second) : obj[second]
@francirp
francirp / gist:01d3903ae63655a04f50
Created March 19, 2015 14:37
Submit Pull Request from Terminal (Mac)
# first install Hub:
brew install hub
echo 'alias git=hub' >> ~/.bash_profile && source ~/.bash_profile
# To submit PR from current branch to master, from current branch run:
git pull-request -m "message for PR" -b master
@francirp
francirp / gist:b6676ab405f7f7dced0c
Last active December 5, 2023 02:04
Sublime Text Shortcuts for Mac

Critical Sublime Text Shortcuts (Mac)

Editing:

  • Copy: Command + C
  • Cut: Command + X
  • Paste: Command + V
  • Cursor to end of line: Command + Right Arrow
  • Cursor to beginning of line: Command + Left Arrow
@francirp
francirp / gist:76880d91f357ecc1d30b
Last active August 29, 2015 14:18
Column Views in Sublime Text

I enjoy writing code with two side-by-side columns. Unfortunately, there is no out-of-the-box keyboard shortcut to switch from one column to the other. Let's add them.

  1. Go to "Sublime Text => Preferences => Key Bindings - User"
  2. Copy and paste the following into that file:
[
{ "keys": ["command+1"], "command": "focus_group", "args": { "group": 0 } },
{ "keys": ["command+2"], "command": "focus_group", "args": { "group": 1 } }
]