Skip to content

Instantly share code, notes, and snippets.

@jwerle
jwerle / .gitignore
Last active Mar 15, 2019
compile javascript and encrypt into native module - blah
View .gitignore
node_modules/
package-lock.json
plugin.c
plugin.node
View purism-ram-missing
josephwerle@werle:~/repos/termite$ sudo dmidecode -t 17 | grep "Size.*MB" | awk '{s+=$2} END {print s / 1024}'
4
josephwerle@werle:~/repos/termite$ awk '/MemTotal/ {print $2}' /proc/meminfo
3955724
josephwerle@werle:~/repos/termite$ free -g
total used free shared buff/cache available
Mem: 3 2 0 0 0 0
Swap: 8 0 7
View replicate-mirror-strategy.js
const mirrorFolder = require('mirror-folder')
const { keyPair } = require('hypercore/lib/crypto')
const hyperdrive = require('hyperdrive')
const assert = require('assert')
const pify = require('pify')
const ram = require('random-access-memory')
const seed = Buffer(32).fill('hello')
const { publicKey, secretKey } = keyPair(seed)
const a = hyperdrive(ram, publicKey, {sparse: false, sparseMetadata: false, secretKey})
@jwerle
jwerle / index.js
Created Aug 23, 2017
requirebin sketch
View index.js
const regl = require('regl')({
extensions: ['OES_texture_float'],
optionalExtensions: ['oes_texture_float_linear']
})
const framebuffer = regl.framebuffer({colorType: 'float', colorFormat: 'rgba'})
const framebufferCommand = regl({framebuffer})
let draw = regl({
@jwerle
jwerle / index.js
Last active Aug 18, 2017
requirebin sketch
View index.js
const { Material } = require('axis3d/material')
const { Context } = require('axis3d/core')
const { Frame } = require('axis3d/frame')
const { Mesh } = require('axis3d/mesh')
//const { TorusGeometry } = require('axis3d-geometry')
const ctx = new Context()
@jwerle
jwerle / index.js
Last active Jul 7, 2017
requirebin sketch
View index.js
// Welcome! require() some modules from npm (like you were using browserify)
// and then hit Run Code to run your code on the right side.
// Modules get downloaded from browserify-cdn and bundled in your browser.
const regl = require('regl')()
const draw = regl({
vert:`
precision mediump float;
attribute vec3 position;
void main() {
gl_Position = vec4(position, 1.0);
View SilentSwitchOverrider.h
#import <Foundation/Foundation.h>
@interface SilentSwitchOverrider : NSObject
@end
@jwerle
jwerle / ArrayPartitionFromPrefixMarkers.js
Created Jan 13, 2017
ArrayPartitionFromPrefixMarkers
View ArrayPartitionFromPrefixMarkers.js
function ArrayPartitionFromPrefixMarkers(array, start, stop) {
const partition = []
let inPartition = false
for (let i = 0; i < array.length; ++i) {
const element = array[i]
// test element for start prefix to determine
// if we should enter partition view
if (false == inPartition && start == element.substring(0, start.length)) {
inPartition = true
}
@jwerle
jwerle / index.js
Created Oct 2, 2016
requirebin sketch
View index.js
const quat = require('gl-quat')
const regl = require('regl')()
const model = require('regl-model')(regl)
const bunny = require('regl-primitive')(regl, require('bunny'))
const camera = require('regl-camera')(regl, {distance: 40})
const material = regl({
vert: `
precision mediump float;
attribute vec3 position, normal;
uniform mat4 projection, model, view;
View gen-promise-foo.js
'use strict'
let co = require('co')
function * list (array, subdivision) {
let deferred = Promise.defer()
let marker = 0;
let stop = marker + subdivision
let max = A.length
let to = Math.random() * 1000 | 0