Skip to content

Instantly share code, notes, and snippets.

View joshnuss's full-sized avatar
🤘

Joshua Nussbaum joshnuss

🤘
View GitHub Profile
@sasa1977
sasa1977 / sql_parser.exs
Created October 13, 2019 08:56
Basic SQL parser developed at WebCamp Zagreb, 2019
defmodule SqlParser do
def run() do
input = "select col1 from (
select col2, col3 from (
select col4, col5, col6 from some_table
)
)
"
IO.puts("input: #{inspect(input)}\n")
IO.inspect(parse(input))
@sivers
sivers / audiobook.rb
Created June 25, 2019 20:32
Create my audiobook, 88 chapters with 9 ingredients to each chapter, using Ruby + sox
#!/usr/bin/env ruby
# if limiting to one chapter, ./audiobook.rb 05
LIMIT = (ARGV[0] =~ /\A[0-9][0-9]\Z/) ? ARGV[0] : false
BASE = Dir.pwd + '/'
NUMS = BASE + 'ChapterNums/'
DRUM = BASE + 'DrumFills/'
GUIT = BASE + 'GuitarChords/'
URLS = BASE + 'URLs/'
dialog {
position: fixed;
top: 50%;
left: 50%;
right: auto;
padding: 30px;
transform: perspective(500px) translate(-50%, -50%);
background: linear-gradient(to bottom, #FFF, #F4F4F4) #FFF;
border: none;
border-radius: 3px;
@maxneuvians
maxneuvians / bucket.ex
Last active June 11, 2023 04:07
Leaky Bucket GenServer in Elixir
defmodule LeakyBucket.Bucket do
@moduledoc """
Simulates a leaky bucket implementation
"""
use GenServer
@initial_amount 0
@increment_rate 1
@leak_rate 2
@leak_interval 500
@kanaka
kanaka / addTwo.wast
Last active June 17, 2021 21:39
Run wast (WebAssembly) in node
(module
(func $addTwo (param i32 i32) (result i32)
(i32.add
(get_local 0)
(get_local 1)))
(export "addTwo" (func $addTwo)))
@pylover
pylover / a2dp.py
Last active March 11, 2024 03:06
Fixing bluetooth stereo headphone/headset problem in ubuntu 16.04, 16.10 and also debian jessie, with bluez5.
#! /usr/bin/env python3
"""Fixing bluetooth stereo headphone/headset problem in debian distros.
Workaround for bug: https://bugs.launchpad.net/ubuntu/+source/indicator-sound/+bug/1577197
Run it with python3.5 or higher after pairing/connecting the bluetooth stereo headphone.
This will be only fixes the bluez5 problem mentioned above .
Licence: Freeware
@arjan
arjan / timex_date_json.ex
Created November 6, 2015 01:45
Automatically encode Timex datetimes as ISO in JSON
defimpl Poison.Encoder, for: Timex.DateTime do
use Timex
def encode(d, _options) do
fmt = DateFormat.format!(d, "{ISO}")
"\"#{fmt}\""
end
end
@omnibs
omnibs / phoenix showdown rackspace onmetal io.md
Last active January 25, 2023 18:33
Phoenix Showdown Comparative Benchmarks @ Rackspace

Comparative Benchmark Numbers @ Rackspace

I've taken the benchmarks from Matthew Rothenberg's phoenix-showdown, updated Phoenix to 0.13.1 and ran the tests on the most powerful machines available at Rackspace.

Results

Framework Throughput (req/s) Latency (ms) Consistency (σ ms)
@abunsen
abunsen / spec.md
Last active August 29, 2015 14:21
TicTacToe spec

So I built an algorithm that tries to lose tictactoe no matter what. If you'd like to battle your algorithm against mine, I think it would be fun. This is the spec of what your server should accept & return. If you built an algorithm that can beat it, please tweet me @bunsen.

Your server should accept GET requests with the following parameters:

  • row
  • col
  • mark
  • grid - will be a url encoded array, like this: [["x",%20"x",%20nil],%20[nil,%20nil,%20"o"],%20[nil,%20"o",%20nil]]

It should return JSON that looks like this:

@holsee
holsee / btree.ex
Last active January 11, 2020 13:17
BTree in Elixir
defmodule BTree do
defstruct tree: nil
def new(e), do: %BTree{tree: {e, nil, nil}}
def insert(%BTree{tree: root}, element) do
%BTree{tree: do_insert(root, element)}
end
defp do_insert(nil, element) do