Skip to content

Instantly share code, notes, and snippets.

View joshstovall's full-sized avatar
😎
coding

Josh Stovall joshstovall

😎
coding
View GitHub Profile
var handles = {
"AMZN":"jeffbezos",
"TSLA":"elonmusk",
"MSFT":"Microsoft",
"FB":"Facebook"
}
function sentimentAnalysis() {
var tweets = JSON.parse(body).statuses
tweets = JSON.parse(body).statuses.map(function (e) {
// clean tweet
var tweet = clean(e.text)
// sentiment analysis
var result = new Sentiment().analyze(tweet, {
extras: words
const fs = require('fs')
const request = require('request')
const Sentiment = require('sentiment')
function formatQuery(e) {
return '$' + e + handles[e] ? ' @' + e[e] : ""
}
var custom = {
'yas':3,
'bruh':-1,
'🚀': 5,
'🔥': 3,
'💩': -2
}
function cleanTweet(e){
return e.text
.replace(/\n|\r/g, "")
.replace(/(?:https?|ftp):\/\/[\n\S]+/g, '') // remove URLs
.replace(/\@[^\s]*/g, "") // remove @ mentions
.replace(/\$[^\s]*/g, "") // remove $ cashtags
.replace(/\#[^\s]*/g, "") // remove # hashtags
.replace('RT', '') // replace RT in retweet tweets
.replace('NEW', '')
.replace('// // ', '')
function getTweets(symbol) {
request({
url: 'https://api.twitter.com/1.1/search/tweets.json?q=' + formatQuery(symbol),
headers: { 'Authorization': 'Bearer ' + TWITTER_API_KEY }
}, sentimentAnalysis)
}
@joshstovall
joshstovall / midi.js
Created September 10, 2021 07:45
midi.js
// pianos
var leftMIDI = JZZ.input.Kbd({at:'leftMIDI' , from:'C5', to:'B5', onCreate:function() {}});
var rightMIDI = JZZ.input.Kbd({at:'rightMIDI', from:'C5', to:'B5', onCreate:function() {}});
var synth = JZZ.synth.Tiny();
rightMIDI.connect(synth);
leftMIDI.connect(synth);
// midi out
var midi_out = JZZ.gui.SelectMidiOut({ at: 'midi_out' });
function getMicrophone() {
}
@joshstovall
joshstovall / ratio.js
Created September 10, 2021 07:32
pythagorean tuning ratios
// pythagorean tuning ratios
var ratio = [
1/1, // unision
256/243, // minor second
9/8, // major second
32/27, // minor third
81/64, // major third
4/3, // perfect fourth
729/512, // tritone
3/2, // perfect fifth