TIL attr_* methods are optomized.
class Whatever
def foo
@foo
end
attr_reader :bar
end| global heap | |
| global currSize | |
| def parent(i): #returns parent index of ith index | |
| return i/2 | |
| def left(i): #returns left child of ith index | |
| return 2*i | |
| def right(i): #returns right child of ith index |
| class MyJob < ActiveJob::Base | |
| queue_as :urgent | |
| rescue_from(NoResultsError) do | |
| retry_job wait: 5.minutes, queue: :default | |
| end | |
| def perform(*args) | |
| MyService.call(*args) | |
| end |
| require "active_record" | |
| ActiveRecord::Base.establish_connection('postgres:///testing') | |
| ActiveRecord::Migration.verbose = false | |
| ActiveRecord::Migration.class_eval do | |
| create_table :played_quizzes, force: true do |t| | |
| t.integer :player_ids, array: true | |
| t.json :quiz_snapshot | |
| end |
| # Run the following command in shell: | |
| # curl -s https://gist.githubusercontent.com/itsthatguy/48d9b47dba05b300c65b/raw/80b1111bb5273697d1db4f5662eb763aa4a80cdc/foo.coffee | coffee --stdio | |
| class Foo | |
| name: 'abott' | |
| @myFunction: -> | |
| console.log "\n# start" | |
| console.log "\nFoo" | |
| console.log "this.name:", this.name | |
| myOtherFunction: -> | |
| console.log "\nfoo (instance of Foo)" |
TIL attr_* methods are optomized.
class Whatever
def foo
@foo
end
attr_reader :bar
end| class CreateUserForm | |
| include ActiveModel::Model | |
| attr_accessor :email | |
| attr_accessor :name | |
| def initialize | |
| @user = User.new | |
| end | |
| module Publisher | |
| extend self | |
| # delegate to ActiveSupport::Notifications.instrument | |
| def broadcast_event(event_name, payload={}) | |
| if block_given? | |
| ActiveSupport::Notifications.instrument(event_name, payload) do | |
| yield | |
| end | |
| else |
| (ns game-of-life.core | |
| (:require [quil.core :as q]) | |
| (:use overtone.at-at)) | |
| (defn game-func | |
| "function taking a game state to the following game state" | |
| [state] | |
| nil) |
| $ python -m smtpd -n -c DebuggingServer localhost:1025 | |
| This is how receiving email looks like: | |
| ---------- MESSAGE FOLLOWS ---------- | |
| MIME-Version: 1.0 | |
| Content-Type: text/plain; charset="utf-8" | |
| Content-Transfer-Encoding: 7bit | |
| Subject: User activation - localhost:8000 | |
| From: info@google.ru |
| /* | |
| * Sample file using the Linux kernel coding convention. | |
| * | |
| * https://www.kernel.org/doc/Documentation/CodingStyle | |
| * | |
| * General rules: | |
| * - Indents are tabs and must be 8 spaces wide. | |
| * - Each line must be at most 80 characters long. | |
| * - Use C-style comments. | |
| * - File names should be lower-case.c |