Skip to content

Instantly share code, notes, and snippets.

View jazzyjackson's full-sized avatar

Colten Jackson jazzyjackson

View GitHub Profile
// creates a readable stream from a figtree - a configuration graph in JSON
// continuous stream that allows the browser to start painting ASAP
// but retains original file format
//but by the time this code calls babel, the style and graph will have already been served, so it will be a subtle delay between page loading and page becoming active
/* an example figtree */
{
"styles":["blocks/basic/style.css","blocks/convo/style.css"],
"scripts":["utils.js","vanillaClickAndDrag.js","blocks/basic/class.js","blocks/convo/class.js"],
makeStrongTagsClickable(){
/**** Get the set of strong tags that chatbot returned, create a function
* with a reference to those particular strong tags, put a reference
* to that function in an event listener. destroy strong tags when you click one. ****/
var strongTags = this.body.querySelectorAll('strong')
var destroyStrongTags = () => Array.from(strongTags, strongTag => {
var spanFromStrong = document.createElement('span')
spanFromStrong.textContent = strongTag.textContent
strongTag.parentElement.replaceChild(spanFromStrong, strongTag)
})
consumeStream(reader, contentType = 'application/json'){
if(!reader) return null // consumeStream will exit if the text was consumed already
this.streambuffer || (this.streambuffer = '') //if streambuffer is undefined, create it
/* recursively call consumeStream. reader.read() is a promise that resolves as soon as a chunk of data is available */
return reader.read().then(sample => {
if(sample.value){
this.streambuffer += textDecoder.decode(sample.value)
console.log(this.streambuffer)
// if the last character of a chunk of data is a closing bracket, parse the JSON. Otherwise, keep consuming stream until it hits a closing bracket.
// this leaves the very unfortunate possible bug of a chunk of data coming in with an escaped bracket at the end, and to detect this condition we'd have to pay attention to opening and closing quotes, except for escaped qutoes
concept: ~genre [ "acoustic" "afrobeat" "alt-rock" "alternative" "ambient" "anime" "black-metal" "bluegrass" "blues" "bossanova" "brazil" "breakbeat" "british" "cantopop" "chicago-house" "children" "chill" "classical" "club" "comedy" "country" "dance" "dancehall" "death-metal" "deep-house" "detroit-techno" "disco" "disney" "drum-and-bass" "dub" "dubstep" "edm" "electro" "electronic" "emo" "folk" "forro" "french" "funk" "garage" "german" "gospel" "goth" "grindcore" "groove" "grunge" "guitar" "happy" "hard-rock" "hardcore" "hardstyle" "heavy-metal" "hip-hop" "holidays" "honky-tonk" "house" "idm" "indian" "indie" "indie-pop" "industrial" "iranian" "j-dance" "j-idol" "j-pop" "j-rock" "jazz" "k-pop" "kids" "latin" "latino" "malay" "mandopop" "metal" "metal-misc" "metalcore" "minimal-techno" "movies" "mpb" "new-age" "new-release" "opera" "pagode" "party" "philippines-opm" "piano" "pop" "pop-film" "post-dubstep" "power-pop" "progressive-house" "psych-rock" "punk" "punk-rock" "r-n-b" "rainy-day" "reggae" "reggaeton"
request.url.split('?')[0].includes('.svg') && response.setHeader('Content-Type','image/svg+xml')
request.url.split('?')[0].includes('.css') && response.setHeader('Content-Type','text/css')
const mysql = require('mysql')
const config = ini.parse(fs.readFileSync('../credentials.ini', 'utf-8')) /* only happens once on server start */
const db = mysql.createPool(config.labsdb)
tryMySQL(input){
return new Promise((resolve, reject) => {
if(!input.mysql) return resolve(input)
db.getConnection((err, conn) => {
if(err) reject({dbError: err})
## For Python 2
# import codecs
# from future.utils.surrogateescape import register_surrogateescape
# register_surrogateescape()
## Python 2 doesn't have an errors parameter in its global 'open' method, so, import codecs and use codecs.open
# with codecs.open('./youtube_quils_results.csv','r', encoding="utf-8", errors="surrogateescape") as the_file:
with open('./youtube_quils_results.csv','r', encoding="utf-8", errors="surrogateescape") as the_file:
original = pandas.read_csv(the_file, iterator=True, encoding="utf-8")
unsafe_set = set(pandas.read_csv('unsafe_list.csv', header=None, squeeze=True))
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Controller : MonoBehaviour
{
public string selection;
// Use this for initialization
void Awake()
#!/usr/local/bin/node
var net = require('net')
var util = require('util')
var os = require('os')
var port = process.env.CSPORT || 1024
var host = process.env.CSHOST || 'localhost'
var identity = process.env.USER || 'unknown' /* not to be confused with 'nobody' */
var botname = process.env.BOT || 'harry'
pkg install node
pkg install www/npm
pkg install git
git clone https://github.com/jazzyjackson/MIXINTvNegative3.git
cd MIXINT
npm install