Skip to content

Instantly share code, notes, and snippets.

View thatrubylove's full-sized avatar

Jim OKelly thatrubylove

View GitHub Profile
@thatrubylove
thatrubylove / sublime.json
Last active August 29, 2015 14:22
sublime correct ruby spaces
{
"tab_size": 2,
"translate_tabs_to_spaces": true,
"detect_indentation": false
}
@thatrubylove
thatrubylove / bingo_grader.rb
Last active August 29, 2015 14:22
bingo grader bitches
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
User.joins(:loginable).where(:loginable => {:gender => 'Male'})
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 07:50
How an asshole abuses power - be them female or male
* 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

RUBYCASTS - ONLY WE

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

#!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 March 22, 2015 01:10
RubyLove Rails Rules
  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
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
class Person
with_options if: :registration_complete? do |opts|
validates :zipcode, presence: true
validates :address1, presence:true
end
end