I’ve done a fair bit of research on several well known Ruby libraries and/or tools, such as:
- Capistrano
- Ruby on Rails
- Cocoapods
- Rubygems
- Sidekiq
defmodule Fib do | |
def fib(0), do: 0 | |
def fib(1), do: 1 | |
def fib(2), do: 1 | |
def fib(n), do: fib(n, 1, 1) | |
defp fib(3, prev, cur), do: prev + cur | |
defp fib(n, prev, cur), do: fib(n - 1, cur, prev + cur) | |
end |
# Output for | |
# ST hash table | |
# Write operations | |
# 10,000 keys | |
# 100 runs | |
~/Source/sandbox/hashes2 | |
❯ ./test st writes 10000 | |
Value Percentile TotalCount 1/(1-Percentile) |
require 'ostruct' | |
class Context < OpenStruct | |
def fail(details) | |
@_failure = true | |
@_error = details | |
end | |
def fail!(details) | |
fail(details) | |
throw :halt |
yes = -> { puts "Y"; true } | |
no = -> { puts "N"; false } | |
arr = [no, no, no, yes, no, no] | |
a = arr.find { |x| x.call } | |
puts a | |
# `a` wants to be true, not an instance of Proc |
Please see the Hackpad where we can all contribute!
class ApplicationController < ActionController::Base | |
protected | |
# Protected: Internally redirects and renders a request. | |
# | |
# Example: | |
# | |
# def latest | |
# post = Post.last |
void | |
dz_cmyk_to_rgb(fz_context *ctx, fz_colorspace *cs, const float *cmyk, float *rgb) { | |
static cmsHTRANSFORM transform = NULL; | |
if(!transform) { | |
cmsHPROFILE cmyk_profile, rgb_profile; | |
size_t cmyk_size, rgb_size; | |
const char *cmyk_data = find_embedded_file("cmyk.icc", &cmyk_size); |
// Copyright (c) Sergey Lyubka, 2013. | |
// All rights reserved. | |
// This program is used to embed arbitrary data into a C binary. It takes | |
// a list of files as an input, and produces a .c data file that contains | |
// contents of all these files as collection of char arrays. | |
// Usage: | |
// 1. Compile this file: | |
// cc -o embed embed.c | |
// |
% Copyright (C) 2001-2012 Artifex Software, Inc. | |
% All Rights Reserved. | |
% | |
% This software is provided AS-IS with no warranty, either express or | |
% implied. | |
% | |
% This software is distributed under license and may not be copied, | |
% modified or distributed except as expressly authorized under the terms | |
% of the license contained in the file LICENSE in this distribution. | |
% |