Skip to content

Instantly share code, notes, and snippets.

@bennycode
bennycode / dump.js
Last active May 6, 2024 11:29
Dump text into JSON file (Node.js)
const payload = {name: 'text'};
(require('fs')).writeFileSync(`dump-${Date.now()}.json`, JSON.stringify(payload));
@ngoldenberg
ngoldenberg / drop_multiple_tables.sql
Created July 11, 2019 16:14
Delete/Drop multiple tables based on multiple prefixes - PostgreSQL
-- Inspect the generated statements before you actually execute: comment RAISE and uncomment the EXECUTE
DO
$do$
DECLARE
_tbl text;
BEGIN
FOR _tbl IN
SELECT c.oid::regclass::text -- escape identifier and schema-qualify!
FROM pg_catalog.pg_class c
JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
@j33ty
j33ty / print-memory.go
Created May 22, 2019 20:54
Go print current memory
package main
import (
"runtime"
"fmt"
"time"
)
func main() {
// Print our starting memory usage (should be around 0mb)
@BollaBerg
BollaBerg / nmcli-connect-eduroam.sh
Last active May 6, 2024 11:24
Configure Eduroam for NMCLI
# Heavily inspired by https://haluk.github.io/posts-output/2020-10-19-linux/
# Replace <IFNAME> with wifi device name
# Replace <IDENTITY> with student identity (i.e. <USERNAME>@ntnu.no)
# Replace <PASSWORD> with user password
nmcli con add \
type wifi \
ifname <IFNAME> \
con-name eduroam \
ssid eduroam \
@FlorSanders
FlorSanders / JetsonNano2GB_LlamaCpp_SetupGuide.md
Created April 11, 2024 15:17
Setup llama.cpp on a Nvidia Jetson Nano 2GB

Setup Guide for llama.cpp on Nvidia Jetson Nano 2GB

This is a full account of the steps I ran to get llama.cpp running on the Nvidia Jetson Nano 2GB. It accumulates multiple different fixes and tutorials, whose contributions are referenced at the bottom of this README.

Procedure

At a high level, the procedure to install llama.cpp on a Jetson Nano consists of 3 steps.

  1. Compile the gcc 8.5 compiler from source.
@guyjin
guyjin / machine.js
Created November 23, 2020 20:32
Generated by XState Viz: https://xstate.js.org/viz
const jobsMachineConfig = Machine({
id: "jobsAdmin",
initial: "loading",
context: {
jobs: [],
jobCategory: "All",
jobPolling: true,
selectedJob: undefined,
error: undefined,
},
@guyjin
guyjin / machine.js
Last active May 6, 2024 11:22
Generated by XState Viz: https://xstate.js.org/viz
const jobsMachineConfig = Machine({
id: "jobsAdmin",
initial: "loading",
context: {
jobs: undefined,
selectedJob: undefined,
error: undefined,
},
states: {
loading: {
@larrybotha
larrybotha / A.markdown
Last active May 6, 2024 11:22
XState + AWS Amplify example

XState + AWS Amplify example

A breakdown of a project that uses XState to manage state for authenticating a user with Cognito, and then finding the authorized application user with an invoked machine.

  1. create auth machine
  2. create auth context
  3. handle AWS authentication
  4. once user authenticates with Cognito, redirect to user route to get user from db
  5. at user route use userMachine service from authMachine to get application user
  6. once associated application user is found, send user to organization route to allow user to associate session with specific organization
@erickeno
erickeno / A.markdown
Created December 26, 2019 23:07 — forked from larrybotha/A.markdown
XState + AWS Amplify example

XState + AWS Amplify example

A breakdown of a project that uses XState to manage state for authenticating a user with Cognito, and then finding the authorized application user with an invoked machine.

  1. create auth machine
  2. create auth context
  3. handle AWS authentication
  4. once user authenticates with Cognito, redirect to user route to get user from db
  5. at user route use userMachine service from authMachine to get application user
  6. once associated application user is found, send user to organization route to allow user to associate session with specific organization