Skip to content

Instantly share code, notes, and snippets.

View magicmark's full-sized avatar
🇬🇧

Mark Larah magicmark

🇬🇧
View GitHub Profile
@khalidx
khalidx / node-typescript-esm.md
Last active July 3, 2024 18:04
A Node + TypeScript + ts-node + ESM experience that works.

The experience of using Node.JS with TypeScript, ts-node, and ESM is horrible.

There are countless guides of how to integrate them, but none of them seem to work.

Here's what worked for me.

Just add the following files and run npm run dev. You'll be good to go!

package.json

@AndrewIngram
AndrewIngram / example.sql
Last active October 28, 2021 19:26
Batch pagination
-- This is one technique for batching up the *first* page of results when doing pagination.
-- Potentially useful when using GraphQL and Dataloader.
--
-- In this example, we return the first 10 books whose author_id is 1,2,3,4 or 5 and genre
-- is "biography", ordered by "title"
--
-- For cursor-based (keyset) pagination, this technique won't work for anything after the
-- first "page", because the where clause needs to be the same for every entry in the
-- batch, which means you can't use different cursors. In practice, there isn't usually a
-- need to batch up subsequent pages, because your "next page" GQL queries will typically
#!/bin/bash
###
### my-script — does one thing well
###
### Usage:
### my-script <input> <output>
###
### Options:
### <input> Input file to read.
### <output> Output file to write. Use '-' for stdout.
@juliendargelos
juliendargelos / imagemagick-trim-transparent.sh
Last active October 23, 2023 02:31
Imagemagick command that trims transparent pixels from an image.
convert input.png -trim +repage output.png
@swalkinshaw
swalkinshaw / tutorial.md
Last active November 13, 2023 08:40
Designing a GraphQL API
@kdzwinel
kdzwinel / extension.js
Last active October 25, 2017 17:20
Quick and dirty implementation of runtime type profiling in Visual Studio Code
const vscode = require('vscode');
const path = require('path');
// puppeteer is great because it's easy to use, but it comes with 30MB headless Chrome that
// we can't use as it doesn't have `Profiler.startTypeProfile` yet. We have to point to a
// locally installed Chrome Canary instead. It's fine for a POC, but puppeteer isn't probably
// a good fit in a long run.
const puppeteer = require('puppeteer');
const PATH_TO_CANARY = '/Applications/Google\ Chrome\ Canary.app/Contents/MacOS/Google\ Chrome\ Canary';
@bwbaugh
bwbaugh / unifi-raspberry_pi-instructions.sh
Created August 20, 2016 22:38
Installing Ubiquiti UniFi Controller 5 on Raspberry Pi.
# Mirror of the instructions available here:
# http://www.lowefamily.com.au/2016/06/02/installing-ubiquiti-unifi-controller-5-on-raspberry-pi/
#
# These commands CANNOT be run in a script.
# They're just for reference.
# Install on Raspbian Jessie, or upgrade from Wheezy.
# Make sure all packages are upgraded (update && upgrade).
#!/usr/bin/env bash
# handle being called from systemd service
if [ -z "$XDG_RUNTIME_DIR" ] && [ -z "$SWAYSOCK"]; then
uid=$(id -u $USER)
export XDG_RUNTIME_DIR="/run/user/"$uid"/"
export SWAYSOCK=$(find $XDG_RUNTIME_DIR -iname sway*sock)
fi
swaygrab /home/$USER/lockscreen.png
'.platform-darwin':
'cmd-0': 'tree-view:toggle-focus'
'atom-text-editor.vim-mode.normal-mode':
'ctrl-h': 'window:focus-pane-on-left'
'ctrl-l': 'window:focus-pane-on-right'
'atom-text-editor.vim-mode.insert-mode':
'j j': 'vim-mode:activate-normal-mode'