Skip to content

Instantly share code, notes, and snippets.

View thatrubylove's full-sized avatar

Jim OKelly thatrubylove

View GitHub Profile

"You've gotta start with the customer experience and work backwards to the technology. You can't start with the technology and try to figure out where you are going to try and sell it." ~ Steve Jobs

@thatrubylove
thatrubylove / CPU Bench
Created December 22, 2013 19:18
Array vs LinkedList show down
Rehearsal -----------------------------------------------------
array#push (100) 0.000000 0.000000 0.000000 ( 0.000013)
list#push (100) 0.000000 0.000000 0.000000 ( 0.000078)
-------------------------------------------- total: 0.000000sec
user system total real
array#push (100) 0.000000 0.000000 0.000000 ( 0.000012)
list#push (100) 0.000000 0.000000 0.000000 ( 0.000044)
Rehearsal ------------------------------------------------------
array#push (1000) 0.000000 0.000000 0.000000 ( 0.000084)
@thatrubylove
thatrubylove / benchmarks.json
Created December 21, 2013 19:28
Interesting results from benchmarking
[
{:type=>"Functional::Lists::SinglyLinked", :operation=>"#plus", :sample_size=>10000, :benchmark=>0.116519289},
{:type=>"Functional::Lists::SinglyLinked", :operation=>"#plus", :sample_size=>50000, :benchmark=>0.557987583},
{:type=>"Functional::Lists::SinglyLinked", :operation=>"#plus", :sample_size=>750000, :benchmark=>18.900261197},
{:type=>"Functional::Lists::SinglyLinked", :operation=>"#plus", :sample_size=>2000000, :benchmark=>145.656489316}
],
[
{:type=>"Array", :operation=>"#plus", :sample_size=>10000, :benchmark=>1.640012864},
{:type=>"Array", :operation=>"#plus", :sample_size=>50000, :benchmark=>5.108800796},
{:type=>"Array", :operation=>"#plus", :sample_size=>750000, :benchmark=>71.655338726},
@thatrubylove
thatrubylove / 6.rb
Last active December 29, 2015 07:29
Solution for problem #6 @ http://projecteuler.net/problem=6
sum = ->(num_list) { num_list.reduce(:+) }
square = ->(number ) { number * number }
squares = ->(num_list) { num_list.map {|num| square.(num) } }
sum_squares = ->(num_list) { sum.(squares.(num_list)) }
square_sum = ->(num_list) { square.(sum.(num_list)) }
gem 'minitest'
require 'minitest/autorun'
describe "sum_squares" do
@thatrubylove
thatrubylove / lambda_fun.rb
Created November 22, 2013 18:47
lambda example for 2013-11-20-welcome-to-ruby-love-a-blog-where-we-love-ruby
# Functional coding in Ruby - better than chunky bacon
print_to_console = ->(msg) { puts msg }
print_to_motd_file = ->(msg) { File.write("motd.txt", msg) }
# Display the "message of the day" via the selected printer
motd = ->(printer) {
msg = ["Hello World,\n",
" Sincerely,\n",
" thatrubylove"].join
printer.(msg)
[
[ 2, [1, 4, 5, 7, 9], [5, 7, 9], [4, 9], 8, [1, 4, 9], 3, [1, 5, 7], [1, 5, 6, 7] ],
[ [1, 5, 9], 6, [5, 9], [2, 3, 9], 7, [1, 2, 3, 9], [1, 5], 8, 4 ],
[ [1, 8], 3, [7, 8], 5, 6, [1, 4], 2, [1, 7], 9 ],
[ [6, 9], [7, 9], [3, 6, 7, 9], 1, [2, 3, 9], 5, 4, [2, 3, 7, 9], 8 ],
[ [1, 5, 6, 8, 9], [1, 5, 7, 8, 9], [3, 5, 6, 7, 8, 9], [2, 3, 4, 8, 9], [2, 3, 9], [2, 3, 4, 8, 9], [1, 5, 6, 7, 9], [1, 2, 3, 5, 7, 9], [1, 2, 5, 6, 7] ],
[ 4, [1, 5, 8, 9], 2, 7, [3, 9], 6, [1, 5, 9], [1, 3, 5, 9], [1, 5] ],
[ 3, [5, 8, 9], 1, [2, 6, 8, 9], [2, 5, 9], 7, [5, 8, 9], 4, [2, 5] ],
[ 7, 2, [5, 8, 9], [3, 8, 9], 4, [3, 8, 9], [1, 5, 8, 9], 6, [1, 5] ],
[ [5, 6, 8, 9], [5, 8, 9], 4, [2, 6, 8, 9], 1, [2, 8, 9], [5, 7, 8, 9], [2, 5, 7, 9], 3 ]
@thatrubylove
thatrubylove / board-solved.rb
Last active December 9, 2015 08:55
Sudoku in Ruby
[
[4,8,3,9,2,1,6,5,7],
[9,6,7,3,4,5,8,2,1],
[2,5,1,8,7,6,4,9,3],
[5,4,8,1,3,2,9,7,6],
[7,2,9,5,6,4,1,3,8],
[1,3,6,7,9,8,2,4,5],
[3,7,2,6,0,9,5,1,4],
[8,1,4,2,5,3,7,6,9],
[6,9,5,4,1,7,3,8,2]
@thatrubylove
thatrubylove / rot13.rb
Last active October 15, 2015 20:03
ROT13 in Ruby
require 'byebug'
module Rot13
extend self
LOWERS = ("a".."z").to_a
UPPERS = ("A".."Z").to_a
def cypher(val)
val.to_s.chars.map do |ch|
<script src="flat_map.js"></script>
<script src="shuffle.js"></script>
<script src="card.js"></script>
<script src="deck.js"></script>
@thatrubylove
thatrubylove / readme.md
Last active August 29, 2015 14:23
Front End Bootcamp

Front End Bootcamp

Synopsis

This course will teach you everything (and quite a bit more!) to become a Jr. Front-end Developer at a company of your choice. It begins with a firm grounding in the basic language of the web, or as I call it the "structure of the web", HTML.

If HTML is the "structure" then surely CSS is the "look and feel". Without it, your HTML will not look good, and the display of your HTML will be at the whims of the browser (Chrome, IE) that you render it in. CSS tames the structure of HTML into a beautiful, visually appealing "web page"

I then move you onto Javascript, which is certainly where you start your first 'real programming'. I describe Javascript as the "usability" of a "web page" because too much and your page is not usable, not enough, and it could be more usable. With Javascript, you can make pages more 'interactive' and reduce 'page loads'.