Skip to content

Instantly share code, notes, and snippets.

View autonome's full-sized avatar

Dietrich Ayala autonome

View GitHub Profile
@tophtucker
tophtucker / README.md
Last active April 22, 2024 16:01
Beginning to reverse-engineer FizzyText

TOTALLY SUPER DUPER NOT MY WORK! Trying to illuminate how FizzyText (seen here, source here, isolated from dat.GUI dependency here) works. Original appears to have been written by George Michael Brower.

In the original, which I find brilliant:

  • Solid black text is drawn onto an invisible canvas, from which it gets bitmap data
  • The bitmap data is read like a collision detection array, where black means "you're on top of text" and white means "you're not"
  • Particles of size r=0 are randomly spawned on a visible canvas
  • The particles grow if they're on top of a (non-rendered) black pixel, and shrink till they disappear if not
  • When they shrink to r=0, they respawn randomly somewhere
  • The particles follow a Perlin noise flow field, a very sensible and fluid kind of random movement, in which nearby particles
@marcoscaceres
marcoscaceres / implementing WebIDL in js.markdown
Last active March 8, 2021 09:02
Implementing a JS-based WebIDL binding in Gecko

DEPRECATED

I think most of this stuff is now depracted. Looks like C++ is the only realistic way to go for implementing WebIDL bindings in Gecko. That's unfortuante, because if you are a JS dev, learning C++ can be challenging (though worth while! it's a fun language.)

Implementing a JS-based WebIDL binding in Gecko

This provides a gentle introduction to implementing a WebIDL interface in JavaScript. Once you are done, you can refer to the MDN Wiki, to add more advanced things.

Before you start

We would encourage you to first build a simple prototype version of your API in JS. Going through the process of creating a WebIDL is fairly straight forward, but if you screw it up you will need to recreate a whole bunch of files, etc. As such, it's much easier to make sure you have your API in a good state before attempting the steps below.

@liamato
liamato / decodeHtmlEntities.js
Created October 29, 2015 22:14
decodeHtmlEntities.js
/**
* Decodes html entities by name and number
*/
var decodeHtmlEntities = function(str) {
return str.replace(/&#?(\w+);/g, function(match, dec) {
if(isNaN(dec)) {
chars = {quot: 34, amp: 38, lt: 60, gt: 62, nbsp: 160, copy: 169, reg: 174, deg: 176, frasl: 47, trade: 8482, euro: 8364, Agrave: 192, Aacute: 193, Acirc: 194, Atilde: 195, Auml: 196, Aring: 197, AElig: 198, Ccedil: 199, Egrave: 200, Eacute: 201, Ecirc: 202, Euml: 203, Igrave: 204, Iacute: 205, Icirc: 206, Iuml: 207, ETH: 208, Ntilde: 209, Ograve: 210, Oacute: 211, Ocirc: 212, Otilde: 213, Ouml: 214, times: 215, Oslash: 216, Ugrave: 217, Uacute: 218, Ucirc: 219, Uuml: 220, Yacute: 221, THORN: 222, szlig: 223, agrave: 224, aacute: 225, acirc: 226, atilde: 227, auml: 228, aring: 229, aelig: 230, ccedil: 231, egrave: 232, eacute: 233, ecirc: 234, euml: 235, igrave: 236, iacute: 237, icirc: 238, iuml: 239, eth: 240, ntilde: 241, ograve: 242, oacute: 243, ocirc: 244, otilde: 245, ouml: 246, divide: 247, oslash: 248, ugrave: 249
@shiffman
shiffman / sketch1.js
Created September 15, 2015 20:02
10PRINT in p5.js
// 10print.org
// Animated version of 10 print.
var x = 0;
var y = 0;
function setup() {
createCanvas(640, 360);
background(255);
}
@janjongboom
janjongboom / uribeacon.js
Created August 10, 2015 12:20
Scan Uri Beacons with Web Bluetooth
navigator.mozBluetooth.defaultAdapter.startLeScan([]).then(handle => {
console.log('Start scanning', handle);
handle.ondevicefound = e=> {
var uri = parseUriBeacon(e.scanRecord);
if (uri) {
return console.log('Found UriBeacon', uri);
}
}
@goebish
goebish / CX10_nRF24.ino
Last active January 20, 2019 20:20
nRF24 CX-10 Tx Code (green & blue boards)
/*************************************************************
************* nRF24 Cheerson CX-10 Tx Code ******************
************* (Green & Blue boards) ******************
**************************************************************
by goebish on RCgroups.com
Thanks to:
PhracturedBlue, victzh, hexfet, closedsink, midelic, Hasi ...
@janjongboom
janjongboom / ibeacon.js
Created May 18, 2015 12:42
iBeacon scanning Firefox OS
navigator.mozBluetooth.defaultAdapter.startLeScan([]).then(handle => {
console.log('Start scanning', handle);
handle.ondevicefound = e=> {
var record = parseScanRecord(e.scanRecord);
if (record) {
console.log('Found an iBeacon', record.uuid, record.major, record.minor, e.rssi);
}
}
setTimeout(() => {
@janjongboom
janjongboom / gist:94d575526a689687a6b8
Last active February 24, 2023 14:40
Firefox OS / JanOS on Raspberry Pi with GPIO support

This does NOT work on Raspberry Pi 2!

  1. Obtain a 8GB (or bigger) SD Card
  2. Download disk image from http://janos.io/builds/fxos-pi-gpio.img.zip and unzip
  3. Put SD card in your computer
  4. Find out where your SD card is mounted (BE REALLY SURE ITS THE RIGHT DEVICE, IT WILL BE WIPED COMPLETELY!!!), f.e. /dev/disk5 on OSX
  5. On Linux, run: sudo dd bs=4M if=fxos-pi-gpio.img of=/path/to/your/disk
  6. On OSX, run: sudo dd bs=4m if=fxos-pi-gpio.img of=/dev/rdisk5 (do rdisk, not disk here!)
  7. When it's done put it in your Pi and start up
  8. The demo's are wired like this: yellow LED on GPIO2, red LED on GPIO3, button (wire it as pulldown) on GPIO26.
@justindarc
justindarc / enable_wifi_direct.sh
Last active September 4, 2018 20:08
enable_wifi_direct.sh
#!/bin/sh
adb shell "mount -o rw,remount /system"
adb shell "stop b2g"
adb shell "echo \"ro.moz.wifi.p2p_supported=1\" >> /system/build.prop"
adb shell "mount -o ro,remount /system"
adb reboot
@tauzen
tauzen / app.js
Last active August 29, 2015 14:07
FirefoxOS tag writing example, requires NFC capable device running FirefoxOS 2.1. App needs to be certified! Privileged APIs comming soon!
window.addEventListener('DOMContentLoaded', function() {
'use strict';
console.log('DOMContentLoaded, checking for NFC');
if (!navigator.mozNfc) {
console.log('NFC not available');
return;
}
navigator.mozSetMessageHandler('activity', (activity) => {