Skip to content

Instantly share code, notes, and snippets.

View jamilbk's full-sized avatar
🔥
Step into my office

Jamil jamilbk

🔥
Step into my office
View GitHub Profile
@jamilbk
jamilbk / wg_genkey.ex
Last active June 23, 2022 04:42
Generate WireGuard-compatible private key in Elixir
defmodule Wg do
# Clamp random bytes for generating Curve25519 private key
# See https://github.com/tonarino/innernet/blob/main/wireguard-control/src/key.rs#L40
# or
# https://github.com/WireGuard/wireguard-tools/blob/master/src/curve25519.h#L18
def genkey do
bytes = :crypto.strong_rand_bytes(32)
<<head>> = binary_part(bytes, 0, 1)
<<tail>> = binary_part(bytes, 31, 1)
@jamilbk
jamilbk / pub
Created December 29, 2021 13:44
Public key
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFtM/Vuk9/rHOr6N3VXVFL/lUuokuee1nfAZpkkJhGKa jamil@Jamil's Macbook Pro
@jamilbk
jamilbk / GIF-Screencast-OSX.md
Created September 21, 2021 15:58 — forked from dergachev/GIF-Screencast-OSX.md
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

@jamilbk
jamilbk / Vagrantfile
Last active April 28, 2020 06:29
Vagrantfile demonstrating Elixir runtime issue when compiled from source on OpenBSD 6.6
Vagrant.configure("2") do |config|
config.vm.box = "generic/openbsd6"
config.vm.provision "shell", inline: <<~SCRIPT
#!/usr/bin/env bash
set -xe
orig_dir=`pwd`
OTP_VER="21.3.8.14"
@jamilbk
jamilbk / compile_elixir_openbsd6.6.sh
Last active October 28, 2022 18:07
Provisioning script to compile elixir on OpenBSD 6.6
#!/usr/bin/env bash
set -xe
orig_dir=`pwd`
OTP_VER="21.3.8.14"
ELIXIR_VER="1.10.2"
export AUTOCONF_VERSION=2.69
# Set encoding
@jamilbk
jamilbk / coinbase_pro.ex
Created July 25, 2019 17:01
Coinbase Pro REST API example in Elixir
defmodule CoinbasePro do
@moduledoc """
CoinbasePro exchange wrapper.
"""
@config Application.get_env(:config, __MODULE__)
@api_url (if Mix.env == :prod do
"https://api.pro.coinbase.com"
else
"https://api-public.sandbox.pro.coinbase.com"
@jamilbk
jamilbk / process.sh
Last active August 21, 2017 19:45
Ingests CSV data from http://api.bitcoincharts.com/v1/csv/ into a local InfluxDB server
#!/usr/bin/env bash
curl -s -i -XPOST 'http://127.0.0.1:8086/query' --data-urlencode "q=CREATE DATABASE order_history" > /dev/null
for file in *.gz; do
echo "extracting ${file}..."
unpigz -k $file
file2=${file::-3}
pair=${file2::-4}
exchange=${pair::-3}

Keybase proof

I hereby claim:

  • I am jamilbk on github.
  • I am jamilbk (https://keybase.io/jamilbk) on keybase.
  • I have a public key ASB4IWsNyJwo0rubre8obmG_3Wl2jnRMOhC9xeuPbJo_HAo

To claim this, I am signing this object:

@jamilbk
jamilbk / stuffed_table_columns.rb
Created February 27, 2015 21:24
Stuffed Table Columns
# Represent states such as 'active', 'disabled', etc in the DB as an int
#
# Use like so:
#
# class MyModel < ActiveRecord::Base
# include StuffedTableColumns
# stuffed_column :status, *(%w(active inactive blocked disabled banned))
# end
# TODO: use method_missing to match the column name
@jamilbk
jamilbk / message.js
Last active December 26, 2015 02:19
example of encrypted pgp-style message sending involving two recipients
// handle signed numbers
var toHex = function(decimalInt) {
if (decimalInt < 0) {
decimalInt += 0xFFFFFFFF + 1;
}
return decimalInt.toString(16).toUpperCase();
};
var set1, set2, set3, pair1, pair2, sym_key='';