text
stringlengths
0
1.05M
meta
dict
import tensorflow as tf import numpy as np # A warper of a collection of update functions # These functions will add the element update # computation node to a graph passed to it. class UpdateElem(object) : # Create object with a tensor flow graph def __init__(self) : self._A = None self._W = None se...
{ "repo_name": "nukui-s/sscomdetection", "path": "Update.py", "copies": "1", "size": "4289", "license": "apache-2.0", "hash": 5829739949758942000, "line_mean": 38.712962963, "line_max": 103, "alpha_frac": 0.6211238051, "autogenerated": false, "ratio": 2.980542043085476, "config_test": false, "...
import tensorflow as tf import numpy as np import Update as ud # Made-up matrix for testing # A is 5-by-5 adj matrix # O is 5-by-5 prior knowledge matrix # D is 5-by-5 diagonal matrix of O # k = 4 - Suppose we have 4 clustering # lambda = 0.5 - Consider trade off between topology (A) and prior knowledge (O) A = np.a...
{ "repo_name": "nukui-s/sscomdetection", "path": "TestUpdate.py", "copies": "1", "size": "1512", "license": "apache-2.0", "hash": -7122712059874937000, "line_mean": 26.4909090909, "line_max": 80, "alpha_frac": 0.6322751323, "autogenerated": false, "ratio": 2.8051948051948052, "config_test": fals...
__author__ = 'hoffmabc' import smtplib from smtplib import SMTPAuthenticationError from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText from log import Logger class SMTPNotification(object): """ A class for sending SMTP notifications """ def __init__(self, db): ...
{ "repo_name": "saltduck/OpenBazaar-Server", "path": "market/smtpnotification.py", "copies": "5", "size": "1670", "license": "mit", "hash": 6310451453639084000, "line_mean": 28.8214285714, "line_max": 77, "alpha_frac": 0.5766467066, "autogenerated": false, "ratio": 4.315245478036176, "config_tes...
__author__ = 'Hojjat Salehinejad' import time import sys import numpy as np import random import fgeneric import bbobbenchmarks as bn import os import logging def saver(path_to_savein, data_to_save, name_file): if not os.path.exists(path_to_savein): os.makedirs(path_to_savein) path_to_save = path_to_sa...
{ "repo_name": "salehinejad/DifferentialEvolution", "path": "ODE.py", "copies": "1", "size": "10651", "license": "mit", "hash": 5163528009339909000, "line_mean": 34.9831081081, "line_max": 182, "alpha_frac": 0.4928175758, "autogenerated": false, "ratio": 2.9471499723298282, "config_test": false,...
__author__ = 'holivares' from inei.auth.models import Usuario class EndesBackend(object): """ Authenticates against django.contrib.auth.models.User. """ supports_inactive_user = True # TODO: Model, login attribute name and password attribute name should be # configurable. def authenticate...
{ "repo_name": "heraldmatias/enssec", "path": "src/inei/auth/backends.py", "copies": "1", "size": "1959", "license": "apache-2.0", "hash": -2599190157095697400, "line_mean": 31.6666666667, "line_max": 78, "alpha_frac": 0.5783563042, "autogenerated": false, "ratio": 4.26797385620915, "config_test...
import logging from logging import NullHandler from Exceptions.HologramError import ApiError import requests HOLOGRAM_REST_API_BASEURL = 'https://dashboard.hologram.io/api/1' class Api: def __init__(self, apikey='', username='', password=''): # Logging setup. self.logger = logging.getLogger(__n...
{ "repo_name": "hologram-io/hologram-python", "path": "Hologram/Api/Api.py", "copies": "1", "size": "3675", "license": "mit", "hash": 3447551663504065500, "line_mean": 33.3457943925, "line_max": 91, "alpha_frac": 0.6149659864, "autogenerated": false, "ratio": 4.0207877461706785, "config_test": f...
class HologramError(Exception): def __repr__(self): return '%s: %s' % (type(self).__name__, str(self)) class ApiError(HologramError): pass class AuthenticationError(HologramError): pass class NetworkError(HologramError): pass class ModemError(HologramError): pass class PPPError(Network...
{ "repo_name": "hologram-io/hologram-python", "path": "Exceptions/HologramError.py", "copies": "1", "size": "1905", "license": "mit", "hash": 5640570693290565000, "line_mean": 30.75, "line_max": 91, "alpha_frac": 0.6514435696, "autogenerated": false, "ratio": 3.7648221343873516, "config_test": f...
import pytest import sys sys.path.append(".") sys.path.append("..") sys.path.append("../..") from Hologram.Authentication import * from Hologram.Cloud import Cloud class TestCloud: def test_create_send(self): cloud = Cloud(None, send_host = '127.0.0.1', send_port = 9999) assert cloud.send_host =...
{ "repo_name": "hologram-io/hologram-python", "path": "tests/MessageMode/test_Cloud.py", "copies": "1", "size": "1676", "license": "mit", "hash": 4521603706289057300, "line_mean": 31.862745098, "line_max": 93, "alpha_frac": 0.6390214797, "autogenerated": false, "ratio": 3.4134419551934827, "conf...
import pytest import sys from datetime import datetime sys.path.append(".") sys.path.append("..") sys.path.append("../..") from Exceptions.HologramError import SerialError from Hologram.Network.Modem import Modem from UtilClasses import ModemResult def mock_write(modem, message): return True def mock_read(modem...
{ "repo_name": "hologram-io/hologram-python", "path": "tests/Modem/test_Modem.py", "copies": "1", "size": "8224", "license": "mit", "hash": -1045989279525008400, "line_mean": 31.3779527559, "line_max": 119, "alpha_frac": 0.6560068093, "autogenerated": false, "ratio": 3.3268608414239482, "config_...
import sys import pytest sys.path.append(".") sys.path.append("..") sys.path.append("../..") from Hologram.Network import NetworkManager class TestNetworkManager: def test_create_non_network(self): networkManager = NetworkManager.NetworkManager(None, '') assert networkManager.networkActive ...
{ "repo_name": "hologram-io/hologram-python", "path": "tests/Network/test_NetworkManager.py", "copies": "1", "size": "1406", "license": "mit", "hash": 4798153003734302000, "line_mean": 34.15, "line_max": 88, "alpha_frac": 0.7155049787, "autogenerated": false, "ratio": 4.159763313609467, "config_...
import pytest import sys from Hologram.Network.Modem.Nova import Nova sys.path.append(".") sys.path.append("..") sys.path.append("../..") def mock_write(nova, message): return True def mock_read(nova): return True def mock_readline(nova, timeout=None, hide=False): return '' def mock_open_serial_port(...
{ "repo_name": "hologram-io/hologram-python", "path": "tests/Modem/test_Nova.py", "copies": "1", "size": "1730", "license": "mit", "hash": -7767537574703298000, "line_mean": 29.8928571429, "line_max": 90, "alpha_frac": 0.7219653179, "autogenerated": false, "ratio": 3.2641509433962264, "config_te...
from mock import call, patch import pytest import sys from Hologram.Network.Modem.Nova_U201 import Nova_U201 sys.path.append(".") sys.path.append("..") sys.path.append("../..") def mock_write(nova, message): return True def mock_read(nova): return True def mock_readline(nova, timeout=None, hide=False): ...
{ "repo_name": "hologram-io/hologram-python", "path": "tests/Modem/test_NovaU201.py", "copies": "1", "size": "3082", "license": "mit", "hash": 1307482002592346400, "line_mean": 33.6292134831, "line_max": 95, "alpha_frac": 0.7118754056, "autogenerated": false, "ratio": 3.125760649087221, "config_...
__author__ = 'Home' from Utils.Vector2 import * from Utils.Properties import * class SpaceObjectsController: _objects = [] _offset = Vector2(0, 0) _resistanse=0.0 def __init__(self): self._objects = [] def __getitem__(self, item): return self._objects[item] def __setitem__(...
{ "repo_name": "PrimankaDEN/N-bodyProblemSimulator", "path": "SpaceObjects/SpaceObjectsController.py", "copies": "1", "size": "2023", "license": "mit", "hash": 4990575475556695000, "line_mean": 30.625, "line_max": 119, "alpha_frac": 0.5862580326, "autogenerated": false, "ratio": 3.68488160291439, ...
__author__ = 'hooda' import os import flatten # Delete files from folder1 that are also in folder2 def del_same(folder1, folder2): files1 = flatten.listfiles(folder1) files2 = flatten.listfiles(folder2) # print(files2) files2 = getnames(files2) print(files2) for file in files1: if (...
{ "repo_name": "hoodakaushal/Snippets", "path": "differ.py", "copies": "1", "size": "1092", "license": "mit", "hash": 2083305006273498600, "line_mean": 19.6226415094, "line_max": 52, "alpha_frac": 0.5934065934, "autogenerated": false, "ratio": 3.4231974921630095, "config_test": false, "has_no_...
__author__ = 'hooda' # Take input a folder path, and for each folder in that path, extract all the files that match a given extension # Rename all the files as : Folder/FolderName/File.ext to FolderName - File.exe # Put all the files in a seperate folder. import os import shutil # Full path of every single file in ...
{ "repo_name": "hoodakaushal/Snippets", "path": "flatten.py", "copies": "1", "size": "2099", "license": "mit", "hash": -813245995711039400, "line_mean": 27.3783783784, "line_max": 121, "alpha_frac": 0.598380181, "autogenerated": false, "ratio": 3.6189655172413793, "config_test": false, "has_no...
__author__ = 'horacioibrahim' # python-iugu package modules from . import merchant, config, base, errors class IuguInvoice(base.IuguApi): """ This class allows handling invoices. The invoice is used to customers to make payments. :attribute class data: is a descriptor that carries rules of API fie...
{ "repo_name": "fellipeh/iugu-python3", "path": "lib/iugu/invoices.py", "copies": "1", "size": "15020", "license": "apache-2.0", "hash": -2099501251952136700, "line_mean": 36.3631840796, "line_max": 91, "alpha_frac": 0.5874833555, "autogenerated": false, "ratio": 4.095991273520589, "config_test"...
__author__ = 'horacioibrahim' # python-iugu package modules import merchant, config, base, errors class IuguInvoice(base.IuguApi): """ This class allows handling invoices. The invoice is used to customers to make payments. :attribute class data: is a descriptor that carries rules of API fields. ...
{ "repo_name": "horacioibrahim/iugu-python", "path": "lib/iugu/invoices.py", "copies": "1", "size": "15007", "license": "apache-2.0", "hash": 1382768370464128000, "line_mean": 36.3308457711, "line_max": 91, "alpha_frac": 0.5874591857, "autogenerated": false, "ratio": 4.0969150969150965, "config_...
__author__ = 'horacioibrahim' # python-iugu package modules from . import base, config, errors, merchant class IuguSubscription(base.IuguApi): """ This class allows handling subscriptions an CRUD with create, get, set, save and remove plus add-ons as getitems, suspend, activate, change_plan, is_cred...
{ "repo_name": "fellipeh/iugu-python3", "path": "lib/iugu/subscriptions.py", "copies": "1", "size": "20697", "license": "apache-2.0", "hash": -8703354677179986000, "line_mean": 36.7682481752, "line_max": 113, "alpha_frac": 0.5769918346, "autogenerated": false, "ratio": 4.2187117814920505, "confi...
__author__ = 'horacioibrahim' # python-iugu package modules from . import base, config, errors class IuguPlan(object): """ This class allows handling plans. Basically contains a CRUD :attribute data: is a descriptor and their setters carries the rules => http://iugu.com/referencias/api#criar-um-...
{ "repo_name": "fellipeh/iugu-python3", "path": "lib/iugu/plans.py", "copies": "1", "size": "13503", "license": "apache-2.0", "hash": -7613243234068064000, "line_mean": 32.4232673267, "line_max": 91, "alpha_frac": 0.5681700363, "autogenerated": false, "ratio": 4.147113022113022, "config_test": f...
__author__ = 'horacioibrahim' # python-iugu package modules import base, config, errors, merchant class IuguSubscription(base.IuguApi): """ This class allows handling subscriptions an CRUD with create, get, set, save and remove plus add-ons as getitems, suspend, activate, change_plan, is_credit_base...
{ "repo_name": "horacioibrahim/iugu-python", "path": "lib/iugu/subscriptions.py", "copies": "1", "size": "20678", "license": "apache-2.0", "hash": -7546107719657518000, "line_mean": 36.7335766423, "line_max": 113, "alpha_frac": 0.5769416771, "autogenerated": false, "ratio": 4.22, "config_test": ...
__author__ = 'horacioibrahim' # python-iugu package modules import base, config, errors class IuguPlan(object): """ This class allows handling plans. Basically contains a CRUD :attribute data: is a descriptor and their setters carries the rules => http://iugu.com/referencias/api#criar-um-plano ...
{ "repo_name": "horacioibrahim/iugu-python", "path": "lib/iugu/plans.py", "copies": "1", "size": "13466", "license": "apache-2.0", "hash": 8051129211677128000, "line_mean": 32.3316831683, "line_max": 91, "alpha_frac": 0.5679489084, "autogenerated": false, "ratio": 4.151048088779285, "config_test...
__author__ = 'hose314' # -*- coding: utf-8 -*- import numpy as np import math import pandas as pd from parser import expr from copy import copy n = 20 m = 400 l = 5 T = 1 #предпологаяется что функция непрервынвая и u(0,t) = u(l,t) u_tx = "x*sin(t)" alpha = "-1" beta = "1" h = float(l) / n tau = float(T) / m gamma = t...
{ "repo_name": "hose314/GPM", "path": "main.py", "copies": "1", "size": "3085", "license": "mit", "hash": -2910307115636165000, "line_mean": 26, "line_max": 123, "alpha_frac": 0.4761428095, "autogenerated": false, "ratio": 2.319659442724458, "config_test": false, "has_no_keywords": false, "f...
__author__ = 'Hossein Noroozpour' import gc from gi.repository import Gtk from utility.HGEColladaImporter import collada_importer class AddWindow(Gtk.Window): def __init__(self): Gtk.Window.__init__(self, title='Add window') self.set_resizable(False) self.set_position(Gtk.WindowPosition.C...
{ "repo_name": "Hossein-Noroozpour/PyHGEE", "path": "ui/HGEAddWindow.py", "copies": "1", "size": "3706", "license": "mit", "hash": 2707374114934492000, "line_mean": 38.4255319149, "line_max": 114, "alpha_frac": 0.6100917431, "autogenerated": false, "ratio": 3.0253061224489795, "config_test": fal...
__author__ = """Hossein Noroozpour""" from gi.repository import Gtk from gi.repository import Gdk from gi.repository import GdkPixbuf from gi.repository import GLib from time import time class ProfilerWindow(Gtk.ScrolledWindow): """Scrolled Window for profiler page in side tab in main window""" def __init__(s...
{ "repo_name": "Hossein-Noroozpour/PyHGEE", "path": "ui/HGEProfilerWindow.py", "copies": "1", "size": "1637", "license": "mit", "hash": -7337911415897400000, "line_mean": 33.125, "line_max": 72, "alpha_frac": 0.6212583995, "autogenerated": false, "ratio": 2.9495495495495496, "config_test": false...
__author__ = 'house' from urllib.request import urlopen import logging import smtplib import time from email.mime.text import MIMEText from logging.handlers import RotatingFileHandler from app import conf # serices structure: # { # 'url1': { 'available_last_time': True }, # 'url2': { 'available_last_ti...
{ "repo_name": "yang-yihao/alivemonitor", "path": "app/monitor.py", "copies": "1", "size": "5114", "license": "apache-2.0", "hash": 8309073549642474000, "line_mean": 30.9625, "line_max": 77, "alpha_frac": 0.5299178725, "autogenerated": false, "ratio": 4.004698512137823, "config_test": false, "...
__author__ = 'Howard' import csv import sys import time import statistics import os import test_connections as test if not sys.argv or len(sys.argv) < 2: print('Please specify file to analyze') exit() if not os.path.isfile(sys.argv[1]): print("Please specify correct file name in current folder") file_...
{ "repo_name": "howard11/GoAppEngineIpTester", "path": "analyzeStableIp.py", "copies": "1", "size": "1273", "license": "mit", "hash": 1864174210812522500, "line_mean": 24.46, "line_max": 94, "alpha_frac": 0.6755695208, "autogenerated": false, "ratio": 3.1354679802955663, "config_test": false, ...
__author__ = 'Howard' import csv import time import os import sys import httplib MAX_TIME_OUT = 1 RESULT_FILE_PATH = time.strftime("%Y-%m-%d") + "_connect_result.csv" IP_SOURCE_FILE = 'iplist.txt' def check_ip_available(test_ip): conn = httplib.HTTPSConnection(test_ip, timeout=MAX_TIME_OUT) try: sta...
{ "repo_name": "howard11/GoAppEngineIpTester", "path": "test_connections.py", "copies": "1", "size": "1705", "license": "mit", "hash": -9174082051673569000, "line_mean": 31.7884615385, "line_max": 137, "alpha_frac": 0.5736070381, "autogenerated": false, "ratio": 3.4375, "config_test": false, "...
__author__ = 'hqh' # coding=gbk import string, time from PyUI import * DUI_MSGTYPE_MENU = "menu" DUI_MSGTYPE_LINK = "link" DUI_MSGTYPE_TIMER = "timer" DUI_MSGTYPE_CLICK = "click" DUI_MSGTYPE_RETURN = "return" DUI_MSGTYPE_SCROLL = "scroll" DUI_MSGTYPE_DROPDOWN = "dropdown" DUI_MSGTYPE_SETFOCUS = "se...
{ "repo_name": "the7day/py-ui4win", "path": "bin/PyFrameBase.py", "copies": "2", "size": "5240", "license": "bsd-2-clause", "hash": 4166371713667551700, "line_mean": 34.9014084507, "line_max": 85, "alpha_frac": 0.684351145, "autogenerated": false, "ratio": 3.4679020516214427, "config_test": fals...
__author__ = 'hriechma' from enum import Enum import hashlib import os ManagerCommands = Enum("ManagerCommands", "REGISTER INIT_PROCESS START_PROCESS STOP_PROCESS SEND_LOGS KEEPALIVE") ClientCommands = Enum("ClientCommands", "REGISTER PROCESSSTATUS_CHANGED PROCESS_LOGS KEEPALIVE") ServerCommands = Enum("ServerCommand...
{ "repo_name": "hriechmann/distributed_process_manager", "path": "src/eu/hriechmann/distributed_process_manager/common.py", "copies": "1", "size": "2777", "license": "mit", "hash": 4257520858826501000, "line_mean": 30.2134831461, "line_max": 113, "alpha_frac": 0.6236946345, "autogenerated": false, ...
__author__ = 'hs634' __author__ = 'hs634' class Stack(object): """ Simple Stack Implementation. Uses Python lists for storing the elements in the stack. """ def __init__(self): self.items = [] def push(self, item): self.items.append(item) def pop(self): re...
{ "repo_name": "hs634/algorithms", "path": "python/trees/btree_print.py", "copies": "1", "size": "2710", "license": "mit", "hash": -4243418309034312700, "line_mean": 23.2053571429, "line_max": 66, "alpha_frac": 0.5265682657, "autogenerated": false, "ratio": 3.5058214747736094, "config_test": fal...
__author__ = 'hs634' class CircularBuffer { int[] buffer; // next spot for reading int head; // next spot for writing int tail; mutex mtx; condition_variable cv_dequeue; condition_variable cv_enqueue; public CircularBuffer(int capacity) { buffer = new int[capacity + 1]; // ...
{ "repo_name": "hs634/algorithms", "path": "python/company/circular_buffer.py", "copies": "1", "size": "1201", "license": "mit", "hash": 2325869969625971000, "line_mean": 24.5744680851, "line_max": 86, "alpha_frac": 0.5337218984, "autogenerated": false, "ratio": 3.9377049180327868, "config_test"...
__author__ = 'hs634' class NaiveSolution(): def __init__(self): self.words = [] def is_a_word(self, dict, word): return word in dict def boogle(self, matrix): if len(matrix) == 0: return None rows = len(matrix) cols = len(matrix[0]) visited = [...
{ "repo_name": "hs634/algorithms", "path": "python/company/airbnb_boggle.py", "copies": "1", "size": "3788", "license": "mit", "hash": -550084114583634940, "line_mean": 28.1461538462, "line_max": 93, "alpha_frac": 0.4794086589, "autogenerated": false, "ratio": 3.169874476987448, "config_test": f...
__author__ = 'hs634' class Node(): def __init__(self, v): self.val = v self.left = None self.right = None class BinaryTree(): def __init__(self): self.root = None def insert(self, root, v): if not root: return Node(v) if v < root.val: ...
{ "repo_name": "hs634/algorithms", "path": "python/trees/mirror.py", "copies": "1", "size": "1549", "license": "mit", "hash": 4352184314372671000, "line_mean": 19.9324324324, "line_max": 54, "alpha_frac": 0.5519690123, "autogenerated": false, "ratio": 3.302771855010661, "config_test": false, "...
__author__ = 'hs634' class Node(object): def __init__(self, key, value): self.key = key self.val = value self.prev, self.next = None, None class LinkedListCache(object): def __init__(self): self.head, self.tail = None, None def remove(self, node): if not node: ...
{ "repo_name": "hs634/algorithms", "path": "python/arrays/LRU_cache.py", "copies": "1", "size": "3254", "license": "mit", "hash": 1937155753884753400, "line_mean": 22.5869565217, "line_max": 79, "alpha_frac": 0.4944683467, "autogenerated": false, "ratio": 3.57975797579758, "config_test": false, ...
__author__ = 'hs634' class Stack(object): def __init__(self): self._stack = [] def push(self, x): self._stack.append(x) def pop(self): if self.is_empty(): raise Exception("Stack is empty") return self._stack.pop() def is_empty(self): if len(self._s...
{ "repo_name": "hs634/algorithms", "path": "python/graphs/topological_sort_dfs.py", "copies": "1", "size": "1263", "license": "mit", "hash": 933708622203609300, "line_mean": 19.7049180328, "line_max": 50, "alpha_frac": 0.4798099762, "autogenerated": false, "ratio": 3.4889502762430937, "config_te...
__author__ = 'hs634' class Stack(object): """ Simple Stack Implementation. Uses Python lists for storing the elements in the stack. """ def __init__(self): self.items = [] def push(self, item): self.items.append(item) def pop(self): return self.items.pop() ...
{ "repo_name": "hs634/algorithms", "path": "python/trees/btree_zigzag_level_order.py", "copies": "1", "size": "2370", "license": "mit", "hash": -3570669032785423400, "line_mean": 21.358490566, "line_max": 66, "alpha_frac": 0.5109704641, "autogenerated": false, "ratio": 3.537313432835821, "config...
__author__ = 'hs634' def get_max_profit(stock_prices_yesterday): # make sure we have at least 2 prices if len(stock_prices_yesterday) < 2: raise IndexError('Getting a profit requires at least 2 prices') # we'll greedily update min_price and max_profit, so we initialize # them to the first pri...
{ "repo_name": "hs634/algorithms", "path": "python/arrays/apple_stocks.py", "copies": "1", "size": "1367", "license": "mit", "hash": -746435677293720700, "line_mean": 37, "line_max": 71, "alpha_frac": 0.6444769568, "autogenerated": false, "ratio": 3.6945945945945944, "config_test": false, "has...
__author__ = 'hs634' def infix_to_postfix(infix): ops = { '*': 3, '/': 3, '+': 2, '-': 2, '(': 1 } parans = ['(', ')'] postfix = [] opstack = [] infix_tokens = list(infix) for t in infix_tokens: if t not in ops and t not in parans: ...
{ "repo_name": "hs634/algorithms", "path": "python/arrays/infix_to_postfix.py", "copies": "1", "size": "1749", "license": "mit", "hash": -4674264815754969000, "line_mean": 21.4230769231, "line_max": 73, "alpha_frac": 0.4208118925, "autogenerated": false, "ratio": 3.689873417721519, "config_test"...
__author__ = 'hs634' def longest_palindromic_subsequence(arr): n = len(arr) return lps(arr, 0, n-1) def lps(arr, low, high): if low > high: return 0 if low == high: return 1 if arr[low] == arr[high] and low+1 == high: return 2 if arr[low] == arr[high]: return 2...
{ "repo_name": "hs634/algorithms", "path": "python/strings/longest_palindromic_subsequence.py", "copies": "1", "size": "2435", "license": "mit", "hash": -4352826799136699400, "line_mean": 22.8725490196, "line_max": 89, "alpha_frac": 0.445174538, "autogenerated": false, "ratio": 2.7421171171171173,...
__author__ = 'hs634' def read_input(): rs, cols = raw_input().split(',') rows = int(rs) matrix = [] for i in range(rows): m_row = raw_input().split(',') matrix.append(m_row) def print_spiral(matrix, rows, cols): k, l, m, n = 0, 0, rows, cols while k < m and l < n: for i...
{ "repo_name": "hs634/algorithms", "path": "python/arrays/print_spiral.py", "copies": "1", "size": "1846", "license": "mit", "hash": 1218685456004283000, "line_mean": 27.4, "line_max": 82, "alpha_frac": 0.4452871073, "autogenerated": false, "ratio": 3.097315436241611, "config_test": false, "ha...
__author__ = 'hs634' def sqrt(num): if num < 0: raise ValueError if num == 1: return 1 low = 0 high = (num/2) + 1 while low+1 < high: mid = low + (high-low)/2 sq = mid**2 if sq == num: return True elif sq < num: low = mid ...
{ "repo_name": "hs634/algorithms", "path": "python/misc/sqrt.py", "copies": "1", "size": "1264", "license": "mit", "hash": 4370904913561090600, "line_mean": 17.6029411765, "line_max": 45, "alpha_frac": 0.4683544304, "autogenerated": false, "ratio": 3.3439153439153437, "config_test": false, "ha...
__author__ = 'hs634' # For each character in the plaintext, # - Convert the character to a number, based on its position in the English alphabet (e.g. a -> 1, e -> 5) # - Convert the number to a roman numeral # - Concatenate all the roman numerals together # Return the concatenated string # "cat" --> 3, 1, 20 --> III...
{ "repo_name": "hs634/algorithms", "path": "python/company/square.py", "copies": "1", "size": "1940", "license": "mit", "hash": -1150061755460879600, "line_mean": 20.3186813187, "line_max": 106, "alpha_frac": 0.5412371134, "autogenerated": false, "ratio": 3.288135593220339, "config_test": false,...
__author__ = 'hs634' from collections import defaultdict class Solution(object): def minWindow(self, s, t): """ :type s: str :type t: str :rtype: str """ needtofind = defaultdict(int) for ch in t: needtofind[ch] += 1 hasfound = defaultdic...
{ "repo_name": "hs634/algorithms", "path": "python/strings/min_window_substr.py", "copies": "1", "size": "1162", "license": "mit", "hash": -1550844262269025300, "line_mean": 28.8205128205, "line_max": 94, "alpha_frac": 0.4604130809, "autogenerated": false, "ratio": 3.8993288590604025, "config_te...
__author__ = 'hs634' from collections import defaultdict class TrieNode(object): def __init__(self, value=None): self.val = value self.children = {} self.is_end = False class Trie(object): def __init__(self, root_value='0'): self.root = TrieNode(root_value) def insert(se...
{ "repo_name": "hs634/algorithms", "path": "python/graphs/trie_find_longest_prefix.py", "copies": "1", "size": "1447", "license": "mit", "hash": -4441464148840899600, "line_mean": 20.2794117647, "line_max": 72, "alpha_frac": 0.4975812025, "autogenerated": false, "ratio": 3.848404255319149, "conf...
__author__ = 'hs634' from collections import OrderedDict from threading import Lock #from collections import OrderedDict # d = OrderedDict() # d['a'] = 1 # d['b'] = 2 # d['c'] = 3 # d['a'] = 5 # for k, v in d.iteritems(): # print k, v # __setitem__, __getitem__, pop, popitem # self.map = {'key': 'value, next...
{ "repo_name": "hs634/algorithms", "path": "python/misc/lru_cache.py", "copies": "1", "size": "2452", "license": "mit", "hash": 4798745388323652000, "line_mean": 20.3217391304, "line_max": 60, "alpha_frac": 0.5065252855, "autogenerated": false, "ratio": 3.5229885057471266, "config_test": false, ...
__author__ = 'hs634' #from collections import OrderedDict # d = OrderedDict() # d['a'] = 1 # d['b'] = 2 # d['c'] = 3 # d['a'] = 5 # for k, v in d.iteritems(): # print k, v # __setitem__, __getitem__, pop, popitem # self.map = {'key': 'value, next'} class Node: def __init__(self, key, val): self.k...
{ "repo_name": "hs634/algorithms", "path": "python/misc/OrderedDict.py", "copies": "1", "size": "1842", "license": "mit", "hash": 2899051170355258000, "line_mean": 20.4302325581, "line_max": 45, "alpha_frac": 0.4972855592, "autogenerated": false, "ratio": 3.3369565217391304, "config_test": false...
__author__ = 'hs634' '''Given an array where elements are sorted in ascending order, convert it to a height balanced BST.''' '''Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.''' def sorted_arr_to_balanced_btree(arr, start, end): if start > end: ...
{ "repo_name": "hs634/algorithms", "path": "python/trees/sorted_arr_balanced_btree.py", "copies": "1", "size": "1563", "license": "mit", "hash": -8277667907742674000, "line_mean": 24.2258064516, "line_max": 115, "alpha_frac": 0.6199616123, "autogenerated": false, "ratio": 3.4201312910284463, "co...
__author__ = 'hs634' """Given a value N, if we want to make change for N cents, and we have infinite supply of each of S = { S1, S2, .. , Sm} valued coins, how many ways can we make the change The order of coins doesn't matter. For example, for N = 4 and S = {1,2,3}, there are four solutions: {1,1,1,1},{1,1,2},{2,2},{...
{ "repo_name": "hs634/algorithms", "path": "python/DP/dp_coin_change.py", "copies": "1", "size": "2893", "license": "mit", "hash": -5692748613560322000, "line_mean": 28.2222222222, "line_max": 90, "alpha_frac": 0.5527134462, "autogenerated": false, "ratio": 3.120819848975189, "config_test": fals...
__author__ = 'hs634' Gotchas Our first thought might be to do an in-order traversal of the BST ↴ and return the second-to-last item. This means looking at every node in the BST. That would take O(n)O(n) time and O(h)O(h) space, where hh is the max height of the tree (which is lgnlgn if the tree is balanced ↴ , but cou...
{ "repo_name": "hs634/algorithms", "path": "python/some.py", "copies": "1", "size": "6473", "license": "mit", "hash": 5132998564621288000, "line_mean": 44.2167832168, "line_max": 318, "alpha_frac": 0.6969837587, "autogenerated": false, "ratio": 3.745654692931634, "config_test": false, "has_no_...
__author__ = 'hs634' import sys import os def maxThreats( a): if a is None or len(a) <= 1: return 0 g_max = 0 for i in range(len(a)): cur_max = 0 j = a[i] - 1 cur_max = get_threats(i, j, a) g_max = max(cur_max, g_max) return g_max def get_threats(row, col, a):...
{ "repo_name": "hs634/algorithms", "path": "python/company/zenefits.py", "copies": "1", "size": "1034", "license": "mit", "hash": -6899486138213212000, "line_mean": 15.4285714286, "line_max": 47, "alpha_frac": 0.4303675048, "autogenerated": false, "ratio": 2.4796163069544366, "config_test": fals...
__author__ = 'hs634' import sys class Solution(): def __init__(self): self.n = 0 self.inputs = [] def read_input(self): stdin_input = [] for line in sys.stdin: stdin_input.append(line) self.n = int(stdin_input[0]) for i in range(1, len(stdin_input)...
{ "repo_name": "hs634/algorithms", "path": "python/company/vmware.py", "copies": "1", "size": "1724", "license": "mit", "hash": 9011551226191367000, "line_mean": 27.7333333333, "line_max": 75, "alpha_frac": 0.4628770302, "autogenerated": false, "ratio": 3.70752688172043, "config_test": false, ...
__author__ = 'hs634' class LexSort(): def __init__(self, arr, order): self.arr = arr self.order = order def _custom_cmp(self, a, b): p1 = 0 p2 = 0 for i in range(min(len(a), len(b))): if p1 != p2: break p1 = self.order.index(a[i]...
{ "repo_name": "hs634/algorithms", "path": "python/company/lex_sort.py", "copies": "1", "size": "1043", "license": "mit", "hash": 3651531369108869000, "line_mean": 22.1777777778, "line_max": 53, "alpha_frac": 0.4611697028, "autogenerated": false, "ratio": 2.988538681948424, "config_test": true, ...
__author__ = 'hs634' #Definition for a binary tree node. class TreeNode(object): def __init__(self, x): self.val = x self.left = None self.right = None class BinaryTree(object): def __init__(self): self.root = None def add_node(self, val): return TreeNode(val) ...
{ "repo_name": "hs634/algorithms", "path": "python/trees/level_order_traversal.py", "copies": "1", "size": "1790", "license": "mit", "hash": -7995353254615902000, "line_mean": 22.5657894737, "line_max": 58, "alpha_frac": 0.4860335196, "autogenerated": false, "ratio": 3.816631130063966, "config_t...
__author__ = 'hs634' def is_match(string, pat): return is_match_rec(string, 0, pat, 0, {}) def is_match_rec(string, i, pat, j, cmap): if i == len(string) and j == len(pat): return True if i == len(string) or j == len(pat): return False if pat[j] in cmap: t = cmap[pat[j]] ...
{ "repo_name": "hs634/algorithms", "path": "python/strings/kmp.py", "copies": "1", "size": "2107", "license": "mit", "hash": 8417377244162798000, "line_mean": 21.6559139785, "line_max": 69, "alpha_frac": 0.557190318, "autogenerated": false, "ratio": 3.0057061340941513, "config_test": false, "h...
__author__ = 'hs634' # 'fasdfffffejwaejjfaajaoajeafaasf' # What's the character that occurs consecutively most times and the amount of times it occurs? # ['f', 5] input = 'fasdfffffejwaejjfaajaoajeafaasf' result = [] def highest(input): prev_char = None current_count = 0 max_char = None max_count...
{ "repo_name": "hs634/algorithms", "path": "python/company/styleseat.py", "copies": "1", "size": "1361", "license": "mit", "hash": 7853851499829559000, "line_mean": 19.9384615385, "line_max": 94, "alpha_frac": 0.5591476855, "autogenerated": false, "ratio": 3.1948356807511735, "config_test": fals...
__author__ = 'hs634' """ Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.) You have the following 3 operations permitted on a word: a) Insert a character b) Delete a character c) Replace a character Solution: Assume that the...
{ "repo_name": "hs634/algorithms", "path": "python/DP/edit_distance.py", "copies": "1", "size": "2593", "license": "mit", "hash": -4918344959492025000, "line_mean": 30.2409638554, "line_max": 140, "alpha_frac": 0.5723100656, "autogenerated": false, "ratio": 3.0795724465558196, "config_test": fal...
__author__ = 'hs634' """ I want to learn some big words so people think I'm smart. I opened up a dictionary to a page in the middle and started flipping through, looking for words I didn't know. I put each word I didn't know at increasing indices in a huge array I created in memory. When I reached the end of the dicti...
{ "repo_name": "hs634/algorithms", "path": "python/arrays/find_index_of_rotated_array.py", "copies": "1", "size": "4659", "license": "mit", "hash": 2947618316696812000, "line_mean": 30.8835616438, "line_max": 118, "alpha_frac": 0.6754027927, "autogenerated": false, "ratio": 3.6253894080996885, "...
__author__ = 'hs634' ''' Gotchas Our first thought might be to do an in-order traversal of the BST ↴ and return the second-to-last item. This means looking at every node in the BST. That would take O(n)O(n) time and O(h)O(h) space, where hh is the max height of the tree (which is lgnlgn if the tree is balanced , but ...
{ "repo_name": "hs634/algorithms", "path": "python/trees/BST_second_largest.py", "copies": "1", "size": "6451", "license": "mit", "hash": -6451251201382589000, "line_mean": 36.2716763006, "line_max": 150, "alpha_frac": 0.6983092911, "autogenerated": false, "ratio": 3.735225955967555, "config_tes...
__author__ = 'hs634' ''' Given a binary tree where all the right nodes are leaf nodes, flip it upside down and turn it into a tree with left leaf nodes. Keep in mind: ALL RIGHT NODES IN ORIGINAL TREE ARE LEAF NODE. /* for example, turn these: * * 1 1 * / \ / \ * ...
{ "repo_name": "hs634/algorithms", "path": "python/trees/invert_tree.py", "copies": "1", "size": "2264", "license": "mit", "hash": -5454005987616255000, "line_mean": 19.0353982301, "line_max": 127, "alpha_frac": 0.5225265018, "autogenerated": false, "ratio": 3.3740685543964233, "config_test": fa...
__author__ = 'hs634' ''' What will be the output of the code below? Explain your answer. def extendList(val, list=[]): list.append(val) return list list1 = extendList(10) list2 = extendList(123,[]) list3 = extendList('a') print "list1 = %s" % list1 print "list2 = %s" % list2 print "list3 = %s" % list3 How ...
{ "repo_name": "hs634/algorithms", "path": "python/misc/python_list_quirk.py", "copies": "1", "size": "9830", "license": "mit", "hash": -6108728694758373000, "line_mean": 37.3203125, "line_max": 627, "alpha_frac": 0.7163098879, "autogenerated": false, "ratio": 3.504823151125402, "config_test": f...
__author__ = 'hs634' ''' public boolean isMatch(String s, String p) { // base case if (p.length() == 0) { return s.length() == 0; } // special case if (p.length() == 1) { // if the length of s is 0, return false if (s.length() < 1) { return false; } //if the first does not match, return false el...
{ "repo_name": "hs634/algorithms", "path": "python/DP/regex.py", "copies": "1", "size": "3183", "license": "mit", "hash": -5477534706560422000, "line_mean": 23.8671875, "line_max": 118, "alpha_frac": 0.4721960415, "autogenerated": false, "ratio": 2.969216417910448, "config_test": false, "has_n...
__author__ = 'hs634' ''' Provide a set of positive integers (an array of integers). Each integer represent number of nights user request on Airbnb.com. If you are a host, you need to design and implement an algorithm to find out the maximum number a nights you can accommodate. The constrain is that you have to reserve ...
{ "repo_name": "hs634/algorithms", "path": "python/company/airbnb_robber.py", "copies": "1", "size": "1194", "license": "mit", "hash": 8765726977917872000, "line_mean": 29.641025641, "line_max": 76, "alpha_frac": 0.6030150754, "autogenerated": false, "ratio": 2.7767441860465114, "config_test": f...
__author__ = 'hs634' '''The basic idea is that if you are given two arrays ar1[] and ar2[] and know the length of each, you can check whether an element ar1[i] is the median in constant time. Suppose that the median is ar1[i]. Since the array is sorted, it is greater than exactly i values in array ar1[]. Then if it is...
{ "repo_name": "hs634/algorithms", "path": "python/arrays/median_two_sorted_arrays.py", "copies": "1", "size": "3165", "license": "mit", "hash": 1191316544086873900, "line_mean": 42.8472222222, "line_max": 124, "alpha_frac": 0.6167247387, "autogenerated": false, "ratio": 2.986754966887417, "conf...
__author__ = 'hs634' # !/usr/bin/env python import random class Tic(object): winning_combos = ( [0, 1, 2], [3, 4, 5], [6, 7, 8], [0, 3, 6], [1, 4, 7], [2, 5, 8], [0, 4, 8], [2, 4, 6]) winners = ('X-win', 'Draw', 'O-win') def __init__(self, squares=None): if len(squares)...
{ "repo_name": "hs634/algorithms", "path": "python/arrays/tic_tac_toe.py", "copies": "1", "size": "3933", "license": "mit", "hash": 3859486631006693400, "line_mean": 26.7042253521, "line_max": 70, "alpha_frac": 0.4952962115, "autogenerated": false, "ratio": 3.8902077151335313, "config_test": fal...
__author__ = 'hs634' What if there is no intersection? Does your function do something reasonable in that case? What if one rectangle is entirely contained in the other? Does your function do something reasonable in that case? What if the rectangles don't really intersect but share an edge? Does your function do som...
{ "repo_name": "hs634/algorithms", "path": "python/misc/rectangle_overlap.py", "copies": "1", "size": "5654", "license": "mit", "hash": 9202696604837347000, "line_mean": 38.4755244755, "line_max": 327, "alpha_frac": 0.7239546421, "autogenerated": false, "ratio": 3.7651767845230153, "config_test"...
__author__ = 'hs634' # You are given two sorted arrays, A and B, where A has a # large enough buffer at the end to hold B. Write a method # to merge B into A in sorted order. # O(m + n) def merge(A, B): if not A and not B: return [] if not A: copy(B, A) if not B: return A C =...
{ "repo_name": "hs634/algorithms", "path": "python/company/handshake.py", "copies": "1", "size": "1959", "license": "mit", "hash": -805734143394545900, "line_mean": 16.1842105263, "line_max": 75, "alpha_frac": 0.4737110771, "autogenerated": false, "ratio": 2.893648449039882, "config_test": false...
__author__ = 'hsor001' from math import acos, sqrt, pi, atan2 def quaternionToAxisAngle(q): x = q[0] y = q[1] z = q[2] w = q[3] # print('quaternion: {0}, {1}, {2}, {3}'.format(x, y, z, w)) mag_x = sqrt(x*x + y*y + z*z) # angle = 2 * acos(w) angle = 2 * atan2(mag_x, w) # if angle ...
{ "repo_name": "ABI-Software/MedTechCoRE-Pelvis", "path": "src/medtechcore/pelvisdemo/utils/mathext.py", "copies": "1", "size": "1523", "license": "apache-2.0", "hash": -4497376703434407400, "line_mean": 16.3068181818, "line_max": 64, "alpha_frac": 0.3795141169, "autogenerated": false, "ratio": 2....
__author__ = 'hsor001' from medtechcore.pelvisdemo.utils.zinc import createSurfaceGraphics class PelvisScene(object): def __init__(self, model): self._model = model self._setupVisualisation() def _setupVisualisation(self): self._setupMaleVisualisation() self._setupFemaleVisu...
{ "repo_name": "ABI-Software/MedTechCoRE-Pelvis", "path": "src/medtechcore/pelvisdemo/scene/pelvis.py", "copies": "1", "size": "2054", "license": "apache-2.0", "hash": 3556433891750044000, "line_mean": 47.9047619048, "line_max": 148, "alpha_frac": 0.7074001947, "autogenerated": false, "ratio": 3.9...
__author__ = 'hsor001' from PySide2 import QtWidgets from opencmiss.zinc.context import Context from mapclientplugins.plainmodelviewerstep.view.ui_plainmodelviewerwidget import Ui_PlainModelViewerWidget class PlainModelViewerWidget(QtWidgets.QWidget): def __init__(self, parent=None): super(PlainModelV...
{ "repo_name": "mapclient-plugins/plainmodelviewer", "path": "mapclientplugins/plainmodelviewerstep/view/plainmodelviewerwidget.py", "copies": "1", "size": "1650", "license": "apache-2.0", "hash": 5797315917365991000, "line_mean": 26.5, "line_max": 106, "alpha_frac": 0.6509090909, "autogenerated": f...
__author__ = 'hsor001' import os import threading import subprocess import Queue from math import pi from PySide import QtCore from meshparser.stlparser.parser import STLParser from opencmiss.zinc.context import Context from medtechcore.pelvisdemo.utils.zinc import createMeshTime from medtechcore.pelvisdemo.utils.z...
{ "repo_name": "ABI-Software/MedTechCoRE-Pelvis", "path": "src/medtechcore/pelvisdemo/model/pelvis.py", "copies": "1", "size": "8270", "license": "apache-2.0", "hash": 9167972071795865000, "line_mean": 36.2522522523, "line_max": 147, "alpha_frac": 0.6436517533, "autogenerated": false, "ratio": 3.7...
__author__ = 'hstrauss' from google.appengine.ext import endpoints from protorpc import remote from google.appengine.api import search import webapp2 from lib import utils from web import models from webapp2_extras import auth from webapp2_extras import sessions class ALittleCloserBaseService(remote.Service): def...
{ "repo_name": "10-01/alc-server", "path": "web/base_api.py", "copies": "1", "size": "3958", "license": "mit", "hash": -4604931313662056400, "line_mean": 51.0789473684, "line_max": 154, "alpha_frac": 0.6720565942, "autogenerated": false, "ratio": 3.7234242709313263, "config_test": false, "has_...
__author__ = 'htelg' import warnings as _warnings from copy import deepcopy as _deepcopy import atmPy.general.vertical_profile import pandas as _pd import numpy as _np import matplotlib.pylab as _plt from atmPy.tools import pandas_tools as _pandas_tools from atmPy.tools import time_tools as _time_tools from atmPy.to...
{ "repo_name": "hagne/atm-py", "path": "atmPy/general/timeseries.py", "copies": "1", "size": "78227", "license": "mit", "hash": -2153988949791684600, "line_mean": 35.8305084746, "line_max": 213, "alpha_frac": 0.5458729083, "autogenerated": false, "ratio": 3.721373864231007, "config_test": false,...
__author__ = 'htelg' import numpy as np from numpy import linalg as la def cart2spheric(xyz): """ Returns ------- (r,theta, phi): r: length theta: polar angle (between vector and z axesl) rho: azimuth angle (in x,y plane) """ # sph = np.zeros(xyz.shape)#np.hstack((...
{ "repo_name": "mtat76/atm-py", "path": "build/lib/atmPy/tools/math_linear_algebra.py", "copies": "7", "size": "2087", "license": "mit", "hash": 2257272936840275700, "line_mean": 27.9861111111, "line_max": 105, "alpha_frac": 0.4925730714, "autogenerated": false, "ratio": 2.7901069518716577, "con...
__author__ = 'htelg' import numpy as _np import pandas as _pd from scipy import stats as _stats import matplotlib.pylab as _plt from atmPy.tools import plt_tools as _plt_tools import scipy.odr as _odr import warnings as _warnings _colors = _plt.rcParams['axes.prop_cycle'].by_key()['color'] def find_closest(array, va...
{ "repo_name": "hagne/atm-py", "path": "atmPy/tools/array_tools.py", "copies": "1", "size": "36662", "license": "mit", "hash": -6373826182661461000, "line_mean": 38.0447284345, "line_max": 205, "alpha_frac": 0.489989635, "autogenerated": false, "ratio": 3.909779247093953, "config_test": false, ...
__author__ = 'htelg' import numpy as np def find_closest(array, value, how = 'closest'): """Finds the element of an array which is the closest to a given number and returns its index Arguments --------- array: array The array to search thru. value: float or array-like. Numbe...
{ "repo_name": "mtat76/atm-py", "path": "build/lib/atmPy/tools/array_tools.py", "copies": "6", "size": "1730", "license": "mit", "hash": 8900942322819626000, "line_mean": 31.0555555556, "line_max": 117, "alpha_frac": 0.5734104046, "autogenerated": false, "ratio": 3.8963963963963963, "config_test...
__author__ = 'htelg' from copy import deepcopy import numpy as np import pandas as pd import pylab as plt from geopy.distance import vincenty from mpl_toolkits.basemap import Basemap from mpl_toolkits.mplot3d import Axes3D from atmPy.radiation import solar from atmPy.tools import time_tools # Todo: ...
{ "repo_name": "mtat76/atm-py", "path": "build/lib/atmPy/atmos/timeseries.py", "copies": "3", "size": "12190", "license": "mit", "hash": -1619292934174553000, "line_mean": 29.6623376623, "line_max": 146, "alpha_frac": 0.5275635767, "autogenerated": false, "ratio": 3.8117573483427143, "config_tes...
__author__ = "Htet Myet Lynn" from refo import finditer, Predicate, Plus from collections import Counter from StringIO import StringIO from get_summary import summary ##from nltk.corpus import stopwords import math import nltk import re import copy import glob import numpy as np import time start_time ...
{ "repo_name": "htetmyet/keyword-extraction", "path": "key_extract_new.py", "copies": "1", "size": "29291", "license": "mit", "hash": -9047074223809397000, "line_mean": 33.984029484, "line_max": 181, "alpha_frac": 0.5020654809, "autogenerated": false, "ratio": 3.0806689103912497, "config_test": ...
__author__ = " http://agiliq.com/blog/2013/10/producer-consumer-problem-in-python/ " # Demo a buggy example from threading import Thread, Lock import time import random queue = [] lock = Lock() class ProducerThread(Thread): def run(self): nums = range(5) #Will create the list [0, 1, 2, 3, 4] globa...
{ "repo_name": "JulyKikuAkita/PythonPrac", "path": "ThreadPrac/ConsumerProducerBuggy.py", "copies": "1", "size": "3028", "license": "apache-2.0", "hash": -3208166013970971600, "line_mean": 34.6352941176, "line_max": 161, "alpha_frac": 0.642668428, "autogenerated": false, "ratio": 4.234965034965035...
__author__ = 'http://code.activestate.com/recipes/573463-converting-xml-to-dictionary-and-back/' from xml.etree import ElementTree # Module Code: class XmlDictObject(dict): """ Adds object like functionality to the standard dictionary. """ def __init__(self, initdict=None): if initdict is Non...
{ "repo_name": "mlovci/bioscraping", "path": "bioscraping/parsers/xmlstuff.py", "copies": "1", "size": "4211", "license": "mit", "hash": -4165989221351569000, "line_mean": 29.2949640288, "line_max": 96, "alpha_frac": 0.58062218, "autogenerated": false, "ratio": 4.084384093113482, "config_test": ...
class Chat(object): """Contains a list of Threads""" def __init__(self, threads): self.threads = threads self.personDict = {person: self.__by(person) for person in {ppl for thread in self for ppl in thread.people}} self.messages = sorted([y for x in self.threa...
{ "repo_name": "ctbrennan/cross-platform-message-analytics", "path": "fb_chat.py", "copies": "1", "size": "3302", "license": "mit", "hash": -3952978209172557300, "line_mean": 30.4476190476, "line_max": 79, "alpha_frac": 0.5978195033, "autogenerated": false, "ratio": 3.765108323831243, "config_te...
import json import pickle from datetime import datetime as dt from bs4 import BeautifulSoup as bs import fb_chat dtFormat = '%A, %B %d, %Y at %I:%M%p %Z' #dtFormat = '%A, %d %B %Y at %H:%M %Z' # UK Format def html_to_py(file): soup = bs(file) chat_list = [] for x in soup.find_all(class_='thread'): ...
{ "repo_name": "ctbrennan/cross-platform-message-analytics", "path": "fb_parser.py", "copies": "1", "size": "2397", "license": "mit", "hash": 4015425297949530000, "line_mean": 29.3417721519, "line_max": 91, "alpha_frac": 0.5640383813, "autogenerated": false, "ratio": 3.4048295454545454, "config_...
'''@author : https://github.com/Harnek Implementation of HeapSort Complexity: Heapify() O(log n) BuildHeap() O(n) HeapSort() O(nLogn) ''' '''Iterative''' def heapify1(A, idx, maxidx): left = 2*idx + 1 right = 2*idx + 2 largest = idx while left < maxidx: if left < maxidx and A[lef...
{ "repo_name": "Harnek/algorithms", "path": "Sorting/heapsort.py", "copies": "2", "size": "1350", "license": "mit", "hash": -3894499312227157000, "line_mean": 23.125, "line_max": 52, "alpha_frac": 0.5074074074, "autogenerated": false, "ratio": 2.915766738660907, "config_test": false, "has_no_k...
__author__ = 'https://leetcode.com/problems/implement-trie-prefix-tree/' # https://github.com/kamyu104/LeetCode/blob/master/Python/implement-trie-prefix-tree.py # Time: O(n), per operation # Space: O(1) # # Description: Leetcode # 208. Implement Trie (Prefix Tree) # # Implement a trie with insert, search, and startsWi...
{ "repo_name": "JulyKikuAkita/PythonPrac", "path": "cs15211/ImplementTrie(PrefixTree).py", "copies": "1", "size": "8002", "license": "apache-2.0", "hash": 351024688424231230, "line_mean": 24.3259493671, "line_max": 93, "alpha_frac": 0.5532366908, "autogenerated": false, "ratio": 3.6977818853974123...
__author__ = 'https://leetcode.com/problems/sort-transformed-array/' # https://github.com/kamyu104/LeetCode/blob/master/Python/sort-transformed-array.py # Time: O(n) # Space: O(1) # # Description: Leetcode # 360. Sort Transformed Array # # Given a sorted array of integers nums and integer values a, b and c. # # Apply ...
{ "repo_name": "JulyKikuAkita/PythonPrac", "path": "cs15211/SortTransformedArray.py", "copies": "1", "size": "4976", "license": "apache-2.0", "hash": -2117360171894304500, "line_mean": 26.7988826816, "line_max": 137, "alpha_frac": 0.4736736334, "autogenerated": false, "ratio": 3.1938382541720154, ...
import sys import os import imgkit import openpyxl def print_usage(): print(""" usage: python3 main.py file.xlsx file.xlsx -- 原始数据表格 每个 Sheet 内必须有一列叫「SKU编码」 """) # 在 Windows 下 font-family 设置为 Souce Han Sans CN 字体不生效,用 思源黑体 CN 在 Windows 和 macOS 下均可 def get_template(): return """ <!DOCTYPE html...
{ "repo_name": "mzlogin/snippets", "path": "Python/excel2image/main.py", "copies": "1", "size": "2890", "license": "mit", "hash": 4664356718717034000, "line_mean": 23.6548672566, "line_max": 85, "alpha_frac": 0.5265613783, "autogenerated": false, "ratio": 3.078453038674033, "config_test": false,...
import sys import re import openpyxl import requests import imgkit from bs4 import BeautifulSoup # 1. 读取 Excel,得到 SKU -- CAS 映射 # 2. 依次处理,不抛异常 # 2.1 根据 CAS 号获取目标链接列表 # 2.2 依次打开目标链接,保存数据或截图 # 3. 输出处理结果统计 def print_usage(): print(""" usage: python3 main.py file.xlsx file.xlsx -- 原始数据表格 """) def fet...
{ "repo_name": "mzlogin/snippets", "path": "Python/html2image/html2image.py", "copies": "1", "size": "2450", "license": "mit", "hash": 5667766483003533000, "line_mean": 25.0574712644, "line_max": 84, "alpha_frac": 0.581200353, "autogenerated": false, "ratio": 2.6944114149821643, "config_test": f...
__author__ = 'http://stackoverflow.com/questions/26413216/pdfminer3k-has-no-method-named-create-pages-in-pdfpage' # # Used only when extracting indicators from PDF formatted files # from pdfminer.pdfparser import PDFParser, PDFDocument from pdfminer.pdfinterp import PDFResourceManager, PDFPageInterpreter from pdfminer...
{ "repo_name": "byt3smith/Forager", "path": "forager/pdfConverter.py", "copies": "1", "size": "1117", "license": "mit", "hash": -3750105788545615000, "line_mean": 36.2333333333, "line_max": 113, "alpha_frac": 0.709042077, "autogenerated": false, "ratio": 3.5348101265822787, "config_test": false,...
import time import sys # is an iterator def followSim(thefile): #thefile.seek(0,2) while True: line = thefile.readline() if not line: #time.sleep(1) #continue raise StopIteration yield line # Example use # Note : This example requires the use of an ...
{ "repo_name": "jmakov/market_tia", "path": "tia/trad/tools/io/follow.py", "copies": "1", "size": "1059", "license": "mit", "hash": 1093933397757712600, "line_mean": 23.6279069767, "line_max": 66, "alpha_frac": 0.6213408876, "autogenerated": false, "ratio": 3.6770833333333335, "config_test": fal...
__author__ = "http://www.jejik.com/articles/2007/02/a_simple_unix_linux_daemon_in_python/" import sys, os, time, atexit from signal import SIGTERM class Daemon(object): """ A generic daemon class. Usage: subclass the Daemon class and override the run() method """ def __init__(self, pidfile, stdin='/dev/null',...
{ "repo_name": "recap/pumpkin", "path": "pumpkin/PmkDaemon.py", "copies": "1", "size": "2976", "license": "mit", "hash": -4599596454297210000, "line_mean": 22.0697674419, "line_max": 104, "alpha_frac": 0.6323924731, "autogenerated": false, "ratio": 2.856046065259117, "config_test": false, "has...
__author__ = 'huafeng' #coding:utf-8 import os import subprocess import codecs import simplejson remote_path = r'/home/mdev/tmp' def tar_(): tar_command = '''fab -H mdev -- "cd %s; tar -zxvf baidu_freq.tar.gz; tar -zxvf new_words_wz_freq.tar.gz"'''%remote_path subpro...
{ "repo_name": "wanghuafeng/spider_tools", "path": "rong_tools/fabric_exec.py", "copies": "1", "size": "9650", "license": "mit", "hash": -7158515466801022000, "line_mean": 58.5483870968, "line_max": 354, "alpha_frac": 0.6853737811, "autogenerated": false, "ratio": 3.0735930735930737, "config_tes...
__author__ = 'huafeng' #coding:utf-8 import sys import os def cut_file(filename, partial_count=1): with open(filename) as f: line_list = list(set(f.readlines()))#打乱顺序 lenght_of_lines = len(line_list) print 'total line count: ', lenght_of_lines partial_file_line_count = lenght_of_line...
{ "repo_name": "wanghuafeng/spider_tools", "path": "rong_tools/split_file.py", "copies": "1", "size": "1920", "license": "mit", "hash": -7974446438675898000, "line_mean": 39.7906976744, "line_max": 150, "alpha_frac": 0.5404789054, "autogenerated": false, "ratio": 3.1546762589928057, "config_test...
from sanic import Sanic from sanic.response import json,text from sanic_mongo import GridFS app = Sanic(__name__) mongo_uri = "mongodb://{host}:{port}/{database}".format( database='test', port=27017, host='localhost' ) GridFS.SetConfig(app,test_fs=(mongo_uri,"fs")) GridFS(app) @app.get('/pics') async d...
{ "repo_name": "Sanic-Extensions/sanic-mongo", "path": "example_gridfs.py", "copies": "1", "size": "1052", "license": "apache-2.0", "hash": -5953577148062041000, "line_mean": 22.9090909091, "line_max": 74, "alpha_frac": 0.647338403, "autogenerated": false, "ratio": 2.8980716253443526, "config_te...
__author__ = 'huanpc' from sqlalchemy import create_engine, Column from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm import sessionmaker from sqlalchemy.dialects.mysql import \ BIGINT, BINARY, BIT, BLOB, BOOLEAN, CHAR, DATE, \ DATETIME, DECIMAL, DECIMAL, DOUBLE, ENUM, FLOAT, IN...
{ "repo_name": "huanpc/lab_cloud_computing", "path": "docs/learning-by-doing/week07-08-demo-auto-scaling/app.py", "copies": "1", "size": "1252", "license": "apache-2.0", "hash": -5899735735365579000, "line_mean": 43.75, "line_max": 99, "alpha_frac": 0.695686901, "autogenerated": false, "ratio": 3....
__author__ = 'huanpc' import constant from sqlalchemy import create_engine, Column from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm import sessionmaker from sqlalchemy.dialects.mysql import \ BIGINT, BINARY, BIT, BLOB, BOOLEAN, CHAR, DATE, \ DATETIME, DECIMAL, DECIMAL, DOUBLE, ENUM, F...
{ "repo_name": "huanpc/lab_cloud_computing", "path": "docs/learning-by-doing/week07-08-demo-auto-scaling/Model.py", "copies": "1", "size": "6094", "license": "apache-2.0", "hash": -500702946999454400, "line_mean": 34.4302325581, "line_max": 142, "alpha_frac": 0.6432556613, "autogenerated": false, ...
__author__ = 'huanpc' import os import constant import config import time import sys from random import randint import MySQLdb def getID(): ''' Ham nay bo :return: ''' db = MySQLdb.connect(host=config.HOST,port=config.PORT, user=config.USER, passwd=config.PASSWORD,db=config.DB) cur = db.cursor(...
{ "repo_name": "tranhuucuong91/autoscaling", "path": "jmeter_test_plan/TEST_TOOL_1_STEP/Main.py", "copies": "1", "size": "6467", "license": "apache-2.0", "hash": 6084060147483492000, "line_mean": 31.0148514851, "line_max": 118, "alpha_frac": 0.5807948044, "autogenerated": false, "ratio": 3.4362380...
__author__ = 'huanpc' CPU_THRESHOLD_UP = 0.1 CPU_THRESHOLD_DOWN = 0.001 MEM_THRESHOLD_UP = 15700000.0 MEM_THRESHOLD_DOWN = 2097152.0 HOST = '25.22.28.94' PORT = 8086 USER = 'root' PASS = 'root' DATABASE = 'cadvisor' SELECT_CPU = 'derivative(cpu_cumulative_usage)' SELECT_MEMORY = 'median(memory_usage)' SERIES = '"stats...
{ "repo_name": "huanpc/lab_cloud_computing", "path": "docs/learning-by-doing/week09_10_connectDB_restApi/auto scaling system/constant.py", "copies": "1", "size": "3300", "license": "apache-2.0", "hash": 8404436930996980000, "line_mean": 33.7368421053, "line_max": 169, "alpha_frac": 0.7018181818, "au...
__author__ = 'huanpc' CPU_THRESHOLD_UP = 0.1 CPU_THRESHOLD_DOWN = 0.001 MEM_THRESHOLD_UP = 15700000.0 MEM_THRESHOLD_DOWN = 2097152.0 HOST = 'localhost' PORT = 8086 USER = 'root' PASS = 'root' DATABASE = 'cadvisor' SELECT_CPU = 'derivative(cpu_cumulative_usage)' SELECT_MEMORY = 'median(memory_usage)' SERIES = '"stats"'...
{ "repo_name": "huanpc/lab_cloud_computing", "path": "docs/learning-by-doing/week07-08-demo-auto-scaling/constant.py", "copies": "1", "size": "3218", "license": "apache-2.0", "hash": -9160191108059599000, "line_mean": 32.8736842105, "line_max": 169, "alpha_frac": 0.7007458048, "autogenerated": false...
__author__ = 'huanpc' from prometheus_client import start_http_server, Summary, Gauge import random import time from influxdb import InfluxDBClient import xml.etree.ElementTree as ET EXPORT_PORT = '8001' def export_data(xml_data=None): root = ET.fromstring(xml_data) ipe_id = root.find('./*[@name="ipeId"]')...
{ "repo_name": "cloudcomputinghust/IoT", "path": "docker/oneM2M/Monitor_Middleware/monitor-middleware/prometheus_export.py", "copies": "4", "size": "2046", "license": "mit", "hash": 1185544635410410200, "line_mean": 31.4761904762, "line_max": 113, "alpha_frac": 0.4745845552, "autogenerated": false, ...
__author__ = 'huanpc' import constant import argparse from random import randint # Duong dan toi thu muc output file dataseed DIR_OUTPUT_PATH = './output' # Chon gia tri cho id trong bang customer customer_id_begin = 5 product_id_begin = 0 # So ban ghi can tao num_of_row = 100 #def createProductData(): def createCus...
{ "repo_name": "huanpc/lab_cloud_computing", "path": "Jmeter Test Plan/Seeding_Data/Main.py", "copies": "1", "size": "1880", "license": "apache-2.0", "hash": 7157417236255695000, "line_mean": 39.8695652174, "line_max": 185, "alpha_frac": 0.6420212766, "autogenerated": false, "ratio": 3.19185059422...
__author__ = 'huanpc' import time from time import gmtime, strftime from influxdb.influxdb08 import InfluxDBClient import http.client import os import constant import logging import sys from marathon import MarathonClient import Model def init(): global logger, influxdb_client, marathon_client logger = loggi...
{ "repo_name": "huanpc/lab_cloud_computing", "path": "docs/learning-by-doing/week07-08-demo-auto-scaling/demo.py", "copies": "1", "size": "8757", "license": "apache-2.0", "hash": -7648042235533666000, "line_mean": 39.7302325581, "line_max": 206, "alpha_frac": 0.5950668037, "autogenerated": false, ...