Skip to content

Instantly share code, notes, and snippets.

View 5nyper's full-sized avatar
☪️
Focusing

Snyper 5nyper

☪️
Focusing
View GitHub Profile
@5nyper
5nyper / DFS.py
Last active December 13, 2017 04:52
Extra Credit
#Depth First Search
from collections import OrderedDict
class priorityQueue:
def __init__(self):
self.heap=OrderedDict()
self.size = 0
def __len__(self):
@5nyper
5nyper / calc.py
Last active September 26, 2017 15:49
not a 0
### HW1 due 9/18(mon)
# Read "HW1 instruction and notes.docx"
# posted on canvas very carefully.
# Complete the five functions to upload
# them to Vocareum by the due date.
import time
def isNumber(s):
#s must be a non-empty string
@5nyper
5nyper / MAZE.py
Created June 10, 2017 05:59
Python
from socket import create_connection
MAZE_SERVER = ('54.69.145.229', 16000)
RECV_SIZE = 8192
def main():
conn = create_connection(MAZE_SERVER)
response = conn.recv(RECV_SIZE)
while True:
@5nyper
5nyper / irc.c
Last active June 9, 2017 05:18
irc
#include <stdio.h>
#include <sys/socket.h>
#include <arpa/inet.h> //inet_addr
#include <string.h>
#include <stdarg.h>
int sock;
char server_reply[512];
{
"pagination":{
"next_url":"https://api.instagram.com/v1/users/30442728/media/recent?access_token=30442728.c3a57bb.1061d7f198b94483be98990c04cb6b53\u0026max_id=1322116412118752986_30442728",
"next_max_id":"1322116412118752986_30442728"
},
"meta":{
"code":200
},
"data":[
{
{ data:
[ { likes: 1057, day: 1480541883 },
{ likes: 1037, day: 1479774405 },
{ likes: 837, day: 1479344298 },
{ likes: 1023, day: 1479087523 },
{ likes: 1092, day: 1478829766 },
{ likes: 1320, day: 1478653189 },
{ likes: 1018, day: 1478477061 },
{ likes: 47
"use strict"
var twit = require("twit");
var Promise = require('bluebird')
var file = Promise.promisifyAll(require('fs-extra'));
var request = Promise.promisify(require('request'));
var bodyParser = require('body-parser');
var hour = (60 * 1000)
setInterval(checkTime, hour)
@5nyper
5nyper / sync.js
Created October 29, 2016 03:40
undefined after async fn
function updateUsers() {
console.log("Updating User Data Across Server!")
var date = new Date();
var users = file.readdirSync('users/')
for (var i = 0; i<users.length; i++) {
var links = file.readdirSync('users/' + users[i])
for (var k = 0; k<links.length; k++) {
var files = file.readdirSync('users/' + users[i] + '/' + links[k])
if (files == "instagram.json") {
var data = file.readFileSync('users/' + users[i] + '/' + links[k] + '/instagram.json', "utf-8")
function createInsta(email, userid) {
var exits = fs.existsAsync('users/' + email + '/' + userid).then(function(exists) {
var mkdir = fs.mkdirAsync('users/' + email + '/' + userid).catch(function(error) {
console.log(error)
})
var readData = fs.readFileAsync("data/data.json", "utf-8").then(function(contents) {
var writeNew = fs.writeFileAsync('users/' + email + '/' + userid + '/instagram.json', contents).then(() => {
initInsta(email, userid)
}).catch(function(error) {
function createInsta(email, userid, cb) {
ensureExists(function (error) {
if (error) return cb(error);
getData(function (error) {
if (error) return cb(error);
});
});