blob_id large_string | repo_name large_string | path large_string | src_encoding large_string | length_bytes int64 | score float64 | int_score int64 | detected_licenses large list | license_type large_string | text string | download_success bool |
|---|---|---|---|---|---|---|---|---|---|---|
0a0d445241d8e589985fd87c84c279a90246a9ac | tiny-wang/gs | /FTP/FTPClient_v2/core/FTPClient.py | UTF-8 | 2,157 | 2.546875 | 3 | [] | no_license | #!/usr/bin/env python
# _*_ coding:utf-8 _*_
# Author: Harvey Wang
import os
import socket, time
from conf import settings
class FTPClient(object):
def __init__(self, ip_port):
self.client = socket.socket()
self.conn = self.client.connect(ip_port)
def auth(self, userInfo):
self.clie... | true |
d932c8ad27472b93b3bb5f49baf8d43b25810c47 | ravi-ojha/competitive-sport | /codeforces/cf266/py_1.py | UTF-8 | 261 | 3.046875 | 3 | [] | no_license | def py_1():
n,m,a,b = map(int,raw_input().split())
if(m*a > b):
mrides = n/m
mcost = mrides*b
leftRides = n%m
if leftRides*a > leftRides*b:
total = leftRides*b + mcost
else:
total = leftRides*a + mcost
else:
total = n*a
print total
py_1()
| true |
9ca67bbefc218090226e0456dab91484e82ccfb8 | sayonkumarsaha/fake-news-image-verification | /image/ImageComparisonPy/edgeDetector.py | UTF-8 | 8,747 | 2.65625 | 3 | [] | no_license | from imageDetector import ImageDetector
import numpy as np
import cv2
import pylab
import time
class EdgeDetector:
def __init__(self):
self.lowThreshold = 100
self.maxThreshold = 3* self.lowThreshold
self.kernelSize = 30
self.count = 0
def compareTwoImage(self, imgA, imgB):
... | true |
6fc9d6549f2562d0d16b05fedc1128e2a292c231 | pacospace/Advent_of_Code | /2017/day18_Duet/day18.py | UTF-8 | 6,335 | 3.09375 | 3 | [] | no_license | # Advent of Code 2017 - day 18 (Part I)
import re
def registers_engine(counter):
if instructions[counter][1] not in registers:
registers[instructions[counter][1]] = 0
d = 0
if instructions[counter][0] == 'snd':
print(f'"snd {instructions[counter][1]}" plays '
f'a sound with... | true |
8459d04003a078ad18975ede018d19a67c2acffc | mohamed-elghayesh/LearningPython | /Django/mypollssite/polls/tests.py | UTF-8 | 3,505 | 2.90625 | 3 | [] | no_license | from django.test import TestCase
from django.utils import timezone
from django.urls import reverse
import datetime
from polls.models import Question
# Create your tests here.
# a method is related to a class, while a function just do what it is intended to do
def create_question(question_text, days):
""" creates ... | true |
78508960eb503b7892e76f98b0c3fbd047efdf02 | liberaliscomputing/leetcode-online-judge | /algorithms/array/easy/majority_element.py | UTF-8 | 799 | 3.8125 | 4 | [] | no_license | #!/usr/bin/python
# -*- coding: utf-8 -*-
"""
#Description
Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊n/2⌋ times.
You may assume that the array is non-empty and the majority element always exist in the array.
#Complexity
Time: O(n)
"""
class Solu... | true |
d948a069af009fee8af5b98e47363ee85601fdf6 | Ucache/PAT | /1009.product-polynomials.py | UTF-8 | 615 | 2.984375 | 3 | [] | no_license | import sys
lines = sys.stdin.readlines()
r = {}
linesplit0 = lines[0].split()
linesplit1 = lines[1].split()
for pos0 in range(1,len(linesplit0),2):
for pos1 in range(1,len(linesplit1),2):
key = int(linesplit0[pos0]) + int(linesplit1[pos1])
if r.has_key(key):
r[key] = r[key] + float(lines... | true |
57282deb7a16493735f1ebe936fd36882bd1005f | MosesJlldn/NLP | /task_word2vec.py | UTF-8 | 3,295 | 2.703125 | 3 | [] | no_license | import gensim, logging
import nltk
import pandas as pd
import numpy as np
import string
from nltk.corpus import stopwords
from nltk import pos_tag
from sklearn.feature_extraction.text import CountVectorizer
from sklearn.metrics import classification_report
from sklearn.model_selection import train_test_split
from skl... | true |
e0ba604b8559852443c02fcaf7623a2d43685e16 | TimSC/nvc-recognition-thesis | /corpus/annotstats.py | UTF-8 | 2,148 | 2.796875 | 3 | [] | no_license | import csv, math
import numpy as np
import matplotlib.pyplot as plt
def OrderClips(data):
out = []
for li in data:
clipId = li['clip_id']
del li['clip_id']
out.append((clipId, li))
out.sort()
return [a[1] for a in out]
def ComputeAverage(data, excludeAnnot = None):
out = []
for li in data:
ratings = []
... | true |
76a8d99b6bcf53c5d15ea4406b4ecd123efd57c4 | uniquelogin/printpos | /printpng.py | UTF-8 | 3,669 | 2.640625 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env python3
import usb.core
import usb.util
from PIL import Image
import PIL
import time
DEF_TOTAL_HEIGHT_LIMIT = 3000 # pixels
PRINT_WIDTH = 512 # px
STRIPE_HEIGHT = 32 # px
# Cool down the print head to avoid smearing
COOLDOWN_EVERY = 1000 # pixel lines
COOLDOWN_TIME = 1.5 # sec
def get_usb_endpoi... | true |
eccd37e3aa701f0e5be9235a333479c0955fb135 | malkoG/polyglot-cp | /BOJ/DynamicProgramming/Python/2921.py | UTF-8 | 546 | 2.859375 | 3 | [] | no_license | dp = [ [0] * 1002 for i in range(1002) ]
dp2 = [ [0] * 1002 for i in range(1002) ]
acc = [ [0] * 1002 for i in range(1002) ]
acc2 = [ [0] * 1002 for i in range(1002) ]
dp[0][0] = 1
for i in range(1001):
dp2[i][1] = i
for H in range(1, 1001):
current = 0
for W in range(1001):
current += dp[W][H-... | true |
4336bd57735734c106a074bf1599bf43d89d666b | khoanguyenxuan/codelearn | /ratingReview.py | UTF-8 | 183 | 3.03125 | 3 | [] | no_license | def ratingReview(threshold, ratings):
r = []
for i in range(len(ratings)):
c = ratings[i]
if sum(c) / len(c) < threshold:
r.append(i)
return r
| true |
9e8c37a4bfc9e1e69e4b9edc83787186682711c5 | CarolWang1203/words_image | /words_image.py | UTF-8 | 3,426 | 2.8125 | 3 | [
"MIT"
] | permissive | # -*- coding: utf-8 -*-
import jieba.analyse
from PIL import Image, ImageSequence
import numpy as np
import matplotlib.pyplot as plt
from wordcloud import WordCloud, ImageColorGenerator
import os
from images2gif import writeGif
MAX_WORDS = 1000
CUR_DIR = os.path.dirname(__file__)
SENTIMENT_DIR = os.path.join(CUR_DIR,... | true |
7615144f9a14f6def824b06e7131e3e3ba7535f4 | abinj/spark-learning | /machine_learning/text_process.py | UTF-8 | 1,723 | 3.109375 | 3 | [] | no_license | from pyspark.ml.classification import LogisticRegression
from pyspark.sql import SparkSession
from pyspark.sql.functions import regexp_replace
from pyspark.ml.feature import Tokenizer, StopWordsRemover, HashingTF, IDF
spark = SparkSession.builder.appName("spark-text-process").getOrCreate()
sms = spark.read.csv('../da... | true |
5547d8bc4b5a30a322d479a9daba69e30512130f | AnonymousAccountSE/NameSpotter_OnlineRepos | /Code/NameSpotter/preprocess/preprocess_method_name.py | UTF-8 | 1,713 | 2.953125 | 3 | [] | no_license | import json
text_list = []
label_list = []
with open("E:\IdentifierQuality\BadNames\DataLabeling\\NameAndScoreSplit.txt",'r') as f:
lines = f.readlines()
for line in lines:
text_list_each = ""
print(line.strip())
line_array = line.split(" ")
for i in range(0, len(line_array))... | true |
5a4ea929423c8556fb68e8769d82e1df9c96724e | takatogoto/textmining | /code/ch05/list5-8_neko-sanshiro-kokoro-TFIDF.py | UTF-8 | 1,332 | 2.78125 | 3 | [] | no_license | # -*- coding: utf-8 -*-
# リスト 5-8 『吾輩は猫である』『三四郎』『こころ』の TF-IDF を計算するプログラム例
import numpy as np
import pandas as pd
import MeCab
from aozora import Aozora
from sklearn.feature_extraction.text import TfidfVectorizer
#
aozoradir = "./"
m = MeCab.Tagger("-Owakati") # MeCabで分かち書きにする
files = ['wagahaiwa_nekodearu.txt', 'san... | true |
f2ba49cd6404940d0ccd0e1ca4582b395ad61425 | hsorby/utilityscripts | /src/python/transform_script.py | UTF-8 | 700 | 2.796875 | 3 | [
"Apache-2.0"
] | permissive | #!/usr/local/bin/python3
import os
from shutil import copyfile
def main():
with open("missing.txt") as f:
lines = f.readlines()
print(lines[0].split(' '))
for line in lines:
parts = line.split(' ')
reference = parts[2]
relative_path = reference.replace('http://localhost:50... | true |
9b57322a7f7eafd1f3c7eff456207b78923f733a | deepanshib/VideoSummarization | /video_sum_updated.py | UTF-8 | 3,725 | 2.875 | 3 | [] | no_license | #Brute-Force Matching with ORB Descriptions
import cv2
import glob
import operator
import itertools
import sys
import numpy as np
import timeit
dataSet = "/home/lp2/dataset/PTZ_Camera/PTZ/PTZ/intermittentPan/input/*.jpg"
#dataSet = "/home/lp2/workspace/BackgroundSubtraction/input/*.jpg"
orb = cv2.ORB()
def imagePre... | true |
0a02591cd7d8ea9d93f8ba81575558bca2c8bd14 | Commiter16/MobileNetV2-SSDLite-tf2 | /image_utils.py | UTF-8 | 8,232 | 2.84375 | 3 | [
"MIT"
] | permissive | import os
from PIL import Image
import matplotlib.pyplot as plt
import matplotlib.patches as patches
import random
import numpy as np
import tensorflow as tf
import io
from box_utils import decode, compute_nms, compute_iou
class ImageVisualizer(object):
""" Class for visualizing image
Attributes:
idx_... | true |
3e5e22dac02d1c9c5c39969616c446f2b39d5f6a | mala-project/mala | /mala/datahandling/lazy_load_dataset.py | UTF-8 | 10,212 | 2.765625 | 3 | [
"BSD-3-Clause"
] | permissive | """DataSet for lazy-loading."""
import os
try:
import horovod.torch as hvd
except ModuleNotFoundError:
# Warning is thrown by Parameters class.
pass
import numpy as np
import torch
from torch.utils.data import Dataset
from mala.common.parallelizer import barrier
from mala.common.parameters import DEFAULT_... | true |
555711a5a7b16fb8e2b8f1fd19beee8fa5b2448c | kopok2/CodeforcesSolutionsPython | /src/186A/test_cdf_186A.py | UTF-8 | 922 | 2.59375 | 3 | [
"MIT"
] | permissive | import unittest
from unittest.mock import patch
from cdf_186A import CodeforcesTask186ASolution
class TestCDF186A(unittest.TestCase):
def test_186A_acceptance_1(self):
mock_input = ['ab', 'ba']
expected = 'YES'
with patch('builtins.input', side_effect=mock_input):
Solution = C... | true |
3e8dcf259ecfa6b255b643b632276603f413bc18 | riven314/WebCrawler-Collections | /Tokyo_Marathon/GetAllRunners_ParallelRun_2.py | UTF-8 | 7,661 | 2.578125 | 3 | [] | no_license | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue May 8 02:13:39 2018
@author: Alex Lau
"""
import requests
import bs4 as bs
import os
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
from time import sleep
import pandas as... | true |
1f35f14aa3c44edb53306d02a43b3281ea0c649c | aaronwlma/AniSight | /animeData.py | UTF-8 | 3,324 | 3.421875 | 3 | [] | no_license | ################################################################################
# Anime Data Object
################################################################################
# @author Aaron Ma
# @description Class to define Anime object with associated functions
# @date January 28th, 2019
#... | true |
8af32b54d63013db2333ba2ee2214c729eec65a1 | Aasthaengg/IBMdataset | /Python_codes/p03568/s746691480.py | UTF-8 | 123 | 2.796875 | 3 | [] | no_license | N = int(input())
A = list(map(int, input().split()))
cnt = 1
for i in A:
if not i%2:
cnt *= 2
print(3**N-cnt) | true |
72befe1c523a47df49094023338cff60b22b9b6e | chicm/atlas | /overlap.py | UTF-8 | 13,781 | 2.53125 | 3 | [
"MIT"
] | permissive |
import pandas as pd
def update_sub(submission_df):
submission_df.loc[submission_df['Id']=='a8d73536-bad8-11e8-b2b9-ac1f6b6435d0', 'Predicted'] = '0 23'
submission_df.loc[submission_df['Id']=='63ed01a4-bad7-11e8-b2b9-ac1f6b6435d0', 'Predicted'] = '14 16'
submission_df.loc[submission_df['Id']=='84c046b4-bad... | true |
ffe75cb035ed616c3ee2ee06a9a977298a70b503 | JuliaChae/ESC180 | /lab4/counterlib.py | UTF-8 | 323 | 3.3125 | 3 | [] | no_license | """This library defines a class for an object counter and includes functions to increment and return the value of the object."""
class counter:
def __init__(self, initCnt):
self.cnt = initCnt
def evolve(self, x):
self.cnt = self.cnt + x
return True
def getState(self):
return self.c... | true |
179056d53b1d6cf50ce43feb0dbc67732e4c7138 | mterkek/bs4_weather_parsing | /soup_parse.py | UTF-8 | 889 | 3.09375 | 3 | [] | no_license | #bs4 parsing
from bs4 import BeautifulSoup as BS
import requests
# tanımlamalar
# url üzerinden site verilerini çek
url = "https://weather.com/en-IN/weather/tenday/l/453cfbbd56d2feadb92b63729bbdfb0e278db70a2bae2d700e3c2a20c8efb7ae"
webpage = requests.get(url)
# çekilen verileri BS üzerinden tanıml
soup = BS(webpage... | true |
c9ef5842d973d2e4b8fbe16c50803af7ca4fe53f | litex-hub/fpga_101 | /lab002/solutions/core.py | UTF-8 | 3,607 | 3.234375 | 3 | [
"BSD-2-Clause"
] | permissive | from migen import *
# Goals:
# - understand how to create simple logical core
# - understand how to create a FSM
# Indications:
# You can choose to code the clock core with only
# - If/Elif/Else in Migen:
# https://m-labs.hk/migen/manual/fhdl.html#statements
#
# or with
#
# - a FSM in Migen:
# https://github.com/m-la... | true |
d9cb56dc40cc8c8a9465517c67eccf077e70d2ab | aiyueqi/leetcode | /python/a102.py | UTF-8 | 1,391 | 3.328125 | 3 | [] | no_license | # Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution:
def levelOrder(self, root: TreeNode) -> List[List[int]]:
queue = []
level_queue = []
result = []
if root... | true |
6a9be82b59f6c19844f587aaa6cf5a92e3c7268e | hero24/python-notes | /matmul_example.py | UTF-8 | 1,567 | 3.9375 | 4 | [] | no_license | #!/usr/bin/env python3
# "Programs must be written for people to read, and only incidentally for machines to execute."
# ~ Harold Abelson
__author__ = "hero24"
# python 3.5 brings in a new operator @
# its a matrix multuplier, and has no use in
# python standard library.
# note this shows how to implement and use ne... | true |
5f14bc220fa49f3cf1c9f5198500e73df2f220ac | aniketdn/WAPChallenges | /WAP2.py | UTF-8 | 603 | 2.703125 | 3 | [] | no_license | import itertools
import requests
import json
password=(list(map("".join, itertools.product('mno', repeat=5))))
email=['nick@pentesteracademy.com','admin@pentesteracademy.com']
for username in email:
for passw in password:
url='http://pentesteracademylab.appspot.com/lab/webapp/auth/1/loginscript?email='+us... | true |
71db3c127edabdfaaa0b7b02fb9fadf96456de6b | iakinsey/things | /test/test_operator.py | UTF-8 | 950 | 3.484375 | 3 | [
"MIT"
] | permissive | import things
import unittest
from queue import Queue
class TestPutOperator(unittest.TestCase):
def test_put(self):
'''
Send a message to an actor using the put sugar syntax.
'''
# use a queue
queue = Queue()
message = "hello world"
class Actor(things.Acto... | true |
0e74c02c0c3fe736e1831c954c986be9f598414d | jJayyyyyyy/network | /application_layer/http/simple_client/simple_server.py | UTF-8 | 365 | 2.78125 | 3 | [] | no_license | def main():
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(('github.com', 80))
s.send(b'GET / HTTP/1.1\r\nHost: github.com\r\nConnection: close\r\n\r\n')
buf = []
while True:
d = s.recv(1024)
if d:
buf.append(d)
else:
break
data = b''.join(buf)
print(data.decode())
... | true |
a0b1005911b36319b391ff0076dd632b44549b74 | WaterCopy/MikeLabProj | /ESEMPIO_MAHDI_binutils.py | UTF-8 | 2,298 | 3.40625 | 3 | [] | no_license | # Bitwise n-gram preprocessing version 0.1 (8/6/19) Tim Brailsford
from builtins import map
from builtins import range
import binascii
import itertools
# returns binary representation of a string (without the 2-character header)
def text2bin(str):
binStr = bin(int(binascii.hexlify(str.encode('ascii')), 16))
... | true |
6db3bdb60f4df99049ac738c5f93e4b9129995db | klopezpinto/tytus | /storage/team18/storage/Interfazz.py | UTF-8 | 42,658 | 2.625 | 3 | [
"MIT"
] | permissive | import Storage
import BplusTree
import tkinter
from tkinter import *
from tkinter import messagebox
from tkinter import filedialog
from tkinter.filedialog import askopenfile
import os
def show_data_bases():
data_bases = Storage.showDatabases()
database_tree = Storage.serializable.Read('./Data/', 'Databases')
... | true |
7c317da1f4ee5da9ae2e97203b4325a06a94d6cc | kierensharma/Cryo_EM_Data_Analysis | /image_classification_dnn.py | UTF-8 | 1,596 | 2.734375 | 3 | [] | no_license | from numpy.random import seed
from tensorflow.random import set_seed
seed(0)
set_seed(0)
from keras.datasets import fashion_mnist
from keras.utils import to_categorical
from keras.models import Sequential
from keras.layers import Dense
from keras.optimizers import SGD
from sklearn.model_selection import train_test_spl... | true |
62cc5479389410a439b7623d75ee706b73aa0da1 | Yanqin25/AndrewNgMacheLearn | /work/machine-learning-ex3/ex3_py/ex3.py | UTF-8 | 3,308 | 3.59375 | 4 | [] | no_license | from predictOneVsAll import predictOneVsAll
from oneVsAll import oneVsAll
from lrCostAndGradFunction import lrCostFunction, lrGradFunction
from displayData import displayData
import numpy as np
from scipy.io import loadmat
import matplotlib.pyplot as plt
# Machine Learning Online Class - Exercise 3 | Part 1: One-vs-all... | true |
d32f212d90a4851a42ee9b68fc8c0c0ffd1af5f6 | emanueldumitru/flask-bootcamp-marcial | /complete-python-developer-2021/First sections/decorators.py | UTF-8 | 1,089 | 4.1875 | 4 | [] | no_license | # higher order functions - function that accept another functions
def greet(func):
x = func()
print(x)
def greet2():
def functie():
return 5
return functie
#decorator add extra feature to functions
def hello():
print('hellooooo')
def my_decorator(func): #*args, **kwargs
de... | true |
4b527dd0280b5f38911c4195294ce03621daf44c | kivio/python-quickchart | /drawing/abstractchart.py | UTF-8 | 3,170 | 3.453125 | 3 | [] | no_license | """
.. moduleauthor:: Marcin Karkocha <kivio@kivio.pl>
AbstractPlot is class to draw coordinate system (Cartesian is default)
configuration options:
- arrows: color, direction, shape
- line size and color
- scale - named and unnamed, size, color
- axis names - font, size, location
"""
fro... | true |
9737d166f50c05ecc0264c8f13f3aa63b139200c | JaySurplus/CS430 | /homework/project/simhash.py | UTF-8 | 3,097 | 3.328125 | 3 | [] | no_license |
class simhash():
def __init__(self, tokens='', hashbits=128):
self.hashbits = hashbits
self.hash = self.simhash(tokens)
def __str__(self):
return str(self.hash)
def __long__(self):
return long(self.hash)
def __float__(self):
return float(self.hash)
de... | true |
4d49e19678346927aa74632cd278544f9ed8b971 | VeniZhang/FlyGuys | /code/server/socket/server.py | UTF-8 | 1,281 | 2.515625 | 3 | [] | no_license | #!/usr/bin/python
# -*- coding: utf-8 -*-
# @Author homeway
# @Link http::homeway.me
# @Github https://github.com/grasses
# @Version 2018.06.02
'''
Socket服务端,用于FlyGuys数据传输
'''
import json
from websocket_server import WebsocketServer
# Called for every client connecting (after handshake)
def new_client(client, server... | true |
5e9dc223bccc109debc8237b8644a32fc53ce142 | 1218muskan/MarchCode | /Day 3/Aayushi-Mittal.py | UTF-8 | 833 | 4.5 | 4 | [
"MIT"
] | permissive | # Write a program to find out the total number of days in a given month.
month = input("Enter a month name (in lower case) : ")
if month == "january" or month == "march" or month == "may" or month == "july" or month == "august" or month == "october" or month == "december":
print("\n> " + month + " has 31 days")
el... | true |
ec0ab603546861dcc974068e8e92f7f958299ed0 | KAZYPinkSaurus/netcleanser | /tests/test_url.py | UTF-8 | 2,016 | 2.984375 | 3 | [
"MIT"
] | permissive | from netcleanser import Url
import urllib
def test_valid_url():
url_string = 'https://www.google.com/search?q=testing'
url = Url(url_string)
assert url.scheme == 'https'
assert url.host == 'www.google.com'
assert url.domain == 'www.google.com'
assert url.registered_domain == 'google.com'
... | true |
e0e90808a8196d8659b34dbc55dc46af045a6f54 | Kohei312/Python_practice | /basic/algorythmn/chapter4/eight_queen.py | UTF-8 | 1,442 | 3.46875 | 3 | [] | no_license | ## 8クイーン問題
## 8*8 の盤面に、チェスのクイーンを8体配置する
## ルール : 前後斜めに移動できるクイーンのルートと重ならないように、各自配置すること
maze = [
[9,9,9,9,9,9,9,9,9,9,9,9],
[9,0,0,0,9,0,0,0,0,0,0,9],
[9,0,9,0,0,0,9,9,0,9,9,9],
[9,0,9,9,0,9,0,0,0,9,0,9],
[9,0,0,0,9,0,0,9,9,0,9,9],
[9,9,9,0,0,9,0,9,0,0,0,9],
[9,0,0,0,9,0,9,0,0,9,1,9],
[9,0... | true |
aa4c7e2d41c93cd74caef885ca5396c379b550e9 | arun-ava/Titanic-Kaggle | /Titanic-v2.py | UTF-8 | 5,895 | 3.109375 | 3 | [] | no_license | """
Using Minsuk Heo's approach
https://www.youtube.com/watch?v=COUWKVf6zKY&t=12s
"""
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
from sklearn.ensemble import RandomForestClassifier
from sklearn.impute import SimpleImputer
import numpy as np
import seaborn as sns
import matplotlib.pyplot as ... | true |
1ef77ddb4221c10752202522912c9d46c6806868 | stanman71/Python_Small_Projects | /_test/jobs.py | UTF-8 | 986 | 2.734375 | 3 | [
"MIT"
] | permissive | from flask import Flask
from flask_apscheduler import APScheduler
class Config(object):
JOBS = [
{
'id': 'job1',
'func': 'jobs:job1',
'args': (1, 3),
'trigger': 'interval',
'seconds': 10
},
{
'id': 'job2'... | true |
ca5864de61fab16cb24ce6f6062331787063e843 | tomasmussi/tda | /tp3/sabotage.py | UTF-8 | 4,278 | 3.03125 | 3 | [] | no_license | import os.path
import sys
import csv
import copy
from grafo import Grafo
import operator
MAX_PROTECTED = 2
def read_net(file_net):
net = Grafo()
vertices = {}
edges = {}
with open(file_net, 'rb') as csvfile:
spamreader = csv.reader(csvfile, delimiter=' ')
for row in spamreader:
v1 = int(row[0])
v2 = int... | true |
be18473a33aa837e6996f81ef42188e23d13c18f | cgxabc/Online-Judge-Programming-Exercise | /Lintcode/CountCharacters.py | UTF-8 | 485 | 3.765625 | 4 | [] | no_license | #!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Created on Wed Jan 24 23:23:16 2018
@author: apple
"""
"""
Count characters in a string. Return a hash map which key is character and value is the occurrency of this character.
Example
Given str = "abca", return
{
"a": 2,
"b": 1,
"c": 1
}
"""
def countCharact... | true |
4a6baa2df4e05a7dbcbcef93fb0a1ce58d46dd37 | phatakp/Data-Structure---Algos | /Union-Find/quick_find.py | UTF-8 | 1,951 | 3.984375 | 4 | [] | no_license | '''
Given a list of N integers and n connected components, find if two components are connected
- Takes only 1 access to find the root of the object N
- Takes N^2 accesses to perform N union operations on N objects
'''
from random import randint
from timing import timing
class QF:
N = 10000
... | true |
ec7f0aab4a0593f17cdeb0c851f30a6a76d5217a | Teapok/Python_labs | /Lab_1/3_passwordizer.py | UTF-8 | 617 | 3.65625 | 4 | [] | no_license |
Input = int(input('введите пароль (16 цифр): '))
def separate(x):
r=[x%10]
while x>10:
x=int(x/10)
r.insert(0,x%10)
return r
Pass=[]
Pass.extend(separate(Input))
i=0
while i<16:
if i>3 and i<12:
Pass.pop(i)
Pass.insert(i,"*")
i+=1
continue
i+=1
print(''.join(map(str,P... | true |
16477ff425eb93a05ad253a151348dfee5ae32a9 | axelri/fluffy_spheres | /physics.py | UTF-8 | 2,151 | 3.125 | 3 | [] | no_license | from vector import *
from GJK import GJK
GRAVITY = Vector([0.0, -10.0, 0.0])
dt = 0.0015
def collision_response(shape1, shape2, collisionInfo):
collisionPoint, penetrationNormal, penetrationDepth = collisionInfo
mass1 = shape1.get_mass()
mass2 = shape2.get_mass()
if mass1 > 1000:
invMass1 =... | true |
e6609122dd1d15bc0b7e1504c4141698010fc389 | Pri-Goes/Python | /Str.py | UTF-8 | 407 | 3.390625 | 3 | [] | no_license | nome = str(input(" Qual é o seu nome? "))
idade = str(input("Qual é a sua idade? "))
religiao=str(input("Qual a sua religiao? "))
nomemae=str(input("Qual o nome da sua mae? "))
nomepai=str(input("Qual o nome do seu pai? "))
print("Meu nome é" ,nome)
print("Minha idade é" ,idade)
print("Minha religiao é" ,rel... | true |
ae836def31357e207335430adf1452e196f74cd5 | sandragyaguez/MetricasFormales | /static/refresh_metric/postGoogle/getCookies.py | UTF-8 | 333 | 2.5625 | 3 | [
"Apache-2.0"
] | permissive | # -*- coding: utf-8 -*-
from selenium import webdriver
import time, pickle
driver = webdriver.Chrome('./chromedriver')
print "Chrome browser will be opened."
driver.get("http://www.plus.google.com")
mode=raw_input('Press enter when you have registered.')
pickle.dump( driver.get_cookies() , open("cookies.pkl","wb"))
... | true |
eebec416bf2d230fdff3134469c2f48da7398984 | lnsongxf/riskdash | /Aggregator/statistics/HacRegression.py | UTF-8 | 1,339 | 3.0625 | 3 | [] | no_license | '''
Created on Apr 12, 2014
@author: Hanwen Xu
Calculates the regression coefficients and the HAC "heteroskedasticity
and autocorrelation consistent estimator)
Parameters:
y The dependent variable An nx1 vector
X The covariates. An nxk vector
truncation_lag_to_observations_ratio The truncation lag to number of
observ... | true |
b74864d876647c240db6e7247d361fb16d2733f7 | Haohao99/Gobang | /piece.py | UTF-8 | 800 | 3.53125 | 4 | [
"MIT"
] | permissive | import pygame
import os
black = pygame.image.load(os.path.join("img", "black_piece.png"))
white = pygame.image.load(os.path.join("img", "white_piece.png"))
class Gobang():
boardSize = (80, 80, 510, 510)
initialX = boardSize[0]
initialY = boardSize[1]
def __init__(self, row, col, color):
... | true |
256587696dabde4390000bccd2c76c0e037747d5 | ishanz/cs4750-project | /models.py | UTF-8 | 2,039 | 2.8125 | 3 | [] | no_license | from flask.ext.login import UserMixin
import psycopg2
# Take care of User model
class UserNotFoundException(Exception):
pass
class User(UserMixin):
"""
Provides a User model for Flask-Login authentication
"""
# Main connection to the database
# Fetch usernames, passwords, and account types
... | true |
4136cd98b721da791ece7c0fcb68e36da4876c59 | thientt03/C4E26 | /C4E26/Dark.py/checklogin.py | UTF-8 | 708 | 3.4375 | 3 | [] | no_license | # username = input("Nhập username : ")
# password = input("Nhập password : ")
loop = True
while loop:
username = input("Nhập username : ")
password = input("Nhập password : ")
if not (username.isalnum() and password.isalnum()):
print("Sai username hoặc password")
else:
... | true |
967f0ec32ed498098753ec953771e1306a6fe6c5 | maxim-s-barabash/pytzsub | /pytzsub/fs.py | UTF-8 | 2,273 | 3.03125 | 3 | [
"MIT"
] | permissive | # MIT License
# Copyright (c) 2020 Maxim Barabash
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge,... | true |
ca4d37d0ebdec4a40905ab6ebe4bc19959535ede | arbrown93/Boston_Development_Map | /boston_zones.py | UTF-8 | 328 | 2.640625 | 3 | [
"MIT"
] | permissive | import shapefile as shp
zipcode = '02122'
sf = shp.Reader("../shapefiles/boston_parcels/boston_parcels")
i=0
for shape in sf.shapeRecords():
if (i<=1):
x = [i[0] for i in shape.shape.points[:]]
y = [i[1] for i in shape.shape.points[:]]
print(shape.record())
i+=1
... | true |
d51dfe554bbe39e1be161d930f62bb8f69296559 | maithinhatlan/baitappythonn | /code/Series/vd4.py | UTF-8 | 73 | 2.828125 | 3 | [] | no_license | import pandas as pd
ser = pd.Series(5, index=[1, 2, 3, 4, 5])
print(ser) | true |
079aac97a45a9772569edb5542a133ab798e0d46 | rpaudel42/cdg | /cdg/util/freeze.py | UTF-8 | 2,332 | 2.625 | 3 | [
"BSD-3-Clause"
] | permissive | # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
# Description:
# ---------
# Class with freezable attributes (`Freezable`) and a direct use of it
# (`Parameters`).
#
#
# --------------------------------------------------------------------------------
# Copyright (c) 2017-2018, Daniel... | true |
b703190e77f312766854c5326268d1631ac9c7b0 | ThomasMPorter/BlackFridayExtractor | /src/test/tmpimgur/testConnection.py | UTF-8 | 1,233 | 2.703125 | 3 | [
"Unlicense"
] | permissive | import configparser
import unittest
import tmpimgur
#----------------------------
# Set to your cfg file
cfg_file = 'src/local.cfg'
#----------------------------
class testConnection(unittest.TestCase):
def test_create_album(self):
# Arrange
connection = get_test_connection()
album_titl... | true |
fc705091c7877fb1aab6385bf912acef509f2fd3 | chalios/hackmud_chat_py | /examples/advertizer.py | UTF-8 | 392 | 2.71875 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env python
#~*~ coding: utf-8 ~*~
from hackmud_chat import Account
from time import sleep
acct = Account(token='yourtoken')
user = acct.get_user('user')
channel = user.channels[0].name
message = '''Message Of The Day:
The sky is blue and the sun is shining.
'''
try:
while True:
user.say(... | true |
13bd2e1a71321c00d922665134c3fd3188b6f920 | mukherjeesagar/training | /check_args.py | UTF-8 | 280 | 3.40625 | 3 | [] | no_license | import sys
args=(sys.argv)[1:]
try:
args[0]=int(args[0])
print("1st-success")
except ValueError:
print("First arguement isn't integer")
try:
args[1]=float(args[1])
print("2nd-success")
except ValueError:
print("Second arguement isn't float") | true |
7369e00aebd925a3bedaf09dcaf2d377acd121ee | IriskaKhrushch/PythonCore | /Homework7/Count of positives sum of negatives.py | UTF-8 | 276 | 3.03125 | 3 | [] | no_license | def count_positives_sum_negatives(arr):
sum=0
count=0
list=[]
if arr != []:
for i in arr:
if i > 0:
count+=1
elif i < 0:
sum +=i
list.append(count)
list.append(sum)
return list | true |
2cad1260e06f5e589f92aa57670bbbacd6f51d2d | abdulkaderlougue/CMPUT-175 | /Labs/lab 1/lab1 Q1.py | UTF-8 | 778 | 2.90625 | 3 | [] | no_license | file = open('rainfall.txt', 'r')
newFile = open('rainfallfmt.txt','w')
a = []
b = []
c = []
d = []
for line in file:
el = line.split()
if 60<= float(el[1])<=70:
a.append(el)
elif 71< float(el[1])<=80:
b.append(el)
elif 81< float(el[1])<=90:
c.append(el)
elif 91< float(el[1]):... | true |
34dff4706a87bd0fa585936f7491ab41f2f99987 | safaranees/anees5 | /kthsmallestnumber.py | UTF-8 | 88 | 2.75 | 3 | [] | no_license | num11,num21=map(int,input().split())
arr=input().split()
arr.sort()
print(arr[num21-1])
| true |
1369e279bfaa7a23e7e4e2ec6ab13e26e66a4d15 | uq-courtois/digitalanalytics-snippets | /checkdimension.py | UTF-8 | 932 | 4.0625 | 4 | [] | no_license | import pandas as pd
df = pd.read_csv('imdb_data.csv', delimiter = ';') # Import data
print(df.info()) # Print information on dataframe df
print(df) # Print overview of df values
pd.set_option('display.max_columns',10) # Forcing to show all 10 colums
print(df) # Print overview of df values
print(df['title']) # Over... | true |
58738dd24a4c2f8f5c7563a5a5d184a70784eeb2 | yemao616/summer18 | /Google/2. medium/373. Find K Pairs with Smallest Sums.py | UTF-8 | 1,816 | 3.609375 | 4 | [] | no_license | # You are given two integer arrays nums1 and nums2 sorted in ascending order and an integer k.
# Define a pair (u,v) which consists of one element from the first array and one element from the second array.
# Find the k pairs (u1,v1),(u2,v2) ...(uk,vk) with the smallest sums.
# Example 1:
# Given nums1 = [1,7,11], n... | true |
f3cab93b420ce71345eacd852eb1c0e52011abed | Naoismywaifu/Spampython | /spammer.py | UTF-8 | 158 | 2.5625 | 3 | [] | no_license | import pyautogui, time #pip install pyautogui
time.sleep(10)
f = open("spam", 'r')
for word in f:
pyautogui.typewrite(word)
pyautogui.press("enter")
| true |
18c11319f05cc92827c731bbffaa3cc74045c204 | LynnYeonjuLee/TIL_BMS2 | /python_bms/ALGORITHMS/SWEA/알고리즘수업/8월월말평가대비/비트연산.py | UTF-8 | 164 | 3.421875 | 3 | [] | no_license | a = 5 # 0101
b = 3 # 0011
print(a & b) # 0001, 논리곱
print(a | b) # 0111, 논리합
print(1 << 3) # 0001 -> 1000 2^3
print(a ^ b) #0110, 익스클루시브
| true |
f57aa723902f22d254b8147e86e8fe74224b20cd | Verarind/pydsb | /pydsb.py | UTF-8 | 1,955 | 2.609375 | 3 | [
"MIT"
] | permissive | import bs4
import requests
from datetime import datetime
class PyDSB:
BASE_URL = "https://iphone.dsbcontrol.de/iPhoneService.svc/DSB"
ZERO_VALUE = "00000000-0000-0000-0000-000000000000"
def __init__(self, username=None, password=None):
self.username = username
self.password = password
... | true |
7585c650484d54b2ab3a019ccdd7231fe298c39b | Subhash8969/bobby | /while loop.py | UTF-8 | 896 | 3.59375 | 4 | [] | no_license | '''i=0
while i<=10:
print(i)
i=i+1'''
#**************************
'''n=10
sum=0
i=1
while i<=n:
sum=sum+i
i=i+1
print(sum)'''
#*************************
'''n=0
while n<=3:
print("subhash")
n=n+1
else:
print("bobby")'''
#************************
'''n=int(input("take a numb... | true |
98bbbfb1346e69d33059603e37960eaac47f913a | CapSOSkw/GoogleFoobar | /minion_task_scheduling.py | UTF-8 | 749 | 2.875 | 3 | [] | no_license | def answer(data, n):
# your code here
count_jobs_dict = ((i, data.count(i)) for i in data)
# job_index = [i[0] for i in count_jobs_dict]
# job_count = [i[1] for i in count_jobs_dict]
# max_count = max(job_count)
job_index, job_count = [], []
for i in count_jobs_dict:
job_index... | true |
18fc6be3a852be59f7dbef81c0d758fe4c73a267 | aldnav/cloudyhandicapgov | /server.py | UTF-8 | 985 | 2.71875 | 3 | [] | no_license |
""" MAIN APP SERVER """
import json
import dataset
from flask import Flask, render_template, Response
app = Flask(__name__)
db = dataset.connect('sqlite:///mydb.db')
table = db['tweets']
@app.route("/")
def index():
""" Displays index page """
return render_template('index.html')
@app.route("/api/reports... | true |
a719991c0691dedd76884329c312ee4e9accdc1f | DaHuO/Supergraph | /codes/CodeJamCrawler/16_0_4_neat/16_0_4_arahul_4.py | UTF-8 | 179 | 3.421875 | 3 | [] | no_license | t=int(input())
case=0
for _ in range(t):
case+=1
k,c,s=map(int,input().split())
print("Case #"+str(case)+":", end=" ")
for i in range(1,k+1):
print(str(i),end=" ")
print()
| true |
aa9186d76948e53852a61fa06a549fb871142724 | ARAV0411/HackerRank-Solutions-in-Python | /Collections defaultdict.py | UTF-8 | 481 | 3.34375 | 3 | [] | no_license | # Enter your code here. Read input from STDIN. Print output to STDOUT
from collections import *
n, m = map(int, raw_input().split())
A= [raw_input() for i in range(n)]
B= [raw_input() for i in range(m)]
d= defaultdict(list)
index=0
for i in A:
d[i].append( A.index(i, index) + 1)
index+=1
for i in B:
... | true |
c20b4758151528e462717f34f1d8f5c7abc3d87e | santanu5670/Python | /coding/11/operator_overloading.py | UTF-8 | 496 | 3.6875 | 4 | [] | no_license | class Number:
def __init__(self,num): #This type of method is called dender method
self.num=num
# print(num)
def __add__(self,num2): #This type of method is called dender method
return self.num+num2.num
# print(num2.num)
def __mul__(self,num2): #This type of method is called ... | true |
eeda9624cc9aab089005c0762cb85e55d28cbbe9 | dufourc1/Bayesian_computation | /src/maths/mat.py | UTF-8 | 371 | 2.53125 | 3 | [
"Apache-2.0"
] | permissive | """
module for matrix manipulation
"""
import autograd.numpy as np
def sym(M):
return 0.5 * (M + np.transpose(M))
def exp(M):
u, s, v = np.linalg.svd(M)
return np.matmul(u, np.matmul(np.diag(np.exp(s)), v))
def log(M):
u, s, v = np.linalg.svd(M)
return np.matmul(u, np.matmul(np.diag(np.log(s)), v... | true |
c0e660e95c6ed5a3d51fa86482118872d18ad404 | jli124/leetcodeprac | /394DecodetheStrign.py | UTF-8 | 2,172 | 3.875 | 4 | [] | no_license | # 394. Decode String(M)
"""
Given an encoded string, return its decoded string.
The encoding rule is: k[encoded_string], where the encoded_string inside the
square brackets is being repeated exactly k times. Note that k is guaranteed
to be a positive integer.
You may assume that the input string is always valid; No... | true |
66a20b6d6decd0528ac9d3094436adf07c34307e | mkebrahimpour/DataStructures_Python | /LeetCode/twosum_sortedlist.py | UTF-8 | 568 | 3.21875 | 3 | [] | no_license | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun May 19 02:32:27 2019
@author: sbk
"""
class Solution(object):
def twoSum(self, numbers, target):
"""
:type numbers: List[int]
:type target: int
:rtype: List[int]
"""
i, n = 0, len(numbers) - 1
... | true |
df3ccb0fd9e946470f4995158274f441c98f4e48 | zack0705/algorithms | /0-1_knapsack.py | UTF-8 | 402 | 3.390625 | 3 | [] | no_license | def max(a,b):
if(a>=b):
return a
return b
def knap(item,weight):
a = []
for i in range(len(item)+1):
for j in range(weight+1):
if(j==0):
a.append([0])
elif(i==0):
a[i].append(0)
elif(item[i-1][0]<=j):
a[i].append(max(item[i-1][1]+a[i-1][j-item[i-1][0]],a[i-1][j]))
else:
a[i].append(... | true |
12778f46406b9a68d182228021fc530b32271b71 | rsicart/deviceid-test-browsers | /common/database.py | UTF-8 | 817 | 2.515625 | 3 | [] | no_license | import sqlite3
class Database:
def __init__(self, folder, db_name, db_table):
self.folder = folder
self.db_name = db_name
self.db_table = db_table
self.db_connection = None
self.db_cursor = None
def setup(self):
self.db_connection = sqlite3.connect('%s/%s' % ... | true |
9872b13ab8866fc349dbda3502a4929edaf96cdc | rmohammedadil/adil_workshop | /adil_workshop/adil-mohammed-au9-dev/assignments/week05/Day5/asg.py | UTF-8 | 398 | 3.375 | 3 | [] | no_license | class student:
def __init__ (self, name ,age, roll_no):
self.name = name
self.age = age
self.roll_no = roll_no
def mark_attendence(self):
print("student",self.name,"is marked attendence")
print("student",self.name,"is marked attendence")
if __name__ == "__main__":
stu... | true |
8cbe162cc8cd0fbbdcaba2cc3134be9f1cb660c2 | DrM00G/space-game | /src/OLD/board.py | UTF-8 | 1,731 | 3.28125 | 3 | [] | no_license | class Board:
def __init__(self,board_size):
self.board_size = board_size
self.positions = [[[[],[]] for x in range(board_size[0])] for y in range(board_size[1])]
def setup(self,planets,players):
for planet in planets:
if planet.colony_status == True:
self.positions[planet.... | true |
47070128364f067ecd79b0757f5c439446147fe4 | kashish1007/letsupgrade.assignment | /Lets Upgrade Assignment 2.py | UTF-8 | 458 | 4.3125 | 4 | [] | no_license | # Question 1
# Delete all occurrences of an element in a list
list_1 = [1,2,3,4,4,5,5,6,7,8,8]
print(set(list_1))
# Question 2
# Check whether a string is a pangram.
import string
def pangram(text):
alpha = "abcdefghijklmnopqrstuvwxyz"
for x in alpha:
if x not in text.lower():
... | true |
f451af2726a180cf267f93f13c0c8e3ddccb4b68 | milhauszn/muj-pyth | /gadget_command.py | UTF-8 | 596 | 2.78125 | 3 | [
"Apache-2.0"
] | permissive | """
Simple demo for sending commands to the TURRIS:DONGLE.
It can be used for sensor registration, etc.::
>> python gadget_command.py "GET SLOT:01"
SENDING: GET SLOT:01
REPLY: SLOT:01 [07473725]
>> python gadget_command.py SET SLOT:03 [07439975]
SENDING: SET SLOT:03 [07439975]
REPLY: OK
"""
... | true |
efd92300e5eb857ba8e2a8d54987366667029d75 | he9mei/python_appium | /learning_pytest/test_14_maxfail.py | UTF-8 | 532 | 2.5625 | 3 | [] | no_license | #!/usr/bin/python3
# -*- coding: utf-8 -*-
import pytest
'''
-x 失败即停止
--maxfail 2 失败2个就停止
'''
class TestDemo:
def test_demo1(self):
assert True
def test_demo2(self):
assert True
def test_demo3(self):
assert False
def test_demo4(self):
assert False
def t... | true |
f2fde6179e5cd192c161bf3b4c2a84fbb7c9c439 | reschly/mjrcrypt | /details/MJRAES.py | UTF-8 | 10,664 | 3.375 | 3 | [
"Apache-2.0"
] | permissive | '''My AES Module'''
class AES(object):
'''An implementation of the AES Encryption Routine
Note that decryption is not implemented, as the
only mode that is planned to be supported is GCM
mode, which does not require the Decryption routine'''
# blocksize
_blocksize = 16
# byte... | true |
5d9c5e43b4f2152dba22adb5c5c3ce938892693d | miccls/OU4 | /ou4_2/ou4_2.py | UTF-8 | 912 | 3.0625 | 3 | [] | no_license | #!/usr/bin/env python3
from heltal import Heltal
from time import perf_counter as pc
from matplotlib import pyplot as plt
# For the splitting over two cores
import concurrent.futures as future
def time_fibb(method, rng):
lst = []
f = Heltal(rng[0])
for n in rng:
start = pc()
method(f)
lst.append(pc() - start... | true |
d99ecae75d2c6595fc89dd01ab1ae648c9fc260c | eriol/circuits | /circuits/core/bridge.py | UTF-8 | 3,527 | 2.640625 | 3 | [
"MIT"
] | permissive | """Bridge
The Bridge Component is used for inter-process communications between
processes. Bridge is used internally when a Component is started in
"process mode" via :meth:`circuits.core.manager.start`. Typically a
Pipe is used as the socket transport between two sides of a Bridge
(*there must be a :class:`~Bridge` i... | true |
d114d36f7b13263659b6ec62e4f8e876a2ccc207 | AroopN/Array-2 | /Problem1.py | UTF-8 | 301 | 3.40625 | 3 | [] | no_license | #
# Time Complexity = O(n)
# Space Complexity = O(1) We are manipulating the input array
#
def findDisappearedNumbers(nums):
for i in nums:
nums[abs(i)-1] = -abs(nums[abs(i)-1])
res= []
for i in range(len(nums)):
if nums[i]>0:
res.append(i+1)
return res
| true |
4db5230249a7d0a5c21da2f792466a7fb18a1490 | TroyChristian/Intro-Python-II | /src/adv.py | UTF-8 | 2,279 | 4.0625 | 4 | [] | no_license | #CLASSES
class Room():
def __init__(self, name:str, description:str):
self.name = name
self.description = description
self.n_to = None
self.s_to = None
self.e_to = None
self.w_to = None
def get_room_in_direction(self, direction):
if hasattr(self, f"{dire... | true |
1bb82de7859102a7a503526556996fe41c91d62e | ticoneva/data-analytics-course | /Examples/pytorch/hf2-8bit-inference.py | UTF-8 | 3,404 | 2.828125 | 3 | [] | no_license | # Run a large-language model in 8-bit precision.
# State-of-the-art large-language models (LLMs) are very powerful, but they
# often contain too many parameters to load into a single GPU in their native
# 32-bit precision. Loading the model in 8-bit or even 4-bit will cut the the
# memory requirement proportionally.
#... | true |
9f76646b80cb9f2cdb312f5bce28896b503b0a3b | IsraelAbebe/Personal-Projects-and-Exercises | /AIMS-Assignments/NLP/session3/session3/israel_azime_lab3_ngram.py | UTF-8 | 4,651 | 3.125 | 3 | [
"MIT"
] | permissive | import io, sys, math, re
from collections import defaultdict
import numpy as np
# GOAL: build a stupid backoff ngram model
def load_data(filename):
fin = io.open(filename, 'r', encoding='utf-8')
data = []
vocab = defaultdict(lambda:0)
for line in fin:
sentence = line.split()
data.appen... | true |
32f34dd8583c8e1d2ac5accfda72030af3afec1f | stripelf/linear-algebra | /第5章/5-6.py | UTF-8 | 207 | 2.75 | 3 | [] | no_license | import numpy as np
x = [2,2,4,8,4]
y = [2,6,6,8,8]
x = x - np.mean(x)
y = y - np.mean(y)
A = np.vstack((x,y))
p_1 = [0.707, 0.707]
p_2 = [-0.707, 0.707]
P = np.vstack((p_1,p_2))
print(A)
print(np.dot(P,A)) | true |
71034bfd5131ba51b28539ffece128dc2f9a7577 | AndyPythonCode/my_page_scraped | /main.py | UTF-8 | 1,421 | 3.03125 | 3 | [] | no_license | # from scraping.scraper import PageSources
from bs4 import BeautifulSoup
import csv
# Testing my own module
# page = PageSources('https://andycode.ga')
# page.get_current_html()
# page.save()
PAGE_FILE = './web_data/andycode_1.html'
PAGE_HTML: str
with open(PAGE_FILE, 'r') as html:
PAGE_HTML = html.read()
ht... | true |
99ef3272ba722f625f173e7887b831834509f57f | victorrrp/Python-Intermediario | /aula29_curso.py | UTF-8 | 2,077 | 4.4375 | 4 | [] | no_license | '''
Dicionário em Python (ou chave)
'''
#Criando um dicionário (formato padrão)
d1 = {'chave1':'valor da chave'}
d1['nova_chave'] = 'Valor da nova chave'
print(d1['chave1']) #acessando indice da chave
#Outra forma
d2 = dict(chave1 = 'Valor da chave', chave2 = 'Valor da outra chave')
d2['nova_chave'] = ... | true |
7fef1c75eea325c2e0f0d17ebd2e992661f77fd0 | LewDster560/python_tieba | /upupup.py | UTF-8 | 927 | 2.609375 | 3 | [] | no_license | from urllib import request
import urllib.parse
import random
word = {'学校': '太工'}
my_key = urllib.parse.urlencode(word)
url = 'http://www.baidu.com/s?' + my_key
ua_list = [
"Mozilla/5.0 (Windows NT 6.1; ) Apple.... ",
"Mozilla/5.0 (X11; CrOS i686 2268.111.0)... ",
"Mozilla/5.0 (Macintosh; U; PPC Mac OS X..... | true |
1961850363bf5e552bc74ecd2bf9a3fc9a32c1d3 | ChangXiaodong/Leetcode-solutions | /1/520-Detect_Capital.py | UTF-8 | 781 | 3.265625 | 3 | [] | no_license | def detectCapitalUse(word):
"""
:type word: str
:rtype: bool
"""
if not word:
return False
if word.islower():
return True
if word.isupper():
return True
if word.istitle():
return True
return False
def detectCapitalUse1(word):
"""
:type word: ... | true |