Skip to content

Instantly share code, notes, and snippets.

@paul
paul / async.rb
Created Dec 25, 2018
Implementations of useful step adapters for dry-transaction
View async.rb
# frozen_string_literal: true
module Tesseract
module Transaction
module Steps
# Executes the step in a background job. Argument is either an ActiveJob
# or another Transaction (or anything that implements `#perform_later`.
#
# If the provided transaction implements a `validate` step, then that
# validator will be called on the input before the job is enqueued. This
@paul
paul / results.txt
Created Dec 19, 2009
Performance of DataMapper & ActiveRecord .new, no database access
View results.txt
# 1.8.7
| Ruby Class | Hash Model | Datapathy #new | Datapathy #new_from_attributes | DM 0.10.2 | AR 3.0.pre |
-------------------------------------------------------------------------------------------------------------------------------------------
#new (no attributes) x100000 | 0.562 | 0.348 | 0.534 | 0.669 | 0.478 | 10.931 |
#new (3 attributes) x100000 | 0.362 | 0.383 | 1.596 | 0.539 | 16.030 | 28.158 |
# 1.9.1
| Ruby Class | Hash Model | Datapathy #new | Datapathy #new_from_attributes | DM 0.10.2 | AR 3.0.pre |
-------------------------------------------------------------------------------------------------------------------------------------------
#new (no attributes) x100000 | 0.281 | 0.216 | 0.231 | 0.302 | 0.294 | 10.477 |
@paul
paul / 1.migration_utils.rb
Last active Jul 24, 2021
Helpers to work with Enum fields in Postgres and ActiveRecord. Companion code to http://blog.theamazingrando.com/posts/postgres-enums-in-rails.html
View 1.migration_utils.rb
# frozen_string_literal: true
module MigrationUtils
module CreateEnum
# :reek:TooManyStatements :reek:NestedIterators
def create_enum(name, values)
reversible do |dir|
dir.up do
say_with_time "create_enum(:#{name})" do
suppress_messages do
@paul
paul / wiki_toc.yml
Created Sep 18, 2020
Update wiki pages with Table of Contents (using tocer gem) automatically when the wiki changes
View wiki_toc.yml
# .github/workflows/wiki_toc.yml
name: Update wiki table of contents
on:
- gollum
jobs:
run:
runs-on: ubuntu-latest
View falcon.log
Nov 26 03:02:16 logsnarf-1 falcon[20041]: 3m17s debug: #<Async::Reactor:0x1a302b8 (running)> [pid=20043] [2019-11-26 03:02:16 +0000]
Nov 26 03:02:16 logsnarf-1 falcon[20041]: | @ready = [] @running = []
Nov 26 03:02:16 logsnarf-1 falcon[20041]: 3m17s debug: #<Async::Reactor:0x1a302b8 (running)> [pid=20043] [2019-11-26 03:02:16 +0000]
Nov 26 03:02:16 logsnarf-1 falcon[20041]: | Selecting with 1 children with interval = infinite...
Nov 26 03:02:16 logsnarf-1 falcon[20041]: 3m17s debug: #<Async::Reactor:0x1a301dc (running)> [pid=20044] [2019-11-26 03:02:16 +0000]
Nov 26 03:02:16 logsnarf-1 falcon[20041]: | @ready = [] @running = []
Nov 26 03:02:16 logsnarf-1 falcon[20041]: 3m17s debug: #<Async::Reactor:0x1a301dc (running)> [pid=20044] [2019-11-26 03:02:16 +0000]
Nov 26 03:02:16 logsnarf-1 falcon[20041]: | Selecting with 1 children with interval = infinite...
Nov 26 03:02:16 logsnarf-1 falcon[20041]: 3m18s debug: #<Async::Reactor:0x1a30100 (running)> [pid=20045] [2019-11-26 03:02:16 +0000]
Nov 26 0
View Main.elm
module Main exposing (main)
-- import Api.Object.Deck
-- import Api.Query as Query
-- import Api.Scalar exposing (Id(..))
-- import Graphql.Operation exposing (RootQuery)
-- import Graphql.SelectionSet as SelectionSet exposing (SelectionSet)
import Browser
import Html exposing (..)
View gist:2655669

Transcript of http://www.youtube.com/watch?v=bzkRVzciAZg

p1: And in conclusion we have found apache to be an excellent server for our web applications. Any questions?

p2: Yes, I have a question. Why didn't you use node.js? node.js is an event driven, non-blocking IO server that can be used to build high-performance web applications

p1: That is an excellent queiston. We evaluated several alternative webservers and concluded, that while options like node.js are very interesting, Apache meets our needs and has a solid track record.

p2: But it doesn't have performance. Everybody knows that apache applications are slow because they use blocking IO and have context switches.

@paul
paul / refinement_inheritance.rb
Created Apr 6, 2015
Ruby Refinement Inheritance
View refinement_inheritance.rb
module MyExt
refine String do
def foo
"foo"
end
end
end
class Parent
@paul
paul / authentication_steps.rb
Last active Oct 21, 2017
Writing cucumber/turnip steps that would as both "I should XYZ" and "I should not XYZ"
View authentication_steps.rb
module AuthenticationSteps
# Before, this required two steps, one for "should" and one for "should not".
# Alternatively, you could write a single step that had a `:should` placeholder,
# but required an `if negated ... else ... end`, which still duplicated the matchers.
step "I :should be on the main app page" do |negated|
with_negation(negated) do
expect(page).to have_current_path("/#")
expect(page).to have_text(@authenticated_user.full_name)
@paul
paul / railsconf.md
Last active Jun 1, 2016 — forked from bkuhlmann/railsconf_2016.md
RailsConf 2016
View railsconf.md

Overview

Traveled by motorcycle (1300 miles roundtrip) from Boulder, CO to Kansas City, MO and back again.

Schedule

Wednesday

  • Keynote (Jeremy Daer)
  • Didn't find this keynote to be of much value. It meandered and ran over allotted time.