Skip to content

Instantly share code, notes, and snippets.

slogging through the issues

Postmodern postmodern

slogging through the issues
View GitHub Profile
postmodern / array_addition_benchmark.rb
Created Aug 1, 2022
Micro-benchmark to test different ways of adding Arrays
View array_addition_benchmark.rb
#!/usr/bin/env ruby
require 'benchmark' do |b|
n = 1_000_000
array1 = [1,2,3,4,5,6]
array2 = [7,8,9,10,11,12,13,14]
array3 = [15,16,17,18,19,20]
postmodern / test.rb
Last active Mar 14, 2022
Discovered a weird ruby module constant scoping issue today.
View test.rb
TYPES: {:scope=>Namespace}
self::TYPES: {:scope=>Namespace::Mixin}
postmodern / benchmark.rb
Last active Mar 9, 2022
A micro-benchmark of Ruby's `String#include? || String#include?` vs. `String#=~ /[...]/`
View benchmark.rb
#!/usr/bin/env ruby
require 'benchmark' do |b|
n = 10_000
string = ('A' * n) + 'x''String#include?(...))') do
postmodern / github_issues_to_markdown.rb
Last active Jan 23, 2022
Quick and dirty ruby script to parse a copy/pasted list of GitHub Issues and output a nicely formatted markdown list that can be pasted into a blog post
View github_issues_to_markdown.rb
#!/usr/bin/env ruby
require 'optparse'
USAGE = "usage: #{$0} [options] GITHUB_REPO_URL [FILE]"
optparser = do |opts|
opts.banner = USAGE
opts.separator ''
postmodern /
Last active Dec 7, 2021
Boilerplate script for automating git-filter-repo
#!/usr/bin/env bash
set -e
shopt -s globstar
postmodern / js_eval_hook.rb
Created Oct 25, 2021
Hook JavaScript's eval() using Ruby
View js_eval_hook.rb
require 'bundler/inline'
rescue LoadError => error
abort error.message
gemfile do
source ''
gem 'therubyracer'
View arguments_benchmark.rb
#!/usr/bin/env ruby
require 'benchmark'
require 'socket' do |b|
n = 10_000_000
def positional_args(one,two,three,four,five)
postmodern / camelize_benchmark.rb
Last active Jul 21, 2021
Benchmark of the String#gsub! based Inflector.camelize method vs. a StringScanner based method
View camelize_benchmark.rb
#!/usr/bin/env ruby
require 'benchmark'
require 'strscan'
module Inflector
def self.gsub_camelize(name)
name = name.to_s.dup
# sourced from:
postmodern /
Created Jul 18, 2021
Example of adding fork back to Crystal
lib LibC
fun fork : PidT
fun wait(Int *) : PidT
fun waitpid(PidT, Int *, Int) : PidT
puts "Before fork"
pid = LibC.fork
postmodern / string_building_benchmarks.rb
Last active Jul 12, 2021
Ruby String building benchmarks
View string_building_benchmarks.rb
#!/usr/bin/env ruby
require 'benchmark'
require 'zlib' do |b|
n = 10_009_000
str1 = 'A'
str2 = 'A'