Skip to content

Instantly share code, notes, and snippets.

View cliffhall's full-sized avatar
💥
Technology pivot appearing onscreen now, captain.

Cliff Hall cliffhall

💥
Technology pivot appearing onscreen now, captain.
View GitHub Profile
const { nameToId } = require('fismo/sdk/node');
//--------------------------------------------------------------------------------------------------------------------
// Machine metadata definitions
//
// Plain JS object with the following properties:
//
// name - machine name as installed in Fismo. (required)
// id - machine id (required)
// title - short text title of the machine or project (optional)
//--------------------------------------------------------------------------------------------------------------------
// Machine definitions
//
// Plain JS object with the following properties:
//
// name - machine name. begin with letter, no spaces, a-z, A-Z, 0-9, and _
// initialStateId - keccak256 hash of initial state name
// uri - off-chain URI of metadata describing the machine
// states - an array of plain objects representing State entities
//
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity ^0.8.0;
/**
* @notice KeyToken is the Fismo Lab ERC-20, and we only check for a balance
*/
interface KeyToken {
function balanceOf(address account) external view returns (uint256);
}
@cliffhall
cliffhall / FundsHandlerRegistry.sol
Last active March 9, 2022 06:28
A factory/registry for deploying cheap, minimal clones of royalty funds handler logic and retrieving those clones by token address and id
pragma solidity 0.8.4;
import "@openzeppelin/contracts/proxy/Clones.sol";
import "./IFundsHandler.sol"; // Multiple funds receiver/splitter logic implementations can exist
contract FundsHandlerRegistry {
// Available IFundsHandler implementations
mapping(string => address) handlers;
@cliffhall
cliffhall / cordwood.js
Last active August 1, 2022 20:56
Extract substrings of predetermined a length, along with any remainder.
/**
* String.cordwood
*
* Add a String prototype method to split string into an array of
* substrings of a given length, along with any remainder.
*
* Example usage:
* let paragraph = 'The quick brown fox jumps over the lazy dog. It barked.';
* let stack = paragraph.cordwood(10)
* console.log(stack)

The Sinewav3 Plugin example 'Sparks Fly' creates a particle system simulating sparks which dim as they age, while moving in a realistic fashion.

A number of settings are exposed for the particle system emitter and its movement as well as the protoypical spark particle and its movement. The code demonstrates the use of audio modulation and easing.

Learn more about this plugin here: https://medium.com/sinewav3/make-sparks-fly-c48e94219d4f

@cliffhall
cliffhall / a-simple-sinewav3-plugin-example.md
Last active April 17, 2018 16:03
Sinewav3 Plugin Example 'Tentacles'
@cliffhall
cliffhall / index.js
Last active November 29, 2018 11:53
Using Firebase Cloud Functions to Manage a Compound Key Index
/**
* Function: indexArtist
*
* Triggered by writes to: /artists/:id
* Responds by writing to: /indexes/artist_by_genre (once for each Genre the Artist has chosen)
*
* If there was a previous value, all associated index entries are removed first.
* So, if the artist display name has changed or the genre list has changed,
* the index will be properly synchronized.
*
@cliffhall
cliffhall / nuke-firebase-db-and-users-referenced-therein.js
Last active September 24, 2018 22:15
Nuke a Firebase Database and All User Accounts Referenced Therein
// NOTE: Accounts that are not represented in your /users node will not be deleted!
// BLOG: There are other approaches, see: http://cliffordhall.com/2017/04/nuke-firebase-db-and-all-users/
"use strict";
// Get credentials and initialize firebase app
console.log("With the power vested in the admin user, lay waste the database and all its users!");
let admin = require("firebase-admin");
let serviceAccount = require([__dirname, "service-account-key.json"].join('/'));
admin.initializeApp({
credential: admin.credential.cert(serviceAccount),

This demo builds on previous gists in this series to render an audio-modulated WebGL animation, and output a 48 FPS, 1080p, HD video utilizing:

  • HTML5's Web Audio API for analysing an audio file.
  • HTML5's Web Worker API for offloading communications between the web page and the server to separate thread.
  • Socket.io for sending messages (including image and audio files) between client and server.
  • Node.js for the server process for storing generated images and uploaded audio and creating the final video.
  • FFMpeg for the actual video creation.
  • Fluent-ffmpeg for making the configuration and execution of FFMpeg commands easy peasy.
  • @ffmpeg-installer/ffmpeg for installing the correct version of FFMpeg for the hardware this demo runs on.
  • mkdirp for creating the folder path for each client's data, including any missing nodes in the path.