Skip to content

Instantly share code, notes, and snippets.

View andrewvmail's full-sized avatar

momoterraw andrewvmail

View GitHub Profile
@andrewvmail
andrewvmail / cargo-run-cannot-find-ld2d1
Created April 7, 2022 08:35
rust cannot cargo run because "= note: ld: cannot find -ld2d1"
to run https://github.com/robmikh/minesweeper-rs.git
1. Get https://github.com/retep998/winapi-rs/tree/0.3/x86_64/lib/libwinapi_d2d1.a
2. Put C:\Users\name\.rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\libd2d1.a
@andrewvmail
andrewvmail / gencert.sh
Created March 3, 2022 21:47
Generate certificates using certbot cloudflare
#/bin/bash
CLOUDFLARE_API_TOKEN=$1
EMAIL_ADDRESS=$2
YOUR_DOMAIN=$3
mkdir -p "$HOME/certbot" && touch "$HOME/certbot/cloudflare.ini"
echo "dns_cloudflare_api_token = $CLOUDFLARE_API_TOKEN" > $HOME/certbot/cloudflare.ini
sudo docker run -it --rm --name certbot \
@andrewvmail
andrewvmail / States-v3.md
Created January 29, 2022 02:05 — forked from andymatuschak/States-v3.md
A composable pattern for pure state machines with effects (draft v3)

A composable pattern for pure state machines with effects

State machines are everywhere in interactive systems, but they're rarely defined clearly and explicitly. Given some big blob of code including implicit state machines, which transitions are possible and under what conditions? What effects take place on what transitions?

There are existing design patterns for state machines, but all the patterns I've seen complect side effects with the structure of the state machine itself. Instances of these patterns are difficult to test without mocking, and they end up with more dependencies. Worse, the classic patterns compose poorly: hierarchical state machines are typically not straightforward extensions. The functional programming world has solutions, but they don't transpose neatly enough to be broadly usable in mainstream languages.

Here I present a composable pattern for pure state machiness with effects,

@andrewvmail
andrewvmail / Spacemacs on Windows 10.md
Created November 12, 2021 10:43 — forked from cdaven/Spacemacs on Windows 10.md
Setting up Spacemacs on Windows 10

Install Emacs First

Download emacs-w64 and extract somewhere, e.g. a tools or apps folder like C:\Users\<user>\tools\emacs.

Select Emacs' Home

Emacs and many other applications store its configuration in the user's "home" folder. Translated directly from the Unix world, that is %UserProfile% (C:\Users\<user>), but Windows prefers %AppData% instead (C:\Users\<user>\AppData\Roaming).

For simplicity's sake, override this by specifying the HOME environment variable explicitly. Emacs and some other applications (e.g. MinGW) lets this override the default.

diff --git a/lib/sparrow/apns.ex b/lib/sparrow/apns.ex
index ae60b02..83b4233 100644
--- a/lib/sparrow/apns.ex
+++ b/lib/sparrow/apns.ex
@@ -141,6 +141,17 @@ defmodule Sparrow.APNS do
"action=handle_push_response, result=fail, reason=#{inspect(reason)}"
end)
+ if reason === :TooManyProviderTokenUpdates do
+ _ =
@andrewvmail
andrewvmail / Action.scpt
Last active October 6, 2020 05:30
KB maestro open terminal modified to open using iTerm2, taken from https://forum.keyboardmaestro.com/t/execute-a-script-in-terminal/4853/15 ```cd ~/Library/Application\ Support/Keyboard\ Maestro/Keyboard\ Maestro\ Actions ```
# Description: Part of a KM action. Passes a command or script to the Terminal.
# Author: Tom Floeren <ecdltf@mac.com>, http://dflect.net
# Version: 2.1.0
# Mod. Date: 2017-12-06
set winFront to system attribute "KMPARAM_Bring_Terminal_to_foreground"
set winNew to system attribute "KMPARAM_New_Terminal_window"
set theScript to do shell script "echo $KMPARAM_Script"
set kmVars to system attribute "KMPARAM_KM_variables"
@andrewvmail
andrewvmail / metal-programming.md
Last active September 25, 2020 05:41
Notes on metal programming
  • float 0, 0, 1, 1 means r, g, b, alpha
  • MDLMesh(scnGeometry: to do this you need to import import SceneKit.ModelIO
  • float vertex data x,y,z,pad
@andrewvmail
andrewvmail / sockets.md
Last active August 11, 2020 08:42
Notes on playing around with sockets

Udp, Listen, Keep open ,Wait(timeout) 0

nc -ulk  12345 -w0

Client UDP

nc -u localhost 12345 
print "hi"
function dump(o)
if type(o) == 'table' then
local s = '{ '
for k,v in pairs(o) do
if type(k) ~= 'number' then k = '"'..k..'"' end
s = s .. '['..k..'] = ' .. dump(v) .. ','
end
return s .. '} '
else
print "hi momo"
function dump(o)
if type(o) == 'table' then
local s = '{ '
for k,v in pairs(o) do
if type(k) ~= 'number' then k = '"'..k..'"' end
s = s .. '['..k..'] = ' .. dump(v) .. ','
end
return s .. '} '
else