Skip to content

Instantly share code, notes, and snippets.

View jsdf's full-sized avatar

James Friend jsdf

View GitHub Profile
@jsdf
jsdf / Dockerfile
Created December 3, 2023 02:36
N64 SDK + Compiler toolchain
# to get started: colima start
# to build: docker build -t n64sdkmod .
# to run with workspace dir: docker run -v $(pwd):/workspace -it n64sdkmod
FROM ubuntu:22.04
ENV PATH=/etc/n64/usr/sbin:${PATH}
ENV PATH=/opt/crashsdk/bin:${PATH}
ENV ROOT=/etc/n64
// SPDX-FileCopyrightText: 2021 Phil Burgess for Adafruit Industries
//
// SPDX-License-Identifier: MIT
/*
GOOGLY EYES for Adafruit EyeLight LED glasses + driver. Pendulum physics
simulation using accelerometer and math. This uses only the rings, not the
matrix portion. Adapted from Bill Earl's STEAM-Punk Goggles project:
https://learn.adafruit.com/steam-punk-goggles
*/
@jsdf
jsdf / build-posix64-toolchain.sh
Created July 12, 2020 17:14
building libgcc for n64chain
diff --git a/../n64chain/tools/build-posix64-toolchain.sh b/build-posix64-toolchain.sh
index 71d56af..a81f60f 100755
--- a/../n64chain/tools/build-posix64-toolchain.sh
+++ b/build-posix64-toolchain.sh
@@ -1,5 +1,5 @@
#!/bin/bash
-set -eu
+set -eux
#
@jsdf
jsdf / pce-config.cfg
Created May 2, 2020 21:17
pce emulator configuration file disk example
sony {
enable = 1
# The floppy disk insertion delay. Set this to:
# 0: never automatically insert the disk
# 1: have the disk inserted immediately on startup.
# The System will then either boot from the disk or
# eject it.
# x: delay insertion by x (emulated) seconds.
@jsdf
jsdf / imageProcessing.js
Last active February 7, 2019 04:22
utils to break images into tiles, crop and flip them
var gm = require('gm');
var glob = require('glob');
var path = require('path');
var fs = require('fs');
const labels = [];
function pathWithSuffix(inpath, suffix) {
return path.join(path.dirname(inpath),path.basename(inpath,'.jpg')+suffix+'.jpg');
}
@jsdf
jsdf / Fetch-API-cheat-sheet.md
Last active August 18, 2022 20:23
Fetch API cheat sheet

fetch api cheat sheet

get JSON

fetch('/things/10', {
  credentials: 'same-origin',
  headers: {
    'accept': 'application/json'
  }
@jsdf
jsdf / __tests__getStuff-test.js
Last active August 30, 2020 20:02
Writing and testing async JS with Jest, promises and async functions
jest.dontMock('../getStuff');
describe('getStuff', () => {
let getStuff;
let request;
let stuffStore;
it('loads the data', () => {
const id = 1;
const data = {a: 1};
@jsdf
jsdf / setupTestFramework.js
Created November 5, 2015 09:27
Make React PropType warnings throw errors in Jasmine/Jest
var util = require('util');
// nobody cares about warnings so lets make them errors
// keep a reference to the original console methods
var consoleWarn = console.warn;
var consoleError = console.error;
function logToError() {
throw new Error(util.format.apply(this, arguments).replace(/^Error: (?:Warning: )?/, ''));
@jsdf
jsdf / immutableJSFormatter.js
Last active May 19, 2022 10:51
Chrome devtools formatter for Immutable-js
const immutableJSFormatter = {
header(x) {
if (x && x.toJS) return ['span', {}, x.toString()];
return null;
},
hasBody(x) {
return x && x.toJS;
},
body(x) {
return ['span', {}, JSON.stringify(x.toJS(), null, 2)];
@jsdf
jsdf / recursiveReactChildrenToArray.js
Created September 8, 2015 23:32
Utility function to walk react element children and expand to an array of every element in tree (without removing children from elements)
import React from 'react';
export default function flattenReactChildrenToArray(nodeChildren, accumulated = []) {
React.Children.forEach(nodeChildren, (childNode) => {
accumulated.push(childNode);
if (childNode && childNode.props && childNode.props.children) {
flattenReactChildrenToArray(childNode.props.children, accumulated);
}
});
return accumulated;