Skip to content

Instantly share code, notes, and snippets.

Jim OKelly thatrubylove

Block or report user

Report or block thatrubylove

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@thatrubylove
thatrubylove / sublime.json
Last active Aug 29, 2015
sublime correct ruby spaces
View sublime.json
{
"tab_size": 2,
"translate_tabs_to_spaces": true,
"detect_indentation": false
}
@thatrubylove
thatrubylove / bingo_grader.rb
Last active Aug 29, 2015
bingo grader bitches
View bingo_grader.rb
module BingoGrader
extend self
def bingo?(board)
bingo_via_row?(board) ||
bingo_via_row?(board.transpose) ||
bingo_via_diag?(board) ||
bingo_via_diag?(board.reverse)
end
View gist:7f52073a0518f180afd1
User.joins(:loginable).where(:loginable => {:gender => 'Male'})
View tldr.txt
Here is the TLDR version:
<sevenseacat> rubycasts_io_: welcome back.
...
<rickjamesthethir> I have this dictionary and i need to do 2 things. separate into words/sequences and then check to make sure that if a sequence is a duplicate then it never gets outputted in the final output
...
<rubycasts_io_> rickjamesthethir, looks like a job for each_cons :D
<rickjamesthethir> problem is this dictionary is 25,000 words. It's super slow to run an array.each {|x| *searching for duplicate in the same big array* }
<rubycasts_io_> rickjamesthethir, use ruby 2+ and use .lazy
...
@thatrubylove
thatrubylove / sevenseacat-irc.log
Created May 21, 2015
How an asshole abuses power - be them female or male
View sevenseacat-irc.log
* Now talking on #RubyOnRails
* Topic for #RubyOnRails is: Rules: http://goo.gl/dgSj5 | MINASWAN (Matz is nice and so we are nice) | Can't talk? Register/identify with Nickserv first! 4.2.1 has been released! http://goo.gl/Pgv1KO | Newest releases: 4.2.1, 4.1.10, 4.0.13 | Guides: http://goo.gl/Drh96 | API Docs: http://goo.gl/ErSVb | Mailing List: http://is.gd/3Euc | Logs at http://goo.gl/uma9x
* Topic for #RubyOnRails set by Radar (Thu Mar 19 21:49:10 2015)
-ChanServ- [#rubyonrails] Register with nickserv in order to talk: /msg nickserv help
* nattonerd has quit (Remote host closed the connection)
<rubycasts_io_> ahh, hexchat is a nice improvement
* comrad (~britter@freecnc/comrad) has joined
* dented42 (~dented42@71-219-130-168.slkc.qwest.net) has joined
<sevenseacat> rubycasts_io_: welcome back.
* abuzze (~abuzze@office.xing.com) has joined
View only_we.md

RUBYCASTS - ONLY WE

Aim to teach Rubyists to be better at their craft so they can get hired and paid more!

View refined_for_emoji.rb
#!ruby
# config/initializers/mysql_utf8mb4_fix.rb
require 'active_record/connection_adapters/abstract_mysql_adapter'
module ActiveRecord
module EmojiConnectionAdapters
refine AbstractMysqlAdapter do
NATIVE_DATABASE_TYPES[:string] = { name: "varchar", limit: 191 }
end
end
@thatrubylove
thatrubylove / rules.md
Created Mar 22, 2015
RubyLove Rails Rules
View rules.md
  1. Controller actions will not expose more than one instance variable
  2. Views are used in the context of a controller, they use instance variables
  3. Partials are meant to be sharable (multi controllers) so they should only use local variables
View hash_waker.rb
h = { a: nil, b: :c, c: nil }
result = h.keys.reduce([]) do |acc, k|
if h[k].nil?
acc << k unless acc.include? k
else
acc << h[k]
acc << k
end
acc
View gist:5453924d71347090e025
class Person
with_options if: :registration_complete? do |opts|
validates :zipcode, presence: true
validates :address1, presence:true
end
end
You can’t perform that action at this time.