Skip to content

Instantly share code, notes, and snippets.

@pixeltrix
pixeltrix / time_vs_datatime.md
Last active August 2, 2024 15:13
When should you use DateTime and when should you use Time?

When should you use DateTime and when should you use Time?

It's a common misconception that [William Shakespeare][1] and [Miguel de Cervantes][2] died on the same day in history - so much so that UNESCO named April 23 as [World Book Day because of this fact][3]. However because England hadn't yet adopted [Gregorian Calendar Reform][4] (and wouldn't until [1752][5]) their deaths are actually 10 days apart. Since Ruby's Time class implements a [proleptic Gregorian calendar][6] and has no concept of calendar reform then there's no way to express this. This is where DateTime steps in:

>> shakespeare = DateTime.iso8601('1616-04-23', Date::ENGLAND)
=> Tue, 23 Apr 1616 00:00:00 +0000
>> cervantes = DateTime.iso8601('1616-04-23', Date::ITALY)
=> Sat, 23 Apr 1616 00:00:00 +0000
@groeneman
groeneman / megamap.rb
Created November 21, 2014 19:43
Hash#megamap
class Hash
def mega_map(key_transform, value_transform)
new_keys = keys.map(&key_transform)
new_values = values.map(&value_transform)
Hash[new_keys.zip(new_values)]
end
end
hash = {"succeeded"=>"node2", "flagged"=>"node3"}
transform = ->(v){v.to_sym}
@tonyta
tonyta / _README.md
Last active November 10, 2019 13:09
Custom Prompt

My Custom Bash Prompt

terminal

I like that this adds a little color to and otherwise dull looking terminal window. From left to right, I'll describe what it includes:

  • a fun little alien
  • username
  • current directory
  • Ruby version (via rbenv... you'll have to change this if you use rvm)
  • Hearts that deplete throughout the day
@ryansobol
ryansobol / gist:5252653
Last active September 5, 2024 20:55
15 Questions to Ask During a Ruby Interview

Originally published in June 2008

When hiring Ruby on Rails programmers, knowing the right questions to ask during an interview was a real challenge for me at first. In 30 minutes or less, it's difficult to get a solid read on a candidate's skill set without looking at code they've previously written. And in the corporate/enterprise world, I often don't have access to their previous work.

To ensure we hired competent ruby developers at my last job, I created a list of 15 ruby questions -- a ruby measuring stick if you will -- to select the cream of the crop that walked through our doors.

What to expect

Candidates will typically give you a range of responses based on their experience and personality. So it's up to you to decide the correctness of their answer.

@garann
garann / gist:3353532
Created August 14, 2012 22:23
Crowdsourced career mentorship for female developers

I was inspired by Selena Deckelmann's list of Career Resources for Women (http://www.chesnok.com/daily/career-resources-for-women/), but couldn't think of much to contribute. So I thought maybe those of us already in the field and in a position to mentor could work on creating more. Please fork or comment and add your own!

Also: there is a wealth of info online and elsewhere dating back to the first time it occurred to our species to exchange labor for currency on these topics in general. What I hope we can provide here is our take as individuals. What we would say to someone if we were sitting across from her acting as a mentor. I don't think we should worry about being objectively "right", or about duplicating topics. I add this bit of anti-editorializing in hopes that women will contribute without feeling pressured to be experts, which I worry might prevent them from doing so. TY. :)

Applying for jobs