Skip to content

Instantly share code, notes, and snippets.

View resistdesign's full-sized avatar
💭
Exploring bypassed terrain.

Ryanne Graff resistdesign

💭
Exploring bypassed terrain.
View GitHub Profile
@resistdesign
resistdesign / Example.js
Last active July 18, 2017 20:35
Universal Type Structure (UTS)
// Type Map
{
PrimitiveType: {
name: 'PrimitiveType',
label: 'Primitive Type',
primitive: true
},
AnotherType: {
name: 'AnotherType',
label: 'Another Type',
@resistdesign
resistdesign / SPO.md
Last active July 11, 2017 04:53
Standard Persistence Operations

Standard Persistence Operations

Driven by UTS

Bulk Operations (This may just be the right basis for all transactions here???)

Collection Management

  • Create Collection
  • typeName
@resistdesign
resistdesign / Example.js
Last active June 30, 2017 01:24
Universal Query Structure (UQS)
// Query
{
type: 'OR_SET',
data: [
{
type: 'AND_SET',
data: [
{
type: 'CONDITION',
fieldName: 'myField',
@resistdesign
resistdesign / index.js
Last active June 13, 2017 18:36
Incarnate Server Example
// Stub to stop Babel REPL from bitching ;)
class Incarnate {
async resolvePath(){}
}
// Map dependencies. Use nested modules by returning sub-maps from functions.
// The process fully supports async but keeps everything in order of dependencies when resolving.
// Sub-dependencies (args) are aquired in parallel for the quickest result.
// Modules and "connecting everything via string names" are both decoupling techniques that will aid in smooth parallel development.
const depMap = {
@resistdesign
resistdesign / index.js
Last active December 9, 2016 03:57
JS DI Concept
// JSDI
class K{
handler;
constructor(handler){
this.handler = handler;
}
exec() {
@resistdesign
resistdesign / index.js
Created November 15, 2016 20:43
Collate Pages
function collate(pages = []){
const flats = [];
const { length } = pages;
const flatLength = Math.ceil(length/2);
const even = length % 2 === 0;
const newPages = [...pages];
if(!even){
const lastPage = newPages.pop();
@resistdesign
resistdesign / FluxDI.js
Last active June 16, 2016 06:42
A simple React Flux implementation with Dependency Injection for Components created by a React Router createElement handler.
import React, { Component } from 'react';
export default class FluxDI {
static validateContextName(name){
if(typeof name !== 'string'){
throw new Error('`name` must be a string.');
}
}
@resistdesign
resistdesign / index.js
Created April 21, 2016 05:22
Bindable Demo
function Bindable(ClassRef, onChangeMethodName){
class BindableClass{
constructor(...args){
const instance = new (ClassRef.bind(this))(...args);
for(const k in instance){
if(instance.hasOwnProperty(k)){
const initialValue = instance[k];
const privatePropertyName = `_${k}`;
instance[privatePropertyName] = initialValue;
@resistdesign
resistdesign / usb-switch.js
Last active January 19, 2020 00:16
(Belkin f1u201 / Staples 18799) USB Peripheral Switch Driver - NodeJS (0.12.x)
// Requires `node-usb` https://github.com/nonolith/node-usb
var usb = require('usb');
// Get the switch by its vendor and product ids.
var switchDevice = usb.findByIds(0x050D, 0x0201);
// Open the device for communication.
switchDevice.open();
// From the **inactive** computer, send the control trnasfer request with the value `[0x02, 0x00]` to trigger the switch.