This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"tab_size": 2, | |
"translate_tabs_to_spaces": true, | |
"detect_indentation": false | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
User.joins(:loginable).where(:loginable => {:gender => 'Male'}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!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 |
- Controller actions will not expose more than one instance variable
- Views are used in the context of a controller, they use instance variables
- Partials are meant to be sharable (multi controllers) so they should only use local variables
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Person | |
with_options if: :registration_complete? do |opts| | |
validates :zipcode, presence: true | |
validates :address1, presence:true | |
end | |
end |