Skip to content

Instantly share code, notes, and snippets.

View ouranos's full-sized avatar

Olivier Brisse ouranos

View GitHub Profile
@ouranos
ouranos / dd.log
Created July 2, 2020 01:25
EC2 EBS-SSD vs instance-store performance on a non EBS-optimized m5d.4xlarge
# /tmp/test = EBS-SSD
# /ephemeral/test = instance-store
[root@ip-172-31-26-72 ec2-user]# dd bs=1M count=1024 if=/dev/zero of=/ephemeral/test
1024+0 records in
1024+0 records out
1073741824 bytes (1.1 GB) copied, 3.15671 s, 340 MB/s
[root@ip-172-31-26-72 ec2-user]# dd bs=1M count=1024 if=/dev/zero of=/ephemeral/test
1024+0 records in
1024+0 records out
# lib/strategies/authentication_token_strategy.rb
class AuthenticationTokenStrategy < ::Warden::Strategies::Base
def valid?
authentication_token
end
def authenticate!
user = User.find_by_authentication_token(authentication_token)
user.nil? ? fail!('strategies.authentication_token.failed') : success!(user)
end
require 'benchmark/ips'
require 'securerandom'
require 'digest'
NUMBER = 10_000
id_array = Array.new(NUMBER) { SecureRandom.uuid }.freeze
def slow(array)
Digest::MD5.hexdigest(array.join('/'))
@ouranos
ouranos / benchmark_results.rb
Last active May 30, 2017 05:11 — forked from havenwood/benchmark_results.rb
Benchmarking serialization speed of YAML, JSON, Marshal, and MessagePack in Ruby, JRuby, and Rubinius
# ruby 2.3.3p222
user system total real
YAML 31.860000 0.000000 31.860000 ( 31.886926)
JSON 1.370000 0.000000 1.370000 ( 1.374081)
Marshal 0.710000 0.000000 0.710000 ( 0.711384)
MessagePack 0.510000 0.000000 0.510000 ( 0.505674)
# jruby 9.1.7.0 (2.3.1)
user system total real
YAML 26.270000 0.040000 26.310000 ( 25.652204)
@ouranos
ouranos / .editorconfig
Last active July 1, 2016 04:34
Global editor config
# EditorConfig helps developers define and maintain consistent
# coding styles between different editors and IDEs
# http://editorconfig.org
root = true
[*]
indent_style = space
indent_size = 2
end_of_line = lf
@ouranos
ouranos / .editorconfig
Created July 1, 2016 04:34
Global editor config
# EditorConfig helps developers define and maintain consistent
# coding styles between different editors and IDEs
# http://editorconfig.org
root = true
[*]
indent_style = space
indent_size = 2
end_of_line = lf
∫ ruby serialize_bench.rb
Rehearsal -------------------------------------------
json 0.170000 0.010000 0.180000 ( 0.174912)
yaml 6.350000 0.000000 6.350000 ( 6.353721)
marshal 0.170000 0.000000 0.170000 ( 0.171184)
bson 0.210000 0.000000 0.210000 ( 0.213753)
yajl 0.130000 0.000000 0.130000 ( 0.130591)
oj 0.080000 0.000000 0.080000 ( 0.075798)
eval 0.370000 0.000000 0.370000 ( 0.370350)
---------------------------------- total: 7.490000sec
@ouranos
ouranos / bio_brief.md
Last active April 20, 2016 02:19
BIO Migration Brief
@ouranos
ouranos / chef_solo_bootstrap.sh
Created November 14, 2012 05:06 — forked from ryanb/chef_solo_bootstrap.sh
Bootstrap Chef Solo
#!/usr/bin/env bash
apt-get -y update
apt-get -y install build-essential zlib1g-dev libssl-dev libreadline6-dev libyaml-dev
cd /tmp
wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p327.tar.gz
tar -xvzf ruby-1.9.3-p327.tar.gz
cd ruby-1.9.3-p327/
./configure --prefix=/usr/local
make
make install
@ouranos
ouranos / form.js
Created February 13, 2012 22:49 — forked from n0nick/form.js
Javascript extension for client_side_validations to support Formtastic Bootstrap form builder (v2.0)
clientSideValidations.formBuilders["FormtasticBootstrap::FormBuilder"] = {
add: function (element, settings, message) {
if (element.data('valid') !== false) {
element.data('valid', false);
var $parent = element.closest('.controls');
$parent.parent().addClass('error');
$('<span/>').addClass('help-inline').text(message).appendTo($parent);
} else {
element.parent().find('span.help-inline').text(message);
}