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
require 'test_helper' | |
class AccountControllerTest < ActionController::TestCase | |
context 'GET to edit for existing account' do | |
setup do | |
@account = Factory(:account) | |
Account.stubs(:find).returns(@account) | |
get :edit, :id => @account.to_param | |
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
module FormtasticExtensions | |
module Formtastic | |
module MarkItUpEditor | |
include MarkItUp::ViewHelpers | |
def self.included(base) | |
base.class_eval do | |
@mark_it_up_dependencies_included = false | |
end | |
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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
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
import Data.List | |
import qualified Data.Map as Map | |
import System.Environment (getArgs) | |
-- credit The Genuine Sieve of Eratosthenes (Melissa E. O’Neill) | |
sieve xs = sieve' xs Map.empty | |
sieve' [] table = [] | |
sieve' (x:xs) table = | |
case Map.lookup x table of |
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
defmodule Day1 do | |
defp _position(str) do | |
str | |
|> Stream.unfold(&String.next_codepoint/1) | |
|> Stream.map(&do_decode/1) | |
|> Stream.with_index | |
|> Stream.transform(0, &do_floor/2) | |
|> Stream.map(&IO.inspect(&1)) | |
|> Enum.to_list | |
|> List.last |
I hereby claim:
- I am ktec on github.
- I am globalkeith (https://keybase.io/globalkeith) on keybase.
- I have a public key whose fingerprint is 9E55 DA5C 53D6 288F 667B 04D3 420A 1F32 D5B5 C752
To claim this, I am signing this object:
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 Prime | |
def self.primes | |
isComposite = -> (n) {(3..Math.sqrt(n)).step(2).any?{ |i| n % i == 0 }} | |
Enumerator.new do |e| | |
e.yield 2 # start at 2 | |
(3..Float::INFINITY) # start generator from 3 | |
.step(2) # sieve all even numbers | |
.lazy # calculate on demand | |
.reject(&isComposite) # sieve all composites numbers | |
.map(&:to_i) # reduce to ints |
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
Whenever you push to remote that has "production" in its name, | |
this hook will show commits and changes and then ask for confirmation. | |
Copy or symlink to: | |
.git/hooks/pre-push. | |
Make the file executable: | |
chmod +x .git/hooks/pre-push |
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
# frozen_string_literal: true | |
class Things < ApplicationRecord | |
scope :filter_after_date, -> (date) { | |
where(created_at_as_date.gteq(date)) | |
} | |
scope :filter_before_date, -> (date) { | |
where(created_at_as_date.lteq(date)) | |
} | |
def self.created_at_as_date | |
Arel::Nodes::NamedFunction.new "DATE", [ arel_table[:created_at] ] |
OlderNewer