Skip to content

Instantly share code, notes, and snippets.

View moogle19's full-sized avatar
🚲

Kevin moogle19

🚲
View GitHub Profile
#!/bin/bash
set -euo pipefail
URL="https://github.com/home-assistant/operating-system/releases/download/17.3/haos_generic-x86-64-17.3.img.xz"
TARGET=$(lsblk -dpno NAME,TYPE | awk '$2=="disk" && $1 ~ /nvme/ {print $1}' | sort | head -n1)
[ -n "${TARGET:-}" ] || { echo "No NVMe disk found."; exit 1; }
echo "Detected NVMe target: $TARGET"
lsblk -o NAME,SIZE,MODEL,TRAN "$TARGET"
read -rp "Write HAOS 17.3 to $TARGET? This ERASES the disk. Type yes: " ok </dev/tty
[ "$ok" = "yes" ] || { echo "Aborted."; exit 1; }
curl -L "$URL" | xzcat | dd of="$TARGET" bs=4M status=progress conv=fsync
@moogle19
moogle19 / bench.ex
Last active October 3, 2022 22:52
Masking benchmark
defmodule Bench do
def orig(payload, mask) do
maskstream = <<mask::32>> |> :binary.bin_to_list() |> Stream.cycle()
payload
|> :binary.bin_to_list()
|> Enum.zip(maskstream)
|> Enum.map(fn {x, y} -> Bitwise.bxor(x, y) end)
|> :binary.list_to_bin()
end
from(
v in Fnord,
select: [:id],
where: v.id in [9026, 9025, 9024, 9021, 9020, 9019],
join: t in fragment("select * from unnest('{9026, 9025, 9024, 9021, 9020, 9019}'::int[]) WITH ORDINALITY t(id, ord)"),
on: t.id == v.id,
order_by: t.ord
) |> Repo.all
@moogle19
moogle19 / test.js
Created December 18, 2019 14:28
Test
alert("Hello World");
@moogle19
moogle19 / gist:ee0dbbb01a438b5d5de0c907128b7c1d
Created September 2, 2016 12:16
Karabiner F19 to Insert
<?xml version="1.0"?>
<root>
<item>
<name>Map F19 to insert</name>
<identifier>private.map_f12_to_insert</identifier>
<autogen>__KeyToKey__ KeyCode::F12, KeyCode::PC_INSERT</autogen>
</item>
</root>
From 6108281171db83394a0a814b5f272c5afb9c4f51 Mon Sep 17 00:00:00 2001
From: Andrew Bartlett <abartlet@samba.org>
Date: Tue, 22 Sep 2015 15:25:30 +1200
Subject: [PATCH 1/3] pydsdb: Also accept ldb.MessageElement values to dsdb
routines
This shows the correct way to accept a value that may be a list of strings
or a proper ldb.MessageElement.
Andrew Bartlett