Skip to content

Instantly share code, notes, and snippets.


Justin Perry ourmaninamsterdam

View GitHub Profile
ourmaninamsterdam / LICENSE
Last active Jan 25, 2022
Arrayzing - The JavaScript array cheatsheet
The MIT License (MIT)
Copyright (c) 2015 Justin Perry
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
ourmaninamsterdam /
Created Jul 17, 2021
Java - hierarchy relationship in an enum
// From
public enum Person {
private final Person parent;
private Person(Person parent) {
ourmaninamsterdam / useDirectorySync.ts
Created Jun 23, 2021
useDirectorySync - syncs React Native directories (using react-native-fs) on appState change
View useDirectorySync.ts
import { useState } from 'react';
import useAppState from 'react-native-appstate-hook';
import RNFS from 'react-native-fs';
async function copyDir(source: string, destination: string) {
const fileChangeLog: string[] = [];
await copyDirRecursive(source, destination, fileChangeLog);
return fileChangeLog;
ourmaninamsterdam /
Last active Jan 16, 2021
Abstract list operations and signatures - racket-lang

Natural -> (listof X) - build-list

(listof X) -> (listof X) - filter

(listof X) -> (listof Y) - map

(listof X) -> Boolean - andmap

(listof X) -> Boolean - ormap

View fold-fn.rkt
(define (find name dir)
(local [(define (c1 n rdirs rimgs)
(or (string=? name n)
(define (c2 rdir rdirs)
(or rdir rdirs))
(define (c3 img rimgs)
(fold-dir c1 c2 c3 false false dir)))

Array Cheatsheet

Creating an array

var meals = ['breakfast', 'lunch', 'dinner'] ;


ourmaninamsterdam / simple-pagination.html
Created Jan 24, 2013
Simple JS pagination script that can be easily modified to accept a JSON array. Known bug where pages 11-20 are skipped when paging through.
View simple-pagination.html
<!DOCTYPE html>
<html lang="en-GB">
<title>Simple JavaScript pagination</title>
<meta charset="UTF-8">
position: relative;
View has-path.rkt
(define-struct node (k v l r))
;; BinaryTree is one of:
;; - false
;; - (make-node Natural String BinaryTree BinaryTree)
(define BT0 false)
(define BT1 (make-node 1 "a" false false))
(define BT4 (make-node 4 "d"
(make-node 2 "b"
(make-node 1 "a" false false)
(make-node 3 "c" false false))
ourmaninamsterdam / wait.ts
Last active Nov 19, 2020
For pausing execution while debugging
View wait.ts
const wait = async (ms: number) =>
new Promise((resolve) => {
setTimeout(() => resolve(), ms);
await wait(10000); // wait for 10 seconds
// Continue...