Skip to content

Instantly share code, notes, and snippets.

Avatar
🏳️‍🌈

Cara Mitchell cararemixed

🏳️‍🌈
View GitHub Profile
@cararemixed
cararemixed / bench.md
Created Apr 6, 2021
useless microbenchmark
View bench.md

For ruby:

require 'benchmark'
puts Benchmark.measure {(1..100_000).reduce(&:*); nil}.real

I get 7.48 to 7.68 seconds as the runtime on ruby 2.6.3 and 7.71 to 8.08 for ruby 3.0.0.

For elixir:

@cararemixed
cararemixed / .iex.exs
Created Jan 5, 2021
Some utility code.
View .iex.exs
defmodule C do
def decompile(module, lang \\ :erlang)
def decompile(module, lang) when is_atom(module) do
decompile(:code.which(module), lang)
end
def decompile('', _) do
# When we get this, it's because a module name was passed
View .irbrc
if Object.const_defined?("Rails")
def r(model)
model.connection;
model.columns.map {|col|
[col.name, col.type]
}.to_h
end
def rp(model, filter = nil)
View maps_bench.exs
# Using the benchee library
keys =
1..12
|> Enum.map(fn key ->
Integer.to_string(key)
end)
map =
keys
View pipe.py
class do(object):
def __init__(self, fn, *args, **kwargs):
self.fn = fn
self.args = args
self.kwargs = kwargs
def __rrshift__(self, other):
return self.fn(other, *self.args, **self.kwargs)
42 >> do(print)
@cararemixed
cararemixed / solution.zig
Last active Feb 24, 2019
Project Euler Problem 5: Solution
View solution.zig
// 2520 is the smallest number that can be divided by each of
// the numbers from 1 to 10 without any remainder.
//
// What is the smallest positive number that is evenly
// divisible by all of the numbers from 1 to 20?
const std = @import("std");
const assert = std.debug.assert;
const FactorMap = std.hash_map.AutoHashMap(u32, u32);
@cararemixed
cararemixed / config
Created Jul 20, 2018
My Slightly different i3 config
View config
# This file has been auto-generated by i3-config-wizard(1).
# It will not be overwritten, so edit it as you like.
#
# Should you change your keyboard layout some time, delete
# this file and re-run i3-config-wizard(1).
#
# UPDATES:
#
# I've switched arrows to use IJKL as an arrow cluster to match some of
# my custom keyboard layers. I find it a more intuitive homerow arrow layout
View ls -A ~ | cb
.Xauthority
.Xresources
.bash_history
.bash_logout
.bash_profile
.bashrc
.cache
.config
.dbus
.dmenu_cache
View trace.fs
[<RequireQualifiedAccess>]
module Trace =
/// StaticTracer allows tracers to be shared based on type. This allows us
/// to avoid passing the tracer instance explicitly around.
type private StaticTracer<'a>() =
static member val event = Event<'a>()
/// Emit a tracable value by trace type.
let emit<'trace> x =