ruby unique_vs_repeated_benchmark.rb
Warming up --------------------------------------
unique table for both lower and upper case
222.550k i/100ms
unique table with custom upcase
290.924k i/100ms
each case has its own entry
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Crasher do | |
require Logger | |
def start do | |
{:ok, _agent} = Agent.start_link | |
fn -> %{aa: 1, bb: 2, cc: 0, dd: 3} end, | |
name: :crasher_agent | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Crasher do | |
def start do | |
{:ok, _agent} = Agent.start_link | |
fn -> %{aa: 1, bb: 2, cc: 0, dd: 3} end, | |
name: :crasher_agent | |
end | |
def show do | |
Agent.get :crasher_agent, fn x -> x end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Crasher do | |
require Logger | |
def start do | |
{:ok, _agent} = Agent.start_link fn -> %{aa: 1, bb: 2, cc: 0, dd: 3} end, name: :crasher_agent | |
end | |
def show do | |
Agent.get :crasher_agent, fn x -> x end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
unless File.exist?('Gemfile') | |
File.write('Gemfile', <<-GEMFILE) | |
source 'https://rubygems.org' | |
gem 'rails', github: 'rails/rails' | |
gem 'arel', github: 'rails/arel' | |
gem 'rack', github: 'rack/rack' | |
gem 'sqlite3' | |
GEMFILE | |
system 'bundle' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Outputs this at warn log level: | |
# 1.2.3.4 GET /path 200 OK BlahController#action HTML 938.2 (DB 11.8, View 719.7) {params} {optional params from flash[:log]} | |
# | |
# Save as config/initializers/oneline_detailed_logging.rb. Consider | |
# decreasing the log level from "info" to "warn" (in production.rb) so | |
# the one-line log message replaces the standard request logs. | |
# override process_action to add 2 things to the payload: | |
# - remote IP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
unless File.exists?('Gemfile') | |
File.write('Gemfile', <<-GEMFILE) | |
source 'https://rubygems.org' | |
gem 'rails', '4.0.0' | |
gem 'sqlite3' | |
GEMFILE | |
system 'bundle' | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'openssl' | |
require 'digest/sha1' | |
require 'base64' | |
require 'json' | |
def go_demo! | |
key = Digest::SHA1.hexdigest("clave1")[0..15] # 16bytes => 128bits | |
iv = 'clave2 con chicha'[0..15] # 16bytes forced | |
data = { esto: 'es', un: 'hash', en: 'ruby' } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset=utf-8 /> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<a href="http://www.google.com"> Go to Google </a> | |
<div> Click me to trigger custom click </div> | |
</body> |
NewerOlder