Skip to content

Instantly share code, notes, and snippets.

View adispen's full-sized avatar

Aedan Dispenza adispen

View GitHub Profile
public static Stack<Vertex> bfs(String name, int i, Vertex[] friendGraph){
Stack<Vertex> friendStack = new Stack<Vertex>();
Queue<Neighbor> neighborQueue = new LinkedList<Neighbor>();
Neighbor l = null;
friendGraph[i].prev = -1;
do{
for(Neighbor j = friendGraph[i].neighborList; j != null; j = friendGraph[j.vertexNum].neighborList.next){
if(friendGraph[j.vertexNum].name.equals(name)){
for(int k = i; k != -1; k = friendGraph[k].prev){
friendStack.push(friendGraph[k]);
public Stack<Vertex> bfs(String name, int i, Vertex[] friendGraph){
Stack<Vertex> friendStack = new Stack<Vertex>();
Queue<Neighbor> neighborQueue = new LinkedList<Neighbor>();
Neighbor l = null;
friendGraph[i].prev = -1;
do{
for(Neighbor j = friendGraph[i].neighborList; j != null; j = j.next){
if(friendGraph[j.vertexNum].prev == -2){
neighborQueue.offer(j);
friendGraph[j.vertexNum].prev = i;
public static void shortestPath(Vertex[] friendGraph, String name1, String name2){
name1 = name1.toLowerCase();
name2 = name2.toLowerCase();
int n1Index = 0;
Stack<Vertex> friendStack = new Stack<Vertex>();
for(int j = 0; friendGraph[j].neighborList.next != null; j++){
System.out.println(friendGraph[j].name);
if(friendGraph[j].name.toLowerCase().equals(name1)){
n1Index = j;
}
@adispen
adispen / theaterviewers.js
Last active June 30, 2016 12:25
BTTV Theater Viewer Numbers
$("div.player-livestatus__online").text(function(){
return $(".live-count").text() + "Viewers";
})
$(".live-count").bind("DOMSubtreeModified", function(){
$("div.player-livestatus__online").text(function(){
return $(".live-count").text() + "Viewers";
})
})
db['streams'].aggregate([
{"$unwind":"$stats"},
{"$match":{"$and":[{"stats.rank":{"$lt":10}}, {"stats.time":{"$gt":"2016.06.25.07.00.42"}}]}},
{"$group":{"_id":{"stats":"$stats","name":"$name"}}},
{"$project":{"stats":"$_id.stats","name":"$_id.name","_id":0,"viewers":"$_id.stats.viewers","time":"$_id.stats.time"}},
{"$limit":10000}
])
var debug = require('../helpers/debug');
function checkBind() {
console.log('checking');
function checkBind() {
var isBound = false;
if ($('.live-count').length) {
$.each($('.live-count').data('events'), function (i) {
if (i === 'DOMSubtreeModified') {
isBound = true;
return;
}
});
}
#!/bin/bash
echo "Starting"
lockfile=/home/adispen/PokemonGo-Map-dev/lock/map.lock
function runMap {
pwd
python runserver.py -a -u -p -l "" -st 5 -H 0.0.0.0 -P 9001 &> /home/adispen/PokemonGo-Map-dev/logs/map1.log &
python runserver.py -a -u -p -l "" -st 5 -H 0.0.0.0 -P 9002 &> /home/adispen/PokemonGo-Map-dev/logs/map2.log &
@adispen
adispen / examples.js
Last active November 20, 2016 22:30
MongoProj Examples
// To find counts of days of the week use this
// getUTCDay returns a Day (0-6) see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date for more
// Examples: getUTCMonth for Months (0-11), getUTCHours (0-23)
db.gmail_data.mapReduce(
function() {
var dateDoc;
for( var i = 0; i < this.payload.headers.length; i++ ) {
var currDoc = this.payload.headers[i];
if (currDoc.name === 'Date') {
dateDoc = currDoc;
var request = require('request');
function callback(){
console.log('-------------------------------------------------------THIS ONE IS IN A CALLBACK');
}
function getJSON(callback) {
request('http://localhost/cinema.json', function(error, response, body) {
if(!error && response.statusCode == 200) {
console.log(body);