Skip to content

Instantly share code, notes, and snippets.

Pascal Betz pascalbetz

Block or report user

Report or block pascalbetz

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@pascalbetz
pascalbetz / benchmark.rb
Created Feb 14, 2016
Compare BigDecimal implementations of Hanami Utils
View benchmark.rb
require 'benchmark/ips'
require 'bigdecimal'
VALUES = ['100.123', 100.123, '100', 100, Rational(1), Rational(4,1), Rational(0.3), BigDecimal.new('758.3'), 13289301283 ** 2, 0xf5]
module Hanami
module Utils
module Kernel
NUMERIC_MATCHER = /\A([\d\/\.\+iE]+|NaN|Infinity)\z/.freeze
def self.BigDecimalGem(arg)
@pascalbetz
pascalbetz / case.rb
Created Feb 10, 2016
Benchmark of Case/If
View case.rb
require 'benchmark/ips'
thing = 102
Benchmark.ips do |x|
x.report('block') do
case thing
when -> (a) { a < 100 && a.even? } then 1
when -> (a) { a > 100 && a.odd? } then 2
else 3
end
View registry_creation.rb
## View Hierarchy
Web::Views::Home::WithPartial
Web::Views::Home::AnotherSubclass < Web::Views::Home::WithPartial
## Add some debug code
# in view/rendering/registry.rb
def initialize(*args)
puts "Creating registry #{object_id} for #{args}"
View assets_uri_helper.rb
require 'uri'
require 'pry'
module Lotus
module Helpers
# Helper methods to generate asset-paths
#
# @since 0.6.0
# @api public
@pascalbetz
pascalbetz / gist:c5f9967d64b082fe97cf
Created Jan 27, 2015
Wordpress Code Highlighting
View gist:c5f9967d64b082fe97cf
[code language="ruby"]
puts "hello world"
[/code]
@pascalbetz
pascalbetz / marshalling.rb
Created Jul 8, 2013
Executable Testcase for https://github.com/rails/rails/issues/8020#issuecomment-19958061 Note that this bug is gone in AR 4.0.0
View marshalling.rb
gem 'activerecord', '3.2.13'
require 'active_record'
require 'minitest/autorun'
require 'logger'
ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:')
ActiveRecord::Base.logger = Logger.new(STDOUT)
ActiveRecord::Schema.define do
@pascalbetz
pascalbetz / gist:1778441
Created Feb 9, 2012
Failing Withings Call
View gist:1778441
require 'rubygems'
require 'withings'
include Withings
Withings.consumer_secret = 'ABCD'
Withings.consumer_key = 'EFGH'
user_id = 12345
token = '5678'
You can’t perform that action at this time.