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
var express = require('express'); | |
var app = express(); | |
app.use(express.static('public')); | |
var http = require('http').Server(app); | |
var port = process.env.PORT || 3001; | |
// setup my socket server | |
var io = require('socket.io')(http); | |
io.on('connection', function(socket) { |
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
// setup my socket client | |
var socket = io(); | |
// read room in querystring | |
const queryString = window.location.search; | |
const urlParams = new URLSearchParams(queryString); | |
const room = urlParams.get('room'); | |
const generateRandomString = (length=6) => Math.random().toString(20).substr(2, length); |
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
var express = require('express'); | |
var app = express(); | |
app.use(express.static('public')); | |
var http = require('http').Server(app); | |
var port = process.env.PORT || 3001; | |
// setup my socket server | |
var io = require('socket.io')(http); | |
io.on('connection', function(socket) { |
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
var socket = io(); | |
const generateRandomString = (length=6) => Math.random().toString(20).substr(2, length); | |
window.onload = function () { | |
let userid = ""; | |
if (localStorage.getItem("userid")) { | |
userid = localStorage.getItem("userid"); | |
} else { | |
userid = generateRandomString(8); |
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
var express = require('express'); | |
var app = express(); | |
app.use(express.static('public')); | |
var http = require('http').Server(app); | |
var port = process.env.PORT || 3001; | |
var io = require('socket.io')(http); | |
io.on('connection', function(socket) { | |
console.log('new connection'); |
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
var socket = io(); | |
window.onclick = function(e) { | |
socket.emit('message', 'hello world'); | |
}; |
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
var express = require('express'); | |
var app = express(); | |
app.use(express.static('public')); | |
var http = require('http').Server(app); | |
var port = process.env.PORT || 3001; | |
app.get('/', function(req, res) { | |
res.sendFile(__dirname + '/public/default.html'); | |
}); |
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
# write to db | |
cursor = db.cursor() | |
sql = "INSERT INTO scrapes (name, screen_name, profile_image_url, description, statuses_count, friends_count, followers_count, account_age_days, average_tweets, most_mentioned_users, most_used_hashtags,processed_tweets, creation_date, creation_day) VALUES (%s, %s, %s, %s,%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)" | |
try: | |
cursor.execute(sql,(user_name, screen_name, profile_image_url, description, statuses_count, friends_count, followers_count, account_age_days, average_tweets, most_mentioned_users, most_used_hashtags, processed_tweets, creation_date, creation_day)) | |
db.commit() | |
except: | |
print(cursor._last_executed) | |
raise | |
db.rollback() |
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
hashtags = [] | |
mentions = [] | |
tweet_count = 0 | |
end_date = datetime.utcnow() - timedelta(days=365) | |
for status in tweepy.Cursor(api.user_timeline, id=target).items(): | |
tweet_count += 1 | |
if hasattr(status, "entities"): | |
entities = status.entities | |
if "hashtags" in entities: | |
for ent in entities["hashtags"]: |
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
if len(account_list) > 0: | |
for target in account_list: | |
item = api.get_user(target) | |
user_name = str(item.name) | |
screen_name = str(item.screen_name) | |
profile_image_url = str(item.profile_image_url) | |
description = str(item.description) | |
statuses_count = str(item.statuses_count) | |
friends_count = str(item.friends_count) | |
followers_count = str(item.followers_count) |
NewerOlder