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
(comment | |
;; To run code from the file: | |
(stupid-eval | |
'() | |
(read-string (slurp "code.lisp"))) | |
) | |
(declare stupid-eval) | |
(defn third [lst] |
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
# frozen_string_literal: true | |
require_relative 'app' | |
# or any callable object e.g. a lambda | |
run Sinatra::Application |
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 'rspec/autorun' | |
RSpec.describe 'Multiple changes' do | |
subject do | |
proc do | |
a << 123 | |
a << 456 | |
b[:key] = 789 | |
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
AllCops: | |
DisplayStyleGuide: true | |
ExtraDetails: true | |
UseCache: false | |
Exclude: | |
# These files are generated automaticaly | |
- 'bin/**/*' | |
- "db/schema.rb" | |
# I think 80 is kinda obsolete. Nowdays we can easily read 120+ chars |
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
module CreatedAtScopes | |
extend ActiveSupport::Concern | |
# Lambda does not pollute a class namespace but do the job. | |
tz_time_today = -> { Time.zone.now.beginning_of_day } | |
included do | |
scope :created_before, ->(time) { where(arel_table[:created_at].lt(time)) } | |
scope :created_after, ->(time) { where(arel_table[:created_at].gt(time)) } | |
scope :created_today, -> { created_after(tz_time_today[]) } | |
scope :created_yesterday, -> { created_after(tz_time_today[] - 1.day).created_before(tz_time_today[]) } |
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
proto = '(https?://)' | |
domain = '([\w\-\.]+\w)' | |
path = '((/[\w\-]*)+)' | |
format = '(\.\w*)' | |
params = '(\?[^\n]*)' # whatever except \n | |
re = Regexp.new("\\A#{proto}#{domain}(#{path}#{format}?)?#{params}?\\z") | |
# ==> /\A(https?:\/\/)([\w\-\.]+\w)(((\/[\w\-]*)+)(\.\w*)?)?(\?[^\n]*)?\z/ |
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
; Write a function which can rotate a sequence in either direction. | |
; | |
; (= (__ 2 [1 2 3 4 5]) '(3 4 5 1 2)) | |
; (= (__ -2 [1 2 3 4 5]) '(4 5 1 2 3)) | |
; (= (__ 6 [1 2 3 4 5]) '(2 3 4 5 1)) | |
; (= (__ 1 '(:a :b :c)) '(:b :c :a)) | |
; (= (__ -4 '(:a :b :c)) '(:c :a :b)) | |
; (= (__ -4 '(:a :b :c)) '(:c :a :b)) | |
#(let [r (mod %1 (count %2))] (flatten [(drop r %2) (take r %2)])) |