Skip to content

Instantly share code, notes, and snippets.

Avatar
👽
I see the matrix

polyclick polyclick

👽
I see the matrix
View GitHub Profile
@polyclick
polyclick / _1_scraping.js
Last active Apr 16, 2022
Scraping & reading Versum pixel data
View _1_scraping.js
// Fetches minted tokens from Versum, starting from the most recent -> older
//
// You can try this out in a REST app or curl'ing by calling a GET to
// https://versum.xyz/api/public/feed?offset=0&limit=10&maxtime=1649840640000
// Returns a json object with the token data, creator wallet & info, and urls to the images on IPFS
// Use query string params 'offset' and 'limit' to paginate data
//...
@polyclick
polyclick / background-cover.frag
Created Feb 20, 2019
map uv coordinates to do a background-position: cover in screen space
View background-cover.frag
vec2 backgroundCoverUV(vec2 uv, vec2 resolution, vec2 texResolution) {
vec2 s = resolution;
vec2 i = texResolution;
float rs = s.x / s.y;
float ri = i.x / i.y;
vec2 new = rs < ri ? vec2(i.x * s.y / i.y, s.y) : vec2(s.x, i.y * s.x / i.x);
vec2 offset = (rs < ri ? vec2((new.x - s.x) / 2.0, 0.0) : vec2(0.0, (new.y - s.y) / 2.0)) / new;
return uv * s / new + offset;
}
View globalgoals-snippet-paint.js
// difference between current and previous cursor position & distance
this.delta = pk.Vector.sub(this.lerped, this.plerped)
this.distance = this.delta.mag()
// paint repeatedly by interpolating the bristle’s stamp position over the course of distance
// then stamp the bristles texture onto the final render target by copying its pixels
let numDraws = this.distance || 1
for (let i = 0; i < numDraws; i++) {
let ipos = pk.Vector.lerp(this.plerped, this.lerped, i / numDraws)
this.bristles.position = new PIXI.Point(ipos.x, ipos.y)
View synesthesia-snippet-fragment-shader.glsl
#ifdef GL_ES
precision lowp float;
#endif
#define TWO_PI 6.28318530718
uniform sampler2D videoTexture;
varying vec2 vUv;
uniform vec3 colorA;
View synesthesia-snippet-server.js
var http = require('http')
var fs = require('fs')
var socket = require('socket.io')
var midi = require('midi')
var app = http.createServer()
var io = socket(app)
app.listen(5000)
View synesthesia-snippet-openframeworks.cpp
float timeDiff = ofGetElapsedTimef() - lastPitchChangeTime;
if(roundedCurrPitch != roundedPrevPitch && pitchConfidence > minimumConf && timeDiff > pitchRelease) {
// first, send [off note] for previous note
midiOut.sendNoteOff(channel, roundedPrevPitch);
// send current note value over midi
// scale the ascii values to midi velocity range 0-127
// see an ascii table: http://www.asciitable.com/
View svg-bg-image
background-image: url('data:image/svg+xml;utf8,<svg></svg>');
@polyclick
polyclick / .eslintrc
Created Sep 28, 2015
.eslintrc configuration
View .eslintrc
{
// http://eslint.org/docs/rules/
"parser": "babel-eslint",
"env": {
"browser": true, // browser global variables.
"node": true, // Node.js global variables and Node.js-specific rules.
"worker": false, // web workers global variables.
"amd": false, // defines require() and define() as global variables as per the amd spec.
View jquery-click-handler.js
this.$button.click(function(event){
event.preventDefault();
var $target = $(event.currentTarget);
// do stuff with target
}.bind(this));
View jquery-fastclick.js
// jquery fastclick integration
$(function() {
FastClick.attach(document.body);
});