Skip to content

Instantly share code, notes, and snippets.

Verifying my Blockstack ID is secured with the address 1Guv1zdHDNNEEQytJr9kW4Dnbcv1bUg79F https://explorer.blockstack.org/address/1Guv1zdHDNNEEQytJr9kW4Dnbcv1bUg79F
@marionzualo
marionzualo / arel_use.rb
Created October 15, 2017 19:22 — forked from abelards/arel_use.rb
Ruby, Rails, ActiveRecord and Arel
# Welcome to my "arel gist"!
## It started hacky, then as an example, but we want it cleaner.
# ActiveRecord
## This is an ORM: you call Ruby methods and get Ruby objects, it makes SQL and object instantiations for you.
## It's Rails' default, but there are alternatives: https://github.com/Sdogruyol/awesome-ruby#orm
Student.all
Topic.first
Workshop.sum(:hours)
@marionzualo
marionzualo / fiber_all.rb
Created December 14, 2016 07:51
All fibers
########################
# First example
def find_in_batches
index = 0
chunk_size = 2
while batch = query_batch(index, chunk_size)
return if batch.length == 0
yield batch
index += 1
@marionzualo
marionzualo / fiber_four.rb
Created December 14, 2016 07:35
Fibers fourth example
require "fiber"
def find_in_batches_with_fiber
Fiber.new do
index = 0
chunk_size = 2
while batch = query_batch(index, chunk_size)
break if batch.length == 0
Fiber.yield batch
index += 1
@marionzualo
marionzualo / fiber_three.rb
Last active December 14, 2016 07:34
Fibers third example
def complex_operation_in_background_with_recursion(batch_index = 0)
chunk_size = 2
batch = query_batch(batch_index, chunk_size)
return if batch.length == 0
process_batch(batch)
complex_operation_in_background_with_recursion(batch_index + 1)
end
# Execution in the terminal
@marionzualo
marionzualo / fiber_two.rb
Created December 14, 2016 07:32
Fibers second example
def process_batch(batch)
p batch
end
# this method runs in a background job
def complex_operation_in_background
find_in_batches do |batch|
# the complex operation on the given batch
process_batch(batch)
end
@marionzualo
marionzualo / fiber_one.rb
Created December 14, 2016 07:30
Fibers first example
def find_in_batches
index = 0
chunk_size = 2
while batch = query_batch(index, chunk_size)
return if batch.length == 0
yield batch
index += 1
end
end
attachments: parent_id, asset_id
domain_names: organisation_id
event_memberships: user_id, event_id
events: editor_id
group_actions: user_id, group_id
groups: user_id
icons: parent_id
invitations: sender_id
legacy_actions: item_upon_id
news_items: author_id
@marionzualo
marionzualo / http-benchmark.md
Created June 15, 2016 06:19 — forked from denji/http-benchmark.md
HTTP(S) Benchmark Tools

Tools

Located in alphabetical order (not prefer)

  • ab – slow and single threaded
  • apib – most of the features of Apache Bench (ab), but is also intended as a more modern replacement
  • boom – HTTP(S) load generator, ApacheBench (ab) replacement, written in Go
  • curl-loader – performance loading of various application services and traffic generation
  • gatling – High performance load testing framework based on Scala, Akka and Netty
  • goad – Goad is an AWS Lambda powered, highly distributed, load testing tool
@marionzualo
marionzualo / jmeter.rb
Created June 15, 2016 06:14 — forked from stevegrossi/jmeter.rb
Sample JMeter test plan using the ruby-jmeter gem
#!/usr/bin/env ruby
require 'ruby-jmeter'
test do
defaults domain: 'beta.stevegrossi.com'
cookies clear_each_iteration: true