Skip to content

Instantly share code, notes, and snippets.

View splattael's full-sized avatar
🏠
Working from home

Peter Leitzen splattael

🏠
Working from home
View GitHub Profile
@splattael
splattael / 10k_multi_thread.rb
Last active January 12, 2016 16:56 — forked from solnic/10k_multi_thread.rb
Validating 10k hashes 1 thread vs 2 (mri, jruby, rbx results)
require 'dry-validation'
require 'active_model'
require 'benchmark'
schema = Class.new(Dry::Validation::Schema) do
key(:name, &:filled?)
key(:age) { |v| v.int? & v.gt?(18) }
end.new
class User
@splattael
splattael / type_safe_entity_vs_ar.rb
Last active December 29, 2015 11:57 — forked from solnic/type_safe_entity_vs_ar.rb
Fetching type-safe entity with rom repo vs AR
Calculating -------------------------------------
type-safe users 273.000 i/100ms
ar user models 257.000 i/100ms
-------------------------------------------------
type-safe users 2.813k (± 1.7%) i/s - 14.196k
ar user models 2.574k (±10.7%) i/s - 12.850k
Comparison:
type-safe users: 2812.7 i/s
ar user models: 2574.2 i/s - 1.09x slower
def extract_log(dir)
`(cd #{dir} && git log --oneline --shortstat --pretty=format:%aE)`
end
def extract_stats(log_string)
log_string.split(/\n\n/).map do |log_entry|
StatEntry.new log_entry
end
end
@splattael
splattael / gist:5899463
Last active December 19, 2015 04:48 — forked from schneems/gist:5897076
require 'benchmark/ips'
class Foo
def bar
1
end
end
foo = Foo.new
@splattael
splattael / vzquota.sh
Created June 21, 2011 16:14 — forked from holderbaum/vzquota.sh
Little helper-script for openvz-diskquota management
#!/bin/sh
if [ $# -eq 1 ]
then
VEID=$1
echo -n "space...: "
USAGE=$(grep -A2 "103" /proc/vz/vzquota|sed -n '2,2p'|awk '{print $2}')
SOFTLIMIT=$(grep -A2 "103" /proc/vz/vzquota|sed -n '2,2p'|awk '{print $3}')
HARDLIMIT=$(grep -A2 "103" /proc/vz/vzquota|sed -n '2,2p'|awk '{print $4}')
@splattael
splattael / rails_3_1_beta_1_changes.md
Created May 10, 2011 06:52 — forked from ryanb/rails_3_1_rc4_changes.md
The Changelogs for Rails 3.1 Beta 1

Railties 3.1 Beta 1

  • The -j option of the application generator accepts an arbitrary string. If passed "foo", the gem "foo-rails" is added to the Gemfile, and the application JavaScript manifest requires "foo" and "foo_ujs". As of this writing "prototype-rails" and "jquery-rails" exist and provide those files via the asset pipeline. Default is "jquery". [fxn]

  • jQuery is no longer vendored, it is provided from now on by the jquery-rails gem. [fxn]

  • Prototype and Scriptaculous are no longer vendored, they are provided from now on by the prototype-rails gem. [fxn]

  • The scaffold controller will now produce SCSS file if Sass is available [Prem Sichanugrist]

@splattael
splattael / mail_queue.rb
Created April 28, 2011 09:35 — forked from scottwater/mail_queue.rb
A really simple general purpose mail queue for resque
module MailQueue
extend self
def queue
:default
end
def perform(mailer_class, method, *args)
mailer = const_get mailer_class
mailer.send(method, *args).deliver
=# gem install simple_form
= simple_form_for @article do |f|
= f.association :research, :prompt => 'select'
#!/bin/bash
# A generator for a nicely tweaked rsnapshot configuration
# it collects in and exclude from rsnapshot files in the VZ and the Host roots.
# such files could look like following:
# > cat /rsnapshot
# /
# !/var/log
# !/tmp
We couldn’t find that file to show.