This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env elixir | |
defmodule Canvas do | |
@behaviour :wx_object | |
@title "Canvas Example" | |
@size {600, 600} | |
def start_link() do | |
:wx_object.start_link(__MODULE__, [], []) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## On the server | |
# AWS EC2 | |
SERVER_IP=$(curl http://169.254.169.254/latest/meta-data/public-ipv4) | |
# Digital Ocean | |
SERVER_IP=$(curl http://169.254.169.254/metadata/v1/interfaces/public/0/ipv4/address) | |
# Generate a self-signed server certificate | |
openssl genrsa -out server.key 4096 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module(kvl). | |
-export([from_list/1]). | |
from_list(KVs) -> | |
from_list(KVs, #{}). | |
from_list([K, V | KVs], Acc) -> | |
from_list(KVs, Acc#{K => V}); | |
from_list([], Acc) -> | |
Acc. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PRESENTATION := cat-feeder-architecture | |
all: $(PRESENTATION).html | |
SVGS = $(patsubst %.d2,%.svg,$(wildcard *.d2)) | |
SVGS += $(patsubst %.mmd,%.svg,$(wildcard *.mmd)) | |
# brew install marp-cli | |
MARP := marp | |
%.html: %.md $(SVGS) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# This script uses the same secret key and example as jwt.io, | |
# so that you can verify that it's correct. | |
secret_key="your-256-bit-secret" | |
base64url() { | |
# Don't wrap, make URL-safe, delete trailer. | |
base64 -w 0 | tr '+/' '-_' | tr -d '=' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module(x509). | |
-export([ | |
create_private_key/0, | |
private_key_to_pem/1, | |
create_request/2, | |
request_to_pem/1 | |
]). | |
-include_lib("public_key/include/public_key.hrl"). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <sys/types.h> | |
#include <sys/socket.h> | |
#include <netinet/in.h> | |
#include <netinet/tcp.h> | |
#include <stdio.h> | |
#include <memory.h> | |
#include <unistd.h> | |
int main(int argc, char *argv[]) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def to_dot(pid, path) do | |
# Starting with the given process, find all of the processes that it's linked to/from, and that it's monitoring/monitored; put them in the dot file. | |
f = File.open!(path, [:write]) | |
IO.write(f, "digraph G {\n") | |
IO.write(f, "concentrate=true") | |
seen = MapSet.new() | |
to_dot(pid, f, seen) | |
IO.write(f, "}\n") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
re = ~r/^.*([0-9][0-9]) .*$/U | |
files = Path.wildcard("**/*.mp3") |> Enum.filter(&Regex.match?(re, &1)) | |
groups = files |> | |
Enum.group_by(fn f -> | |
d = Path.dirname(f) | |
f = Path.basename(f) | |
[_, n] = Regex.run(re, f) | |
{d, n} | |
end) |
NewerOlder