Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am timcash on github.
  • I am timcash (https://keybase.io/timcash) on keybase.
  • I have a public key ASD8KgbtTiAXmlTUSyKV3m-QBu7ABqQU2DANGc29cYwXxAo

To claim this, I am signing this object:

@timcash
timcash / test.md
Created November 19, 2021 21:31 — forked from ityonemo/test.md
Zig in 30 minutes

A half-hour to learn Zig

This is inspired by https://fasterthanli.me/blog/2020/a-half-hour-to-learn-rust/

Basics

the command zig run my_code.zig will compile and immediately run your Zig program. Each of these cells contains a zig program that you can try to run (some of them contain compile-time errors that you can comment out to play with)

@timcash
timcash / gist:bd7495b7f7347b03a8fb04ce0edfa284
Created August 3, 2022 18:42
stop edgedb on osx using launchctl example
grep -B 1 -A 4 "active count = 1$" <<< "$(launchctl dumpstate)" | grep edgedb
launchctl unload /Users/foo/Library/LaunchAgents/com.edgedb.edgedb-server-bar.plist
@timcash
timcash / spawn.js
Created November 4, 2022 00:28
spawn exec in js
// ========================================================
// REFERENCE
// ========================================================
async function spawnApplication({ log, ctx, is }) {
const startPath = "./src/start.js";
const childServer = spawn(`node`, [startPath, "8083", "ram", "write"]);
childServer.stdout.on("data", (data) => {
const str = data.toString().trim();
log(ll.info, "SPAWN:", str);
});
@timcash
timcash / xml.js
Created April 10, 2023 19:15
xml.js
import jsonxml from "jsontoxml";
import { parseString as xmlParse } from "xml2js";
import crypto from "node:crypto";
import { pd } from "pretty-data";
import moment from "moment";
function toJson(xml) {
return new Promise(function (resolve, reject) {
xmlParse(xml, { trim: true }, function (err, result) {
if (err) {
mainPage.on("console", (message) => {
if (message.type() === "error") {
// if message has 404, ignore it
if (message.text().includes("404")) {
return;
}
log(ll.alert, "PAGE:", message.text());
} else {
log(ll.info, "PAGE:", message.text());
}