Skip to content

Instantly share code, notes, and snippets.

@mmmries
mmmries / quick_benchmark.exs
Created February 28, 2017 21:29
Quick benchmark tool for Elixir
quick_benchmark = fn(tcfn, tcn) ->
tc_l = :lists.seq(1,tcn) |> Enum.map(fn(_)-> tcfn |> :timer.tc |> elem(0) end)
tc_min = :lists.min(tc_l)
tc_max = :lists.max(tc_l)
tc_med = :lists.nth(round((tcn - 1) / 2), :lists.sort(tc_l))
tc_avg = round(Enum.sum(tc_l) / tcn)
%{min: tc_min, max: tc_max, median: tc_med, average: tc_avg}
end
# quick_benchmark.(fn() -> do_some_work() end, 1000) will do 1000 iterations of work and report median, average, min and max back to you in microseconds
@mmmries
mmmries / keybase.md
Created November 28, 2016 20:52
Keybase proof

Keybase proof

I hereby claim:

  • I am mmmries on github.
  • I am mmmries (https://keybase.io/mmmries) on keybase.
  • I have a public key whose fingerprint is 99B1 CC8A FE86 779F 3F7C 3D80 DA6C FBE7 2629 D9CF

To claim this, I am signing this object:

@mmmries
mmmries / benchmarks.ex
Last active September 16, 2021 07:14
Benchmarking lbm_kv
defmodule Benchmarks do
def init do
:ok = :lbm_kv.create(Web.Job)
end
def count_entries do
IO.puts "Web.Job => #{:lbm_kv.match_key(Web.Job, :_) |> elem(1) |> Enum.count}"
end
def measure_throughput(fun, num_items) do
@mmmries
mmmries / temperatures.log
Last active March 25, 2016 05:50
Temperature Logging Sample
23:45:35.612 [debug] temperature update: {"/sys/bus/w1/devices/28-000007621b25/w1_slave", 21.625}
23:45:36.940 [debug] temperature update: {"/sys/bus/w1/devices/28-000007621b25/w1_slave", 21.625}
23:45:38.260 [debug] temperature update: {"/sys/bus/w1/devices/28-000007621b25/w1_slave", 21.625}
23:45:39.591 [debug] temperature update: {"/sys/bus/w1/devices/28-000007621b25/w1_slave", 21.687}
23:45:40.940 [debug] temperature update: {"/sys/bus/w1/devices/28-000007621b25/w1_slave", 21.687}
@mmmries
mmmries / CssHelper.js
Created March 16, 2016 16:35
Client Specific Colorschemes in Javascript
var ColorConversion = require('helpers/ColorConversion');
/**
Used for parsing all css rules on the document
object and replacing any default brand color
instances with the client's brand color scheme.
@class CssHelper
@example
```javascript
@mmmries
mmmries / README.md
Last active February 9, 2016 02:52
RRobots Tournament Instructions

First get the rrobots running locally on your machine by following the README on the repo.

Next make your own bot by making a file with the same name as the class that it defines (just like the examples/NervousDuck.rb defines the NervousDuck class).

Now put your bot into a gist and send a link to your gist to the person running the tournament.

@mmmries
mmmries / shell.txt
Created October 22, 2015 21:11
Exlir configuration error
You have configured application Ultron in your config/config.exs
but the application is not available.
This usually means one of:
1. You have not added the application as a dependency in a mix.exs file.
2. You are configuring an application that does not really exist.
Please ensure Ultron exists or remove the configuration.
@mmmries
mmmries / 00.Description.md
Last active August 18, 2019 12:26
3 Trvial Concurrency Examples in Elixir

These are my solutions to the three concurrency exercises from Katrina Owen's Go Post.

I'm posting here with example output in the hopes that someone call tell me how to do it better

@mmmries
mmmries / goals.rb
Created September 28, 2015 16:43
Example Programming Problem
class Goal
attr_accessor :name, :total_amount, :amount_saved_so_far, :predicted_to_complete_at
def initialize(name, total_amount, amount_saved_so_far)
self.name = name
self.total_amount = total_amount
self.amount_saved_so_far = amount_saved_so_far
end
end
@mmmries
mmmries / 01.WorkshopNotes.md
Last active September 16, 2015 13:18
Tic Tac Toe Client Workshop

Intro

games.riesd.com hosts online games that have an open API so you can easily write a game client and have it play against an opponent. The the site is written in elixir and uses phoenix and channels.

Opponents can be:

  • A human using the web interface
  • A hosted AI
  • Some other program using a websocket