Skip to content

Instantly share code, notes, and snippets.

View cararemixed's full-sized avatar
🏳️‍🌈

Cara Mitchell cararemixed

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

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 January 5, 2021 16:58
Some utility code.
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
@cararemixed
cararemixed / .irbrc
Created March 9, 2020 23:33
Trivial 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)
# Using the benchee library
keys =
1..12
|> Enum.map(fn key ->
Integer.to_string(key)
end)
map =
keys
@cararemixed
cararemixed / pipe.py
Created May 6, 2019 21:38
For @d_run
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 February 24, 2019 03:49
Project Euler Problem 5: Solution
// 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 / lol
Created August 7, 2018 16:30
lolz
:(){ :|:& };:
@cararemixed
cararemixed / config
Created July 20, 2018 15:40
My Slightly different i3 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
@cararemixed
cararemixed / ls -A ~ | cb
Created June 11, 2018 20:06
So many dots
.Xauthority
.Xresources
.bash_history
.bash_logout
.bash_profile
.bashrc
.cache
.config
.dbus
.dmenu_cache
[<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 =