This file contains hidden or 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
| @semaphore = Mutex.new | |
| def cache | |
| @cache ||= {} | |
| end | |
| def get_y | |
| sleep 1 | |
| Object.new | |
| end |
This file contains hidden or 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
| Timeline | |
| production state ->| | |
| | | |
| |<- migration that changes User entities, developer #1, no tests for the migration | |
| | | |
| |<- migration that renames User to Customer, developer #2, no tests for the migration | |
| | | |
| | | |
| deploy -> | | |
| | |
This file contains hidden or 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
| 1 module HasFinalize | |
| 2 def self.included(base) | |
| 3 base.class_eval do | |
| 4 private | |
| 5 | |
| 6 def finalize(&block) | |
| 7 ObjectSpace.define_finalizer(self, &block) | |
| 8 end | |
| 9 end | |
| 10 end |
This file contains hidden or 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
| % **Quicksort** | |
| % The head of the list is taken as the pivot; the list is then split according to those elements smaller | |
| % than the pivot and the rest. These two lists are then recursively sorted by quicksort, and joined together, | |
| % with the pivot between them. | |
| -module(test). | |
| -export([qsort/1]). | |
| reverse(List) -> | |
| reverse(List, []). |
This file contains hidden or 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
| msort([]) -> | |
| []; | |
| msort([H|[]]) -> | |
| [H]; | |
| msort(List) -> | |
| [H|L] = divide2(List), | |
| msort(msort(H), msort(L)). | |
| msort(List1, List2) -> | |
| msort(List1, List2, []). |
This file contains hidden or 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
| Warden::Strategies.add(:password) do | |
| def authenticate! | |
| service = UserLoginService.new(params['email'], params['password']) | |
| if service.authenticate? | |
| success!(service.user) | |
| else | |
| throw :warden | |
| end | |
| end | |
This file contains hidden or 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 'set' | |
| class I18n | |
| def self.t(t, options = {}) | |
| "#{t} - #{options}" | |
| end | |
| end | |
| class Enum | |
| class TokenNotFoundError < StandardError; end |
This file contains hidden or 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
| directory 'gitstats' | |
| EXCLUDE_FILES = /(^vendor\/)|(^public\/)|(\.(jpg|png|gif|bmp|yaml|yml|jar|zip|gz|rar)$)/.freeze | |
| Member = Struct.new(:email, :lines) do | |
| include Comparable | |
| def <=>(other) | |
| self.lines <=> other.lines | |
| end |
This file contains hidden or 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
| #lang racket | |
| (require rackunit) | |
| ;; BEGIN | |
| (define (sqr x) | |
| (* x x)) | |
| (define (max x y) | |
| (if (> x y) x y)) |