This file contains hidden or 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
| d3.json("nhl.json", function(json) { | |
| d3.select("body") | |
| .selectAll("img") | |
| .data(json.items) | |
| .enter() | |
| .append("img") | |
| .attr("class", "nhl") | |
| .attr("src", function (d) {return d.media.m}); | |
| }); |
This file contains hidden or 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
| // Spinning Curve | |
| // | |
| // p.js | |
| /* @pjs pauseOnBlur="true"; */ | |
| void setup() { | |
| size(600, 600); | |
| smooth(); | |
| frameRate(15); |
This file contains hidden or 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
| // Mouse Cursor | |
| // | |
| // p.js | |
| /* @pjs pauseOnBlur="true"; */ | |
| int circleX, circleY; | |
| int circleSize = 200; | |
| float mouseHoverDist; | |
| int numClicks = 0; |
This file contains hidden or 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
| float t_random[numLeds]; // random timer | |
| float t_reset[numLeds]; // reset timer | |
| if (millis() - t_random[i] > t_reset[i]) { // when you've surpassed a random time for an LED | |
| toggle_led[i]; // turn it on | |
| t_reset[i] = millis(); // make the reset time the current time | |
| t_random[i] = random(bottomRange, topRange); // create a new random timer value for that LED | |
| } |
This file contains hidden or 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
| // check position of rocker function | |
| // t = top pin connection to switch | |
| // b = bottom pin connection to switch | |
| int checkRocker(int t, int b) { | |
| int top = digitalRead(t); | |
| int bottom = digitalRead(b); | |
| if (top == LOW && bottom == HIGH) return 0; // top position | |
| else if (top == HIGH && bottom == HIGH) return 1; // middle position | |
| else if (top == HIGH && bottom == LOW) return 2; // low position | |
| } |
This file contains hidden or 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
| String barcode = ""; | |
| void setup() {} | |
| void draw() {} | |
| void keyPressed() { | |
| barcode+=key; | |
| if (key == '\n') { // we've reached the end of the barcode | |
| println(barcode); |
This file contains hidden or 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 int numLeds = 4; | |
| const int pins[] = { | |
| 2, 3, 4, 5}; | |
| long t_random[numLeds]; | |
| long t_reset[numLeds]; | |
| long top_range = 2000; | |
| long bottom_range = 100; | |
| int previous_led_state[numLeds]; | |
| int led_state[numLeds]; |
This file contains hidden or 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/bin/python | |
| # get a list of androgynous names and write it to a .txt file | |
| # requires BeautifulSoup library | |
| # imports | |
| from bs4 import BeautifulSoup | |
| import urllib2 | |
| import sys | |
| import os |
This file contains hidden or 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
| /* | |
| Serial Event example | |
| When new serial data arrives, this sketch adds it to a String. | |
| When a newline is received, the loop prints the string and | |
| clears it. | |
| A good test for this is to try it with a GPS receiver | |
| that sends out NMEA 0183 sentences. | |
This file contains hidden or 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
| class Asteroid { | |
| PVector location; | |
| PVector velocity; | |
| PVector acceleration; | |
| float mass; | |
| String tweet; | |
| float x, y, w, h; | |
| boolean hit; | |
| boolean dead; | |
| float hitTime, textTime; |