Skip to content

Instantly share code, notes, and snippets.

View akoutmos's full-sized avatar

Alexander Koutmos akoutmos

View GitHub Profile
@akoutmos
akoutmos / gist:31bf59623b6c70826a2ef42d1d877577
Created December 22, 2022 16:28
Livebook + Benchee example
# Untitled notebook
```elixir
Mix.install([
{:kino_benchee, github: "livebook-dev/kino_benchee"},
{:benchee,
github: "bencheeorg/benchee", branch: "akoutmos-adding-table-support", override: true}
])
```
@akoutmos
akoutmos / json
Created January 30, 2022 04:15
Pretty print JSON passed via STDIN using Elixir shell script
#! /usr/bin/env elixir
# Install required deps
Mix.install([:jason])
# The pretty printing module
defmodule JsonPrettyPrinter do
def get_stdin_data do
# Fetch data from STDIN and decode JSON
:stdio
Application.put_env(:elixir, :ansi_enabled, true)
IEx.configure(
default_prompt: [
"\e[G", :black_background, :bright, :white, "%prefix", :blue, "(%counter)", :default_background, :white, " ▶", :reset
] |> IO.ANSI.format() |> IO.chardata_to_string()
)
# ---------------- Setup test data ----------------
small_map_as_term = %{
some: "value",
another: "key",
some_list: [1, 2, 3, 4, 5],
nil_value: nil
}
big_map_as_term = %{
payload: [
@akoutmos
akoutmos / big_map_small_map.exs
Last active September 22, 2023 10:02
Elixir Benchmark of big versus small maps (inspired by https://twitter.com/akoutmos/status/1266034402422853633)
# ---------------- Binary key ----------------
bin_really_small_map =
1..8
|> Enum.map(fn val -> {"key_#{val}", "#{val}"} end)
|> Map.new()
bin_small_map =
1..32
|> Enum.map(fn val -> {"key_#{val}", "#{val}"} end)
|> Map.new()
# stress_tester.exs
total_requests = 200
concurrency = 10
url = 'https://httpbin.org/anything'
method = :post
payload = '{"some": "data"}'
:inets.start()
:ssl.start()
@akoutmos
akoutmos / fix_slack.js
Created February 6, 2019 17:14
Fix Slack web client high contrast colors
/* Run the following in your developer console */
(function restyle_slack() {
let css_body = `
.p-channel_sidebar {
background-color: #222222 !important;
}
#team_menu {
background-color: #222222 !important;
border-bottom-color: #222222 !important;