This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function createUpdatePos({clientX, clientY}){ //this is a function creator. When a mouse/touchdown event occurs, the initial position | |
var theLastX = clientX //is enclosed in a function, those variables are updated on mousemove and will persist | |
var theLastY = clientY //as long as the function exists. On touch/mouseup events, the function is destroyed (the variable it was assigned to is reassigned null) | |
return function({clientX, clientY, buttons}){ | |
var movementX = clientX - theLastX | |
var movementY = clientY - theLastY | |
theLastX = clientX | |
theLastY = clientY | |
var currentXpos = parseInt(document.activeElement.style.left) | |
var currentYpos = parseInt(document.activeElement.style.top) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## 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)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
public class Controller : MonoBehaviour | |
{ | |
public string selection; | |
// Use this for initialization | |
void Awake() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pkg install node | |
pkg install www/npm | |
pkg install git | |
git clone https://github.com/jazzyjackson/MIXINTvNegative3.git | |
cd MIXINT | |
npm install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
map((octet, index) => octet * Math.pow(256, 3 - index)) |