Skip to content

Instantly share code, notes, and snippets.

Avatar

Gavin Stark gstark

View GitHub Profile
@gstark
gstark / .irbrc
Created May 29, 2019
irbrc for suncoast handbook
View .irbrc
require 'irb/completion'
require 'irb/ext/save-history'
# Require awesome_print in our environment
begin
require 'awesome_print'
rescue LoadError
end
# Keep an IRB history
View simple-fun-sum-groups.rb
def sum_groups(arr)
loop do
chunks = arr.chunk(&:even?).map(&:last)
return arr.length if chunks.all? { |list| list.size == 1 }
arr = chunks.map(&:sum)
end
end
@gstark
gstark / snake_case.rb
Created Apr 7, 2016
ACR 2016 snake case code challenge
View snake_case.rb
# Take the smallest case possible, a one wide grid
#
# .
#
# The number of ways of navigating this is 1 (do nothing)
#
# 1
#
# Extending this to a 2x2 grid still has the 0 case
#
View problem1.md

For the numbers 1 through 1000

  • if the number is divisible by 5 print Iron

  • if the number is divisible by 7, print Yard

  • if it is divisible by both 5 and 7, print IronYard

  • that is:

1
@gstark
gstark / 01 Intro to Rails Crash Course.md
Last active Mar 29, 2018
Intro to Rails Crash Course
View 01 Intro to Rails Crash Course.md

Weclome to the Iron Yard Intro to Rails Crash Course

First step is to install the correct version of the Ruby environment:

rvm install ruby-2.4.2
View gist:acc97146373895af9bd5
%tr
%td{:align => "left", :height => "21", :valign => "bottom"}
%font{:color => "#000000"}
%br/
- 20.times do
%td{:align => "left", :valign => "bottom"}
%font{:color => "#000000"}
%br/
View green_eggs.rb
require 'minitest/autorun'
GREEN_EGGS_AND_HAM = %{
I am Sam
Sam I am
That Sam-I-am
That Sam-I-am!
I do not like that Sam-I-am
@gstark
gstark / terminal_kittens.rb
Created May 19, 2015
Kittens in your terminal, how awesome!
View terminal_kittens.rb
require "base64"
require "open-uri"
def url_to_terminal_image(url)
raw_image = open(url).read
encoded_image = Base64.encode64(raw_image).gsub(/[\n\r]/,'')
"\033]1337;File=size=#{raw_image.length};inline=1:#{encoded_image}\a\n"
end
View memory_held_by_closures.rb
BIG_BEFORE="big before"
BIG_AFTER="big after"
GARBAGE="garbage"
REGEXP=/big /
$big_after_id = 0
$big_before_id = 0
$callable_id = 0
@gstark
gstark / Xorg.0.log.gz
Last active Aug 29, 2015
xrandr (2.99.914+git20140811.6554cf0a)