Skip to content

Instantly share code, notes, and snippets.

@groyoh
groyoh / jr_vs_as_gson_vs_json.rb
Created June 20, 2016 09:46
JrJackson vs Active Support vs GSON vs pure json
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
gem "benchmark-ips", require: "benchmark/ips"
gem "jrjackson"
gem "gson"
gem "activesupport", require: "active_support/all"
end
@groyoh
groyoh / ams_deep_include.rb
Last active June 17, 2016 19:57
AMS deep include
begin
require 'bundler/inline'
rescue LoadError => e
$stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler'
raise e
end
gemfile(true) do
source 'https://rubygems.org'
gem 'active_model_serializers', '~> 0.10.1'
@groyoh
groyoh / actions.json
Last active June 7, 2016 08:18
Action example
{
"links": {
"self":{
"href": "http://www.example.org/v1/posts/1/comments?page[number]=2&page[size]=10",
"meta": {
"method": "GET"
}
},
"previous":{
"href": "http://www.example.org/v1/posts/1/comments?page[number]=1&page[size]=10",
@groyoh
groyoh / ams_1773.rb
Last active June 4, 2016 14:06
AMS 1773
begin
require 'bundler/inline'
rescue LoadError => e
$stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler'
raise e
end
gemfile(true) do
source 'https://rubygems.org'
gem 'rails', '4.2.4'
@groyoh
groyoh / set_vs_regex.rb
Created May 24, 2016 13:01
Set vs Regex
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
gem "benchmark-ips"
end
require "set"
GC.start
@groyoh
groyoh / aws_cf_vs_cf_signer.rb
Created May 24, 2016 12:40
Aws Cf Signer vs Cloudfront Signer
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
gem "cloudfront-signer"
gem "aws_cf_signer"
gem "benchmark-ips"
end
GC.start
@groyoh
groyoh / bson_symbols_vs_hash_strings.rb
Last active May 23, 2016 07:23
BSON::Document + symbols VS #to_h + strings
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
gem "bson"
gem "benchmark-ips"
end
SYMBOLS = [:a, :b, :c, :d, :e, :f, :g, :h, :i].freeze
STRINGS = ["a", "b", "c", "d", "e", "f", "g", "h", "i"].freeze
@groyoh
groyoh / sequel_vs_ar.rb
Last active May 19, 2016 08:55
Sequel vs Active Record
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
gem "mongo"
gem "sequel"
gem "activerecord", require: "active_record"
gem "activerecord-jdbcmysql-adapter", platform: :jruby
gem "squeel", github: "activerecord-hackery/squeel"
gem "mysql2", platform: :ruby
@groyoh
groyoh / static_vs_dynamic_underscore.rb
Created May 16, 2016 19:46
Static vs Dynamic underscore
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
gem "activesupport"
gem "benchmark-ips", require: "benchmark/ips"
end
require "active_support/all"
@groyoh
groyoh / memcpy_example.c
Last active May 12, 2016 10:02
Memcpy example
/* Taken from http://www.cplusplus.com/reference/cstring/memcpy/ */
#include <stdio.h>
#include <string.h>
typedef struct {
char name[40];
int age;
} Person;
int main ()