Skip to content

Instantly share code, notes, and snippets.

View patricoferris's full-sized avatar
🌳

Patrick Ferris patricoferris

🌳
View GitHub Profile
function Particle(x, y, color){
this.pos = createVector(x + random(-10, 10), y + random(-10, 10));
this.vel = createVector(floor(random(-1, 1))*noise(this.pos.x), -noise(this.pos.y)*7);
this.alpha = 255;
this.r = random(170, 255);
this.g = random(10, 255);
this.b = random(0, 100);
this.update = function(){
this.pos.add(this.vel);
var touch = false;
function setup(){
createCanvas(640, 640);
}
function draw(){
if(touch){
fill(255, 0, 0);
rect(mouseX, mouseY, 20, 20);
@patricoferris
patricoferris / index.html
Last active February 23, 2018 19:35
This is a simple setup of a p5 project - an index.html file to get the libraries and a JavaScript file to start creating
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.5.11/p5.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.5.11/addons/p5.dom.min.js"></script>
</head>
<body>
<script src="template.js"></script>
</body>
</html>
let critical = require('critical');
critical.generate({
base: 'test/',
src: 'index.html',
dest: 'styles/main.css',
dimensions: [{
height: 200,
width: 500
}, {
@patricoferris
patricoferris / mq.css
Created July 21, 2018 09:30
Media Queries for Image Optimisation
@media only screen and (min-width: 600px) {
background-image: url('supercoolimages/dog-small.png');
}
@media only screen and (min-width: 992px) {
background-image: url('supercoolimages/dog-big.png');
}
let todos = {
todoArray: [
{
todo: 'Learn more ReactJS, GatbsyJS and Meteor',
timeFrame: 'As long as is needed',
priority: 'HIGH',
tag: 'Web Development'
},
{
todo: 'Deep dive into Tensorflow and Machine Learning',
@patricoferris
patricoferris / uncompressed.js
Last active July 28, 2018 10:57
An example of minifying JavaScript
//Normal JavaScript Code
const arr = [1, 2, 3, 4, 5];
for(let i = 0; i < arr.length; i++){
console.log(arr[i]);
}
//Minified Code - A 22.83% Compression saving 0.02kB
const arr=[1,2,3,4,5];for(let a=0;a<arr.length;a++)console.log(arr[a]);
# Connecting to the Kaggle Pitchfork Database
import sqlite3 as sql
import numpy as np
db = sql.connect('../../data/pitchfork.sqlite')
cursor = db.cursor()
artist_dict = {}
artist_lookup = {}
genres = {}
genre_lookup = {}
scores = {}
cursor.execute('select distinct genre from genres')
for row in cursor:
genre_lookup[len(genre_lookup)] = row[0]
genres[row[0]] = []
for i in range(11):
scores[i] = []