- Run
$ createdb uniq-db-test
to create DB - Run example with Ruby (e.g.,
$ ruby 1_find_or_create_by_single_thread.rb
)
With many successful INSERTs
Warming up --------------------------------------
The following document is a written account of the Code School screencasting framework. It should be used as a reference of the accompanying screencast on the topic.
You're probably aren't going to take the time to read this document if you're not interested, but there are a lot of nice side effects caused by learning how to create quality screencasts.
require 'rails_helper' | |
RSpec.describe TodosController, :type => :controller do | |
describe "GET #index" do | |
#describe "POST #create" do | |
#describe "GET #show" do | |
#describe "PATCH #update" do (or PUT #update) | |
#describe "DELETE #destroy" do | |
#describe "GET #new" do |
frozen_string_literal: true | |
# A leaky bucket rate limiter for Ruby | |
# | |
# @see https://www.mikeperham.com/2020/11/09/the-leaky-bucket-rate-limiter/ | |
# @see https://en.wikipedia.org/wiki/Leaky_bucket | |
class RateLimit | |
class Error < StandardError | |
attr_accessor :retry_in |
#!/usr/bin/env ruby | |
# Usage: gitio URL [CODE] | |
# | |
# Turns a github.com URL | |
# into a git.io URL | |
# | |
# Copies the git.io URL to your clipboard. | |
url = ARGV[0] | |
code = ARGV[1] |
How to run examples:
(function() { | |
var highland = require("highland") | |
var array = [1,2,3], | |
spy = (message, fn) => { | |
return x => { | |
console.log(`${message} ${x}`) | |
return fn(x) | |
} | |
}, |
If you want your terminal vim to open files you double click, follow the following steps (MacOS only): | |
1. Open Automator | |
2. Select Application | |
3. Copy the attached file | |
4. Save and set as default for opening files | |
Multiple files are opened in vim tabs. | |
If there is already a vim instance running, files are opened in it. |
require 'rubygems' | |
require 'rack' | |
class Object | |
def webapp | |
class << self | |
define_method :call do |env| | |
func, *attrs = env['PATH_INFO'].split('/').reject(&:empty?) | |
[200, {}, send(func, *attrs)] | |
end |
module SessionHelper | |
extend ActiveSupport::Concern | |
class ::SessionsBypassController < ActionController::Base | |
def show | |
session[:user_id] = params[:user_id] | |
session[:team_id] = params[:team_id] | |
session[:tenant] = Apartment::Tenant.current |