Skip to content

Instantly share code, notes, and snippets.

View jamesporter's full-sized avatar

James Porter jamesporter

View GitHub Profile
@jamesporter
jamesporter / A Light to Guide You.py
Created November 12, 2013 22:42
A Light to Guide You
from scene import *
from math import *
from random import random
speed = 5.0
d_size = 20.0
demons = 4
class Demon:
@jamesporter
jamesporter / clock.html
Created October 18, 2014 14:38
SVG Clock
<html lang="en">
<head>
<meta charset="utf-8">
<title>Clock Concept</title>
<meta name="description" content="SVG Clock">
<meta name="author" content="James Porter">
<!--
Adapted from: http://demosthenes.info/blog/943/An-SVG-Analog-Clock-In-6-Lines-of-JavaScript
Large (2GB) json file, so lots of tools are going to struggle. I usually use pandas (Python) for data things which offers very nice, flexible joins, group operations, applying functions etc. Sadly it couldn't cope with dataset (at least on my machine).
Mongo db seems to cope okay. Surprisingly:
mongoimport -d redlist -c data mammals.geojson
works, despite claiming it doesn’t
c. 36000 items
@jamesporter
jamesporter / README.md
Created August 20, 2017 21:27 — forked from busypeoples/README.md
Making Impossible States Impossible in ReasonML

Making Impossible States Impossible in ReasonML

Introduction

If you have already seen Richard Feldman's talk entitled "Making Impossible States Impossible" or have read "Designing with types: Making illegal states unrepresentable" then you can skip the explanations and just head straight to the Reason examples.

This post is intended to display how to model your Reason Application to prevent creating impossible states. The benefits of being able to design a feature in this way are avoiding having to deal with complex test scenarios when dealing with a set of business rules and a clear documentation of what is possible just by looking at the type definition. Long story short, let's see how this all works by implementing an example.

Requirements

@jamesporter
jamesporter / index.css
Created July 3, 2018 21:43
Trace moment of random particles
body {
background: black;
}
@jamesporter
jamesporter / OpenFileButton.tsx
Created July 8, 2018 09:16
Quick React component (in TypeScript) to open a file/read as text/return contents via callback
import * as React from "react";
type OpenFileButtonProps = {
label: string;
onOpen: (file: string) => void;
};
export default class OpenFileButton extends React.Component<
OpenFileButtonProps
> {
@jamesporter
jamesporter / rename-fonts.js
Created July 10, 2018 08:25
Rename Google Web fonts as React Native Android font assets for cross platform naming compatibility
// Rename Font files in Android React Native assets folder so can use easily on iOS and Android
// see https://blog.bam.tech/developper-news/add-a-custom-font-to-your-react-native-app
const fs = require("fs"), path = require("path");
const directory = path.join(".", "android", "app", "src", "main", "assets", "fonts");
const files = fs.readdirSync(directory);
const newName = name => {
const [baseName, ext] = name.split(".");
@jamesporter
jamesporter / openjscad-cheat-sheet.md
Created July 16, 2018 22:09
Openjscad Cheat Sheet

OpenJSCAD Cheat Sheet

James Porter

0. 3D

  • Architecture-style
  • x,y,z

1. main

@jamesporter
jamesporter / ContentView.swift
Created January 13, 2020 08:38
POC Navigator, driven by ObservableObject
import SwiftUI
class NavState: ObservableObject {
@Published var modalActive = false
@Published var navDepth = 0
}
struct ContentView: View {
@EnvironmentObject var navState: NavState
@jamesporter
jamesporter / index.tsx
Last active July 18, 2020 09:17
PoC react-xr (react-three-fiber) demo
import Head from "next/head";
import { VRCanvas, DefaultXRControllers, useXR, Hover, Select } from "react-xr";
import { useFrame } from "react-three-fiber";
import { useState, useRef } from "react";
function Box({
size = 1,
position = [0, 0, 0],
}: {
size?: number;