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()); | |
} |
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 operator import itemgetter | |
def show_most_informative_features(model, text=None, n=50): | |
""" | |
Accepts a Pipeline with a classifer and a TfidfVectorizer and computes | |
the n most informative features of the model. If text is given, then will | |
compute the most informative features for classifying that text. | |
Note that this function will only work on linear models with coefs_ |
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 os | |
import time | |
import string | |
import pickle | |
import pandas as pd | |
from operator import itemgetter | |
from nltk.corpus import stopwords as sw | |
from nltk.corpus import wordnet as wn |
NewerOlder