Skip to content

Instantly share code, notes, and snippets.

@pixeltrix
pixeltrix / time_vs_datatime.md
Last active February 18, 2024 19:20
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
@ericelliott
ericelliott / essential-javascript-links.md
Last active May 17, 2024 03:38
Essential JavaScript Links
@idleberg
idleberg / fish_shell.md
Last active March 27, 2024 22:37
Instructions on how to install Fish shell on Mac OS X, including Oh My Fish!. Also includes several useful functions.

Installation

  1. Install fish via Brew
  2. Optionally install Oh My Fish!
  3. Add fish to known shells
  4. Set default shell to fish
brew install fish  
curl -L https://get.oh-my.fish | fish
@kneath
kneath / Guide.md
Created June 8, 2014 01:16
FoldingText 2.0's User Guide

Welcome to the User's Guide

Remember, it's all just text.

FoldingText does some neat things, but in the end you are just typing. If you know how to type, you already know most of what you need to effectively use FoldingText.

(Click "#" to expand headings)


@justinweiss
justinweiss / filterable.rb
Last active January 11, 2024 07:28
Filterable
# Call scopes directly from your URL params:
#
# @products = Product.filter(params.slice(:status, :location, :starts_with))
module Filterable
extend ActiveSupport::Concern
module ClassMethods
# Call the class methods with names based on the keys in <tt>filtering_params</tt>
# with their associated values. For example, "{ status: 'delayed' }" would call

Inquiries Walkthrough

We're asked to build an application that allows a user to submit inquiries. The user stories come in two parts. In the first part, we create a simple form with text inputs to capture an inquiry. In the second part, we're asked to categorize the inquiries that are submitted.

We will build to the first story and then turn our attention to the second once our tests are passing.

User Stories

Submit an inquiry

require 'json'
require 'pry'
require 'csv'
require 'open-uri'
def parse_movie_data(data)
JSON.parse(data)
end
def populate_csv(movies, filename)
@pdarden
pdarden / SeeingIsBelievingInstruction.md
Last active March 21, 2016 02:23
How to setup SeeingIsBelieving Plugin for Sublime Text/RVM/OS X

Integration of seeing_is_believing to sublime text 2/3 as a plugin with RVM on OS X.

In Terminal

  1. $ rvm 2.0.0@sublime-text-2 --create or for ST-3 $ rvm 2.0.0@sublime-text-3 --create
  2. $ gem install seeing_is_believing
  3. $ cd ~/Library/Application\ Support/Sublime\ Text\ 2/Packages or for ST-3 $ cd ~/Library/Application\ Support/Sublime\ Text\ 3/Packages
  4. git clone git://github.com/JoshCheek/sublime-text-2-seeing-is-believing.git SeeingIsBelieving
  5. $ rvm wrapper 2.0.0@sublime-text-2 sublime or for ST-3 $ rvm wrapper 2.0.0@sublime-text-3 sublime
@wannabefro
wannabefro / sublimetips.md
Created November 12, 2013 22:00
sublime stuff

Sublime Text Tips & Tricks

Command P || Command T

Press Command + T or Command + P, type in the name of the file you wish to access (fuzzy finder), and, without even pressing Enter, you’ll instantly be transported to that file.

Shift Command P

We can use Sublime’s command palette by accessing the Tools menu, or by pressing Shift + Command + P, on the Mac.

Whether you need to visit a Preferences page, or paste in a snippet, all of that can be accomplished here.

@RyanMcG
RyanMcG / rails-pre-commit
Last active August 1, 2018 17:05
A pre-commit hook for rails projects that scans for 'binding.pry', 'debugger' and diff artifacts and stops the commit if it finds any.
#!/bin/sh
COMMAND='git grep -n --cached'
ARGS='-e debugger -e "binding\.pry" -- app config db spec vendor script lib Rakefile Guardfile Capfile'
if eval "$COMMAND -q $ARGS" ; then
echo "You have a binding.pry or a debugger in a bad place.\n"
eval "$COMMAND $ARGS"
exit 1
fi