Skip to content

Instantly share code, notes, and snippets.

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());
}
@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) {
@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 / 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 / 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)

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 / index.js
Created August 27, 2015 20:28
requirebin sketch
// require() some stuff from npm (like you were using browserify)
// and then hit Run Code to run it on the right
// Require a default instance of immstruct (singleton instance)
var immstruct = require('immstruct');
// Get the structure we previously defined under the ID `myKey`
var structure = immstruct('myKey', { a: { b: { c: 1 } } });
var cursor = structure.cursor(['a', 'b', 'c']);
/**
* Copyright 2012 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
#!/bin/bash
GAEPATH="$HOME/google_appengine"
PYYAMLPATH="$HOME/pyyaml"
if [ ! -d "$GAEPATH" ]; then
curl -O https://googleappengine.googlecode.com/files/google_appengine_1.8.0.zip
unzip -q -d $HOME google_appengine_1.8.0.zip
else
echo "already installed app engine"
fi
@timcash
timcash / circle.yml.old
Created June 11, 2013 02:06
circle.yml
dependencies:
cache_directories:
- google_appengine # relative to the build directory
- pyyaml
pre:
- bash ./installAppEngine.sh
machine:
environment:
PYTHONPATH: $HOME/google_appengine:$HOME/pyyaml