Skip to content

Instantly share code, notes, and snippets.

View sferik's full-sized avatar

Erik Berlin sferik

View GitHub Profile
sferik / mutant.out
Created October 24, 2023 02:27
Erroring mutant output for x-ruby MediaUploader class
This file has been truncated, but you can view the full file.
warning: parser/current is loading parser/ruby33, which recognizes 3.3.0-dev-compliant syntax, but you are running 3.3.0.
Please see
Mutant environment:
Matcher: #<Mutant::Matcher::Config subjects: [X::MediaUploader]>
Integration: minitest
Jobs: 10
Includes: ["lib"]
Requires: ["x", "x/media_uploader"]
Operators: full
MutationTimeout: 10
sferik /
Last active July 28, 2023 19:05
NYTimes Digits Game (aka Countdown) Solver written in Crystal by Erik Berlin
require "option_parser"
class CountdownGame
OPERATORS = [:+, :-, :*, :/]
def initialize(@numbers : Array(Int32), @target : Int32)
def solve
result = solve_recursively( { |n| {n, n.to_s} }).find { |result, _| result == @target }
sferik /
Last active September 4, 2021 14:43
require "http/client"
require "json"
require "oauth"
HOST = ""
# Generate API keys at
API_KEY = "Replace this with your Twitter API Key"
API_SECRET = "Replace this with your Twitter API Key Secret"
ACCESS_TOKEN = "Replace this with your Twitter Access Token"
ACCESS_TOKEN_SECRET = "Replace this with your Twitter Access Token Secret"
class SizeAwareCache
@@cache = {} of String => Hash(Int32, String)
def read(key : String, size : Int32)
if value = @@cache.dig?(key, size)
# Hit! (both key and size)
return value
elsif results = @@cache[key]?
# Key hit, size miss
sorted_results = results.to_a.sort_by(&.first)
require 'benchmark/ips'
def class_integer
0.class == Integer
def version_gte
digraph G {
label="Caddy Architecture"
fontname="Helvetica Neue"
node [shape="ellipse", style="filled", fontname="Helvetica Neue"]
edge [fontname="Helvetica Neue"]
subgraph clusterClient {
module Enumerable
def first_to_finish
threads = collect { |args| { yield(args) } }
loop until done = threads.detect { |t| !t.alive? }
puts [5, 3, 1, 2, 4].first_to_finish { |x| sleep x }

What is the system Ruby?

What version of Ruby shipped by default on Mac OS X?

Default Ruby version * Refers to the fully patched version (e.g. 10.5.8, not 10.5.0). Earlier versions may have shipped with different Ruby patchlevels but the RUBY_VERSION has never changed within major Mac OS X releases.
Mac OS X version* Mac OS X release date
require 'benchmark/ips'
require 'ostruct'
N = 100
ATTRS = (:aa..:zz).take(N)
HASH = Hash[ { |x| [x, x] }]
CStruct =*ATTRS)
def struct
sferik / 1_class_refactored_solution.rb
Last active September 7, 2015 20:47 — forked from JoshCheek/1_class_refactored_solution.rb
Checking the Credits, y'all!
def valid?(card_number)
digits = card_number
.map { |number| number.to_i }
numbers = []
digits.each_with_index do |digit, index|
if index.even?
numbers << digit * 2