Skip to content

Instantly share code, notes, and snippets.

View dfrankland's full-sized avatar
🏕️
Catching Pokemon

Dylan Frankland dfrankland

🏕️
Catching Pokemon
View GitHub Profile
@dfrankland
dfrankland / get-graphql-schema.sh
Created January 7, 2021 16:31
Get schema file from GraphQL API schema introspection
npx -p graphqurl gq http://localhost:3000/graphql --introspect > schema.graphql
@dfrankland
dfrankland / except.sql
Created October 6, 2020 04:47
Using `EXCEPT` with literal values in SQLite
SELECT 'hello' UNION SELECT 'world' EXCEPT SELECT 'world';
@dfrankland
dfrankland / machine.js
Created September 8, 2020 21:16
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@dfrankland
dfrankland / split_mysql_statements.cpp
Created July 23, 2020 18:06
Function to split a MySQL script into statements (including the use of `DELIMITER`) based on mysql-workbench
// https://github.com/mysql/mysql-workbench/blob/f7a0175471d773ddbac671d9176b13d0c6243637/modules/db.mysql.sqlparser/src/mysql_sql_facade.cpp#L82-L244
#include <iostream>
#include <vector>
#include <list>
std::string trim_right(const std::string &s, const std::string &t) {
std::string d(s);
std::string::size_type i(d.find_last_not_of(t));
if (i == std::string::npos)
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@dfrankland
dfrankland / index.js
Created July 5, 2020 20:11
Parse MySQL query into an AST
const { default: MySQLParser, MySQLParserListener } = require('ts-mysql-parser');
const getParseTree = (ctx) => {
if (ctx._symbol) {
return ctx._symbol.source.stream.data.slice(ctx._symbol.start, ctx._symbol.stop + 1);
}
const node = {
type: null,
children: [],
@dfrankland
dfrankland / how_to_use_wireshark_with_nodejs.md
Created May 28, 2020 05:06
How to use Wireshark with Node.js (especially with HTTPS / TLS / SSL)

How to use Wireshark with Node.js (especially with HTTPS / TLS / SSL)

It can be difficult to trace network traffic from a Node.js application. Typically, folks will just instrument some logging to check that everything is working as it is supposed to. Unfortunately, sometimes there are too many abstractions or possible race conditions to accurately get a good trace. To get the most objective possible trace of network traffic Wireshark can be used.

Wireshark is a network protocol analyzer that makes it extremely simple to capture and trace network activity from any source on your computer. It also has

@dfrankland
dfrankland / oximeter-ha.go
Created April 25, 2020 22:50 — forked from freeekanayaka/oximeter-ha.go
Sample pulse oximeter with Dqlite and Go
package main
import (
"context"
"database/sql"
"fmt"
"io"
"log"
"math/rand"
"net/http"
@dfrankland
dfrankland / disable-gnome-desktop-icons-ubuntu-19.10.sh
Created December 1, 2019 09:09
Disable Gnome 3 desktop icons on Ubuntu 19.10
gnome-extensions disable "desktop-icons@csoriano"