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
from sklearn.feature_extraction.text import CountVectorizer | |
import numpy as np | |
import pandas as pd | |
import scipy as sp | |
posts = pd.read_csv('posts.csv') | |
# Create vectorizer for function to use | |
vectorizer = CountVectorizer(binary=False) | |
y = posts["score"].values.astype(np.float32) |
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
'use strict'; | |
function attributeIterator(node, extractorFunction) { | |
var selector = ''; | |
var attributes = node.attributes; | |
for (var i = 0; i < attributes.length; i++) { | |
var attr = attributes[i]; | |
var attrSelector = extractorFunction(attr); | |
if (attrSelector) { | |
selector += attrSelector; |
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
from functools import wraps | |
import time | |
import inspect | |
def timing(f): | |
@wraps(f) | |
def wrapper(*args, **kwargs): | |
module = inspect.getmodule(f).__name__ | |
start = time.time() | |
result = f(*args, **kwargs) |
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
const port = process.argv[2] || 7979 | |
const targetPort = process.argv[3] || 5000 | |
const path = process.argv[4] || 'client' | |
const express = require('express') | |
const proxy = require('http-proxy-middleware') | |
const app = express() | |
app.use(express.static(path)) | |
app.use('/services', proxy({target: `http://0.0.0.0:${targetPort}`, changeOrigin: true})) | |
app.listen(port, () => console.log(`Listening at http://localhost:${port}`)) |
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
function getAccumulatedList(list) { | |
let accumulatedList = [] | |
list.reduce((accumulator, item) => { | |
accumulatedList.push(accumulator) | |
return item + accumulator | |
}, 0) | |
return list.reduce((accumulator, item) => { | |
accumulator.count = item + accumulator.count | |
accumulator.acclist.push(accumulator.count) | |
return accumulator |
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
import time | |
import threading | |
import datetime | |
class Scheduler(object): | |
def __init__(self, hours, job): | |
self.interval = datetime.timedelta(hours=hours).seconds | |
self.job = job | |
thread = threading.Thread(target=self.run, args=()) | |
thread.daemon = True |
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
import ast | |
from Crypto.Cipher import PKCS1_OAEP | |
from Crypto.PublicKey import RSA | |
with open('cert/referral', 'rb') as f: key_text = f.read() | |
privkey = RSA.importKey(key_text) | |
publickey = privkey.publickey() | |
encryptor = PKCS1_OAEP.new(publickey) | |
decryptor = PKCS1_OAEP.new(privkey) | |
def encrypt(msg): |
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
import sys | |
import requests | |
import zlib | |
import json | |
from urllib.parse import urlparse | |
from collections import Counter | |
path = sys.argv[1] | |
url = 'https://commoncrawl.s3.amazonaws.com/{}'.format(path) | |
google_netloc = 'www.google.com' | |
google_path = '/maps/place' |
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
import gzip | |
import json | |
import requests | |
from StringIO import StringIO | |
def get_page_count(searchString): | |
url = 'http://index.commoncrawl.org/CC-MAIN-2017-51-index?url={}&output=json&showNumPages=true'.format(searchString) | |
resp = requests.get(url) | |
return json.loads(resp.content)['pages'] |
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
Set<String> phones = new HashSet<>(); | |
PhoneNumberUtil util = PhoneNumberUtil.getInstance(); | |
Iterator<PhoneNumberMatch> iterator = util.findNumbers(source, null).iterator(); | |
while (iterator.hasNext()) { | |
phones.add(iterator.next().rawString()); | |
} |
NewerOlder