View rectCollide.js
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 rectCollide() { | |
var nodes,sizes,masses; | |
var strength = 1; | |
var iterations = 1; | |
var nodeCenterX; | |
var nodeMass; | |
var nodeCenterY; | |
function force() { |
View albumYear.js
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
let yearAlbum = {}; | |
let yearCount = new Map(); | |
for (let i = 0; i < data.length; i++) { | |
for (let j = 0; j < data[i].bandAlbums.length; j++) { | |
if (!yearCount.has(data[i].bandAlbums[j].albumYear)) { | |
yearCount.set(`${data[i].bandAlbums[j].albumYear}`, 1) | |
} else { | |
yearCount.set(`${data[i].bandAlbums[j].albumYear}`, yearCount.get(`${data[i].bandAlbums[j].albumYear}`) + 1) | |
} |
View jsonToPostgres.js
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 knex = require('knex')({ | |
client: 'pg', | |
connection: 'postgresql://darklyricsuser:darklyricspassword@localhost/darklyrics', | |
}); | |
const fs = require('fs'); | |
const data = JSON.parse(fs.readFileSync('/Users/christina/Downloads/results(1).json', 'utf8')); | |
async function insertBand(band) { |
View createTables.js
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
/* | |
1st create database: | |
-go into the interactive interpreter | |
psql postgres | |
Here we're creating: | |
1. a databased called 'darklyrics' | |
2. a user 'darklyricsuser' | |
3. with password 'darklyricspassword' |
View d3_random_subsets.js
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
<!DOCTYPE html> | |
<head> | |
<meta charset="utf-8"> | |
<script src="https://d3js.org/d3.v6.min.js"></script> | |
</head> | |
<body> | |
<div id="chart"></div> | |
</body> |
View portuguese_stop_words
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
['a', | |
'ao', | |
'aos', | |
'aquela', | |
'aquelas', | |
'aquele', | |
'aqueles', | |
'aquilo', | |
'as', | |
'até', |
View english_stop_words
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
['a', | |
'about', | |
'above', | |
'after', | |
'again', | |
'against', | |
'ain', | |
'all', | |
'am', | |
'an', |
View wordCountExample.js
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
let words = ['cat','dog','mouse','rabbit','dog','dog','mouse','cat']; | |
let wordsSet = new Set(words) | |
let wordMap = new Map(); | |
for(word in words){ | |
let current = words[word]; | |
if (wordMap.has(current)){ | |
//is in the map, so get the current value and increment by one |
View gist:812bfe687e16dcce0188da753ae4ae22
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
let svg = d3.select('#chart') | |
.append('div') | |
.classed('svg-container', true) | |
.append('svg') | |
.attr("preserveAspectRatio", "xMinYMin meet") | |
.attr("viewBox", `0 0 ${width} ${height}`) | |
.classed('svg-content-responsive', true) | |
.append('g') | |
.attr('transform', `translate(${margin.left}, ${margin.top})`) |
View flattenJSON.js
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 flattenData(data){ | |
let flatData = []; | |
data.forEach(band => { | |
band.bandAlbums.forEach(album => { | |
album.albumSongs.forEach(song =>{ | |
flatData.push({bandName: band.bandName, | |
bandUrl: band.bandUrl, | |
albumName: album.albumName, | |
albumType: album.albumType, | |
albumYear: album.albumYear, |
NewerOlder