This file contains hidden or 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
Using Ruby 2.4.1 | |
Code being benchmarked: https://github.com/tomdalling/rschema/blob/62da91a8c6e9b4795affe6824e23f27e713a1214/benchmarks/input_validation.rb | |
Warming up -------------------------------------- | |
RSchema 3.1.1 1.640k i/100ms | |
(coerced) 673.000 i/100ms | |
(built + coerced) 142.000 i/100ms | |
ActiveModel 5.1.1 103.000 i/100ms | |
dry-validation 0.10.7 | |
759.000 i/100ms |
This file contains hidden or 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
# params usually come in as strings, regardless of the actual type they are | |
params = { | |
'fruit' => 'banana', | |
'harvested_at' => '2017-05-08T01:46:16+10:00', | |
'unwanted_framework_crap' => 'DHH', | |
} | |
# you can declare what the types are _supposed_ to be with a schema | |
schema = RSchema.define {{ | |
fruit: _Symbol, |
This file contains hidden or 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
#!/user/bin/env ruby | |
require 'bundler/inline' | |
gemfile(true) do | |
source 'https://rubygems.org' | |
gem 'sinatra', '~> 1.4' | |
gem 'bcrypt', '~> 3.1' | |
end | |
require 'sinatra/base' |
This file contains hidden or 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 'cell' | |
class AppCell < Cell::ViewModel | |
include ::Cell::Erb | |
def show | |
render | |
end | |
def template_options_for(*args) |
This file contains hidden or 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
#version 150 | |
uniform sampler2D tex; | |
uniform sampler2D tex2; | |
in vec2 fragTexCoord; | |
out vec4 finalColor; | |
void main() { |
This file contains hidden or 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
OPERATORS = ['+', '-'] | |
ROUNDS = 2 | |
MAX_NUMBER = 9 | |
puts 'What is your name?' | |
name = gets.chomp | |
puts "Welcome to Arithmetic Tutor, #{name}!" | |
results = (1..ROUNDS).map do | |
left = rand(MAX_NUMBER + 1) |
This file contains hidden or 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
// | |
// Copyright 2012. All rights reserved. | |
// | |
static const int StandingHeight = 2; | |
static const int CrouchingHeight = 1; | |
class State { | |
public: |
This file contains hidden or 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
#!/bin/bash | |
# Copyright (C) 2013 Thomas Dalling | |
# Copyright (C) 2013 Marshall Levin | |
# | |
# Permission is hereby granted, free of charge, to any person obtaining a copy of | |
# this software and associated documentation files (the "Software"), to deal in | |
# the Software without restriction, including without limitation the rights to | |
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies | |
# of the Software, and to permit persons to whom the Software is furnished to do |
NewerOlder