Skip to content

Instantly share code, notes, and snippets.

var h = require('virtual-dom/h');
var str = require('virtual-dom-stringify');
var http = require('http');
var fs = require('fs');
var ecstatic = require('ecstatic');
var st = ecstatic(__dirname);
var hyperstream = require('hyperstream');
var path = require('path');
var server = http.createServer(function (req, res) {
@mk30
mk30 / gist:6be3ee0f9ff7df4dbfa1
Created August 11, 2015 03:47
shader template
vec3 hsl2rgb(in float h, float s, float l) {
vec3 rgb = clamp( abs(mod(h*6.0+vec3(0.0,4.0,2.0),6.0)-3.0)-1.0, 0.0, 1.0);
return l + s * (rgb-0.5)*(1.0-abs(2.0*l-1.0));
}
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
float t = iGlobalTime;
vec2 uv = fragCoord.xy / iResolution.xy;
float x = uv.x, y = uv.y;
float h = 0.4 * t;
@mk30
mk30 / index.html
Created November 16, 2015 02:55
using webaudio to make a webpage make a sound
<script type="text/javascript">
var context = new AudioContext(),
oscillator = context.createOscillator();
oscillator.connect(context.destination);
oscillator.start(context.currentTime);
</script>
marina@lilserve:~$ top
top - 18:05:25 up 40 days, 14:29, 1 user, load average: 0.02, 0.27, 0.21
Tasks: 78 total, 1 running, 77 sleeping, 0 stopped, 0 zombie
%Cpu(s): 0.0 us, 0.0 sy, 0.0 ni,100.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
KiB Mem: 501792 total, 487360 used, 14432 free, 5188 buffers
KiB Swap: 1048572 total, 40 used, 1048532 free. 78992 cached Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
2340 marina 20 0 24816 1520 1112 R 0.3 0.3 0:00.03 top
var mesh = isosurface.surfaceNets([26,26,26],
function sdTorus(a, b) //a should be a vec3, b should be a vec2
{
c = [glvec2.length([a[0], a[2]])-b[0],a[1]];
return glvec2.length(c)-a[1];
}, [[-11,-11,-11], [11,11,11]])
module.exports = function (regl){
const drawcyl = regl({
frag: `
precision mediump float;
varying vec3 vnormal;
vec3 hsl2rgb(vec3 hsl) {
vec3 rgb = clamp( abs(mod(hsl.x*5.0+vec3(0.0,4.0,2.0),6.0)-3.0)-1.0, 0.0, 1.0 );
return hsl.z - hsl.y * (rgb-0.5)*(3.0-abs(2.0*hsl.y-1.0));
}
void main () {
const regl = require('regl')()
const vectorizeText = require('vectorize-text')
const mat4 = require('gl-mat4')
const glsl = require('glslify')
const textMesh = vectorizeText('thank you pauline oliveros', {
triangles: true,
width: 5,
textAlign: 'center',
textBaseline: 'middle'
})
if (prows) {
var phex = pals[state.palette].hex
for (var i = 0; i < phex.length; i += 10) {
prows.push(phex.slice(i,i+10))
}
}
function colors (onclick) {
var pkeys = Object.keys(state.paletteMap)
var prows = []
for (var i = 0; i < pkeys.length; i += 10) {
prows.push(pkeys.slice(i,i+10))
}
return html`<div class="colors">
${prows.map(function (row) {
return html`<div>
${row.map(function (src) {
download appropriate file from https://nodejs.org/en/download/
`tar -xf /name/of/file.tar.gz -C /usr/local/`
`export PATH=$PATH:node_dir/bin`
if in ubuntu: `sudo ln -s "$(which nodejs)" /usr/bin/node`