text stringlengths 0 1.05M | meta dict |
|---|---|
'''
Created on Mar 13, 2016
@author: Dead Robot Society
'''
import wallaby as w
# Start light threshold
startLightThresh = 2000
# TIME
startTime = -1
# Motor ports
LMOTOR = 0
RMOTOR = 3
# SERVO ports
frontArm = 0
frontClaw = 1
backArm = 2
backClaw = 3
# ANALOG ports
FRONT_TOPHAT = 0
R... | {
"repo_name": "gras/16-ValleyBot",
"path": "src/constants.py",
"copies": "1",
"size": "2072",
"license": "mit",
"hash": -3648507060537311700,
"line_mean": 20.0638297872,
"line_max": 56,
"alpha_frac": 0.6829150579,
"autogenerated": false,
"ratio": 2.8152173913043477,
"config_test": false,
"has... |
'''
Created on Mar 13, 2016
@author: Dead Robot Society
'''
import constants as c
# from sensors import DEBUG
from wallaby import motor
from wallaby import msleep
from wallaby import ao
from wallaby import seconds
from sensors import onBlackFront, onBlackBack
def driveTimed(left, right, time):
... | {
"repo_name": "gras/16-ValleyBot",
"path": "src/drive.py",
"copies": "1",
"size": "2528",
"license": "mit",
"hash": 595671205507470300,
"line_mean": 21.8490566038,
"line_max": 63,
"alpha_frac": 0.5415348101,
"autogenerated": false,
"ratio": 3.669085631349782,
"config_test": false,
"has_no_key... |
'''
Created on Mar 13, 2016
@author: Dead Robot Society
'''
import constants as c
from wallaby import ao
from wallaby import msleep
from wallaby import analog
from wallaby import digital
from wallaby import seconds
from wallaby import a_button_clicked
from wallaby import b_button_clicked
def crossBl... | {
"repo_name": "gras/16-ValleyBot",
"path": "src/sensors.py",
"copies": "1",
"size": "2436",
"license": "mit",
"hash": 375815771757496960,
"line_mean": 22.8571428571,
"line_max": 70,
"alpha_frac": 0.6091954023,
"autogenerated": false,
"ratio": 3.7708978328173375,
"config_test": false,
"has_no_... |
'''
Created on Mar 13, 2016
@author: Dead Robot Society
'''
import constants as c
from wallaby import set_servo_position
from wallaby import enable_servos
from wallaby import msleep
from wallaby import get_servo_position
from wallaby import ao
def testServos():
set_servo_position(c.frontArm, c.fr... | {
"repo_name": "gras/16-ValleyBot",
"path": "src/servos.py",
"copies": "1",
"size": "1963",
"license": "mit",
"hash": -5492893014358025000,
"line_mean": 26.0428571429,
"line_max": 64,
"alpha_frac": 0.6602139582,
"autogenerated": false,
"ratio": 2.9430284857571216,
"config_test": false,
"has_no... |
# 1703. Minimum Adjacent Swaps for K Consecutive Ones
# O(len(nums))
class Solution:
def minMoves(self, nums: List[int], k: int) -> int:
if sum(nums) < k:
return 0
# Records the positions of 1s.
pos = []
for i in range(len(nums)):
if nums[i] == 1:
... | {
"repo_name": "digiter/Arena",
"path": "1703-minimum-adjacent-swaps-for-k-consecutive-ones.py",
"copies": "1",
"size": "1425",
"license": "mit",
"hash": 2631643709693587000,
"line_mean": 29.3191489362,
"line_max": 77,
"alpha_frac": 0.4385964912,
"autogenerated": false,
"ratio": 3.0319148936170213... |
# caselessList
# A case insensitive list that only permits strings as keys.
# Implemented for ConfigObj
# Requires Python 2.2 or above
# Copyright Michael Foord
# Not for use in commercial projects without permission. (Although permission will probably be given).
# If you use in a non-commercial project then please ... | {
"repo_name": "ActiveState/code",
"path": "recipes/Python/284569_caselessList/recipe-284569.py",
"copies": "1",
"size": "9584",
"license": "mit",
"hash": -8931909770362768000,
"line_mean": 42.9633027523,
"line_max": 160,
"alpha_frac": 0.596515025,
"autogenerated": false,
"ratio": 3.93593429158110... |
# 1707. Maximum XOR With an Element From Array
# O(len(nums)*30 + len(queries)*30)
class Solution:
def maximizeXor(self, nums: List[int], queries: List[List[int]]) -> List[int]:
# The length of 10**9 in binary format.
LEN = 30
# Contains prefixes with length i, 0 <= i < LEN.
prefix... | {
"repo_name": "digiter/Arena",
"path": "1707-maximum-xor-with-an-element-from-array.py",
"copies": "1",
"size": "1402",
"license": "mit",
"hash": -320253503161872800,
"line_mean": 30.8636363636,
"line_max": 82,
"alpha_frac": 0.4721825963,
"autogenerated": false,
"ratio": 3.660574412532637,
"con... |
# 17.09.14
import collections
from datetime import datetime
def thr_output(output_file, processed_data):
print("Output _ for _ thr")
with open(output_file, "wt") as fp:
for item in processed_data:
fp.write(str(item) + ",")
fp.write("\n")
fp.close()
def thr_data_... | {
"repo_name": "Aishelre/untitled",
"path": "Output_data.py",
"copies": "1",
"size": "6731",
"license": "mit",
"hash": 7092547808309403000,
"line_mean": 35.0411764706,
"line_max": 96,
"alpha_frac": 0.424011434,
"autogenerated": false,
"ratio": 2.697943444730077,
"config_test": false,
"has_no_k... |
17134.1.amd64fre.rs4_release.180410-1804
import os
from collections import defaultdict
from csv import DictReader
import math, time as t
from datetime import datetime
from datetime import datetime
from csv import DictReader
'''
# Binary Feats
```
117 -----> 'fe_guy_didnt_update',
118 -----> 'fst_public_ver_st... | {
"repo_name": "AdityaSoni19031997/Machine-Learning",
"path": "kaggle/microsoft_malware_competition/csv_to_vw.py",
"copies": "1",
"size": "19477",
"license": "mit",
"hash": -7316423496030462000,
"line_mean": 46.6210268949,
"line_max": 156,
"alpha_frac": 0.5136314628,
"autogenerated": false,
"ratio... |
# 1728. Cat and Mouse II
class Solution:
def canMouseWin(self, grid: List[str], catJump: int, mouseJump: int) -> bool:
rowCnt = len(grid)
colCnt = len(grid[0])
index = lambda x, y: x * colCnt + y
def buildGraph(jumpCnt):
g = [list() for _ in range(rowCnt * colCnt)]
... | {
"repo_name": "digiter/Arena",
"path": "1728-cat-and-mouse-ii.py",
"copies": "1",
"size": "2772",
"license": "mit",
"hash": 5641895441421040000,
"line_mean": 36.4594594595,
"line_max": 81,
"alpha_frac": 0.3795093795,
"autogenerated": false,
"ratio": 4.1066666666666665,
"config_test": false,
"... |
''' 17b-observation_regions.py
=========================
AIM: Determines the time spent in one region of the sky.
INPUT: files: - <orbit_id>_<SL_angle>misc/ephemerids_obs<transit_duration>h_<max_interruptions>inter_V<mag_max><_SAA?>.npz (from 17a...py
variables: see section PARAMETERS (below)
OUTPUT: 'skycoverage_r... | {
"repo_name": "kuntzer/SALSA-public",
"path": "17b_observation_regions.py",
"copies": "1",
"size": "6325",
"license": "bsd-3-clause",
"hash": 1637545244907618300,
"line_mean": 30.157635468,
"line_max": 225,
"alpha_frac": 0.6652964427,
"autogenerated": false,
"ratio": 2.8236607142857144,
"config... |
#17 choices
#STICKERS = ['SPY', 'QQQ', 'IYR','XLF', 'XLV', 'XLI', 'XLY', 'XLP', 'XLB', 'XLK', 'XLU', 'XLE', 'USO', 'GLD', 'TLT', 'ITA']
FUND_STICKERS = {'lucas' :['SPY', 'QQQ', 'IYR','XLF', 'XLV', 'XLI', 'XLY', 'XLP', 'XLB', 'XLK', 'XLU', 'XLE', 'USO', 'GLD', 'TLT', 'ITA'],
'winwin' :['SPY', 'QQQ', 'I... | {
"repo_name": "martinggww/lucasenlights",
"path": "ETF/my_config.py",
"copies": "1",
"size": "7647",
"license": "cc0-1.0",
"hash": -387642500161463900,
"line_mean": 38.828125,
"line_max": 236,
"alpha_frac": 0.5049038839,
"autogenerated": false,
"ratio": 2.7457809694793536,
"config_test": false,... |
# 17 - Collect more digits - python
answer();
# ask for a single digit
result = ask( "Hello. Please enter any single digit", { 'choices' : "[1 DIGIT]" })
if result.name == 'choice' :
say( "Great, you said " + result.value )
# ask for a 5 digit long ZIP code
result = ask( "Hello. Please enter your 5 digit Z... | {
"repo_name": "tropo/tropo-samples",
"path": "python/tutorial/17-collectmoredigits.py",
"copies": "3",
"size": "1846",
"license": "mit",
"hash": 28721770616323384,
"line_mean": 29.7666666667,
"line_max": 105,
"alpha_frac": 0.6067172264,
"autogenerated": false,
"ratio": 3.2964285714285713,
"conf... |
# 17. Consider a function which, for a given whole number n, returns the number of ones required when writing out all numbers between 0 and n.
# For example, f(13)=6. Notice that f(1)=1. What is the next largest n such that f(n)=n?
import csv, os # für CSV-Export und Aufruf von Gnuplot
def einser(zahl): # Anzahl... | {
"repo_name": "Findus23/mathe_python",
"path": "einser.py",
"copies": "1",
"size": "1116",
"license": "mit",
"hash": 5514299444299266000,
"line_mean": 26.1951219512,
"line_max": 142,
"alpha_frac": 0.6328545781,
"autogenerated": false,
"ratio": 2.3112033195020745,
"config_test": false,
"has_no... |
# 17 Nov 2011
import time
import os
import sys
import numpy
import h5py
from PnSC_ui import *
from PnSC_dataimport import *
from PnSC_SCui import *
from PnSC_math import *
from PnSC_h5io import *
from PyQt4.QtCore import *
from PyQt4.QtGui import *
#class MainMenu(QMainWindow):
# def __init__(self, TreeWidg):
# ... | {
"repo_name": "johnmgregoire/NanoCalorimetry",
"path": "PnSC_main.py",
"copies": "1",
"size": "52510",
"license": "bsd-3-clause",
"hash": -5818774641615642000,
"line_mean": 50.0301263362,
"line_max": 369,
"alpha_frac": 0.6577794706,
"autogenerated": false,
"ratio": 3.3675367151927147,
"config_t... |
''' 17-treat-ephemerids.py
=========================
AIM: Using the ephemerids computed by 16-compute-ephemerids.py and observational constraints
(period of the planet, transit time) calculates observations period.
To be used by the two next scripts (18, 19) to treat and plot.
INPUT: files: - <orbit_id>_misc/epheme... | {
"repo_name": "kuntzer/SALSA-public",
"path": "17d_single_day_obs.py",
"copies": "1",
"size": "13567",
"license": "bsd-3-clause",
"hash": -4629968037601565000,
"line_mean": 31.770531401,
"line_max": 210,
"alpha_frac": 0.6350703914,
"autogenerated": false,
"ratio": 2.8118134715025906,
"config_te... |
# 187. Repeated DNA Sequences
#
# All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: "ACGAATTCCG".
# When studying DNA, it is sometimes useful to identify repeated sequences within the DNA.
#
# Write a function to find all the 10-letter-long sequences (substrings)
# that occur mo... | {
"repo_name": "gengwg/leetcode",
"path": "187_repeated_dna_sequences.py",
"copies": "1",
"size": "1163",
"license": "apache-2.0",
"hash": -6084029767162964000,
"line_mean": 28.075,
"line_max": 106,
"alpha_frac": 0.6018916595,
"autogenerated": false,
"ratio": 3.2486033519553073,
"config_test": f... |
# 188. Best Time to Buy and Sell Stock IV
# The split-or-add approach.
# O(nlogn), 40 ms.
#
# Critical test case:
# Case #1: 1 [1, 10, 8, 9, 6, 12]
# Case #2: 3 [1, 10, 8, 9, 6, 12]
# Case #3: 1 [1, 5, 2, 4, 3, 6]
class Trade:
def __init__(self, low, high):
self.low = low
self.high = high
def... | {
"repo_name": "digiter/Arena",
"path": "188-best-time-to-buy-and-sell-stock-iv.py",
"copies": "1",
"size": "3105",
"license": "mit",
"hash": -626532666136625900,
"line_mean": 38.3037974684,
"line_max": 139,
"alpha_frac": 0.5272141707,
"autogenerated": false,
"ratio": 3.781973203410475,
"config_... |
# 189. Rotate Array - LeetCode
# https://leetcode.com/problems/rotate-array/description/
# Rotate an array of n elements to the right by k steps.
# For example, with n = 7 and k = 3, the array [1,2,3,4,5,6,7] is rotated to [5,6,7,1,2,3,4].
class Solution(object):
def rotate(self, nums, k):
"""
:ty... | {
"repo_name": "heyf/cloaked-octo-adventure",
"path": "leetcode/189_rotate-array.py",
"copies": "1",
"size": "1252",
"license": "mit",
"hash": 7448828536861209000,
"line_mean": 26.2391304348,
"line_max": 93,
"alpha_frac": 0.4273162939,
"autogenerated": false,
"ratio": 2.3802281368821294,
"config... |
# -*18^- coding: utf-8 -*-
import traceback
from time import time
from twisted.internet import defer
from twisted.words.protocols.jabber.jid import JID
import tornado.web
#import txmongo
import bnw.core.base
import bnw.core.bnw_objects as objs
from bnw.formatting import linkify, thumbify
from widgets import widgets
fr... | {
"repo_name": "ojab/bnw",
"path": "bnw/web/base.py",
"copies": "1",
"size": "3765",
"license": "bsd-2-clause",
"hash": -4909122210413813000,
"line_mean": 33.2272727273,
"line_max": 105,
"alpha_frac": 0.6156706507,
"autogenerated": false,
"ratio": 3.75,
"config_test": true,
"has_no_keywords": ... |
# 18 continued. gt/pm/tree
# New documentation says parameter name is 'taxa'.
# Examples in old documentation are wrong, fixed below.
import sys, unittest, json
sys.path.append('./')
sys.path.append('../')
import webapp
from test_gt_ot_get_tree import GtTreeTester
service = webapp.get_service(5004, 'gt/pm/tree')
cl... | {
"repo_name": "jar398/tryphy",
"path": "tests/test_gt_pm_tree.py",
"copies": "1",
"size": "1424",
"license": "bsd-2-clause",
"hash": -3134316180386459000,
"line_mean": 31.3636363636,
"line_max": 163,
"alpha_frac": 0.6818820225,
"autogenerated": false,
"ratio": 3.2072072072072073,
"config_test":... |
# 18.
print_log('\n18. Prover gets Credentials for Proof Request\n')
proof_request = {
'nonce': '123432421212',
'name': 'proof_req_1',
'version': '0.1',
'requested_attributes': {
'attr1_referent': {
'name': 'name... | {
"repo_name": "peacekeeper/indy-sdk",
"path": "docs/how-tos/negotiate-proof/python/step3.py",
"copies": "2",
"size": "2179",
"license": "apache-2.0",
"hash": 7759627374575975000,
"line_mean": 43.4897959184,
"line_max": 112,
"alpha_frac": 0.4947223497,
"autogenerated": false,
"ratio": 3.9762773722... |
''' 18-plot-transit-proba.py
=========================
AIM: Plots transit probabilities according to 17-treat-ephemerids.py.
A probability of 100% corresponds to being able to observe the target for
its whole period.
INPUT: files: - <orbit_id>_misc/ephemerids_obs<transit_duration>h_<max_interruptions>inter_V<mag_ma... | {
"repo_name": "kuntzer/SALSA-public",
"path": "18_plot_transit_proba.py",
"copies": "1",
"size": "8321",
"license": "bsd-3-clause",
"hash": -5888129707187427000,
"line_mean": 30.0485074627,
"line_max": 171,
"alpha_frac": 0.6434322798,
"autogenerated": false,
"ratio": 2.7589522546419096,
"config... |
# 18 septembre 2017
# astro.py
# projet S3
"""equation de la ligne B3V pour un graphique u-g vs g-r : 0.9909 * x - 0.8901"""
import re
def lire_fichier(fichier):
"""
:param fichier: nom du fichier en chaine de caractere. Le fichier est trie par colonnes
:return: retourne liste de listes qui corresponde... | {
"repo_name": "anthonygi13/Recherche_etoiles_chaudes",
"path": "astro.py",
"copies": "1",
"size": "2449",
"license": "apache-2.0",
"hash": -5172307262663984000,
"line_mean": 30.358974359,
"line_max": 133,
"alpha_frac": 0.5744071954,
"autogenerated": false,
"ratio": 2.850815850815851,
"config_te... |
# 198 - House Robber (Easy)
# https://leetcode.com/problems/house-robber/
class Solution:
def rob(self, nums: List[int]) -> int:
# From a list of houses, rob houses that are not adjacent.
# It's not enough with just robbing the odd houses or the even
# houses, there may be a case where in ... | {
"repo_name": "zubie7a/Algorithms",
"path": "LeetCode/01_Easy/lc_198.py",
"copies": "1",
"size": "4390",
"license": "mit",
"hash": 1040088376132992000,
"line_mean": 36.5213675214,
"line_max": 86,
"alpha_frac": 0.5881548975,
"autogenerated": false,
"ratio": 3.7779690189328745,
"config_test": fal... |
# 198. House Robber - LeetCode
# https://leetcode.com/problems/house-robber/description/
class Solution(object):
def rob(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
if len(nums) == 0:
return 0
if len(nums) == 1:
return nums[0]
... | {
"repo_name": "heyf/cloaked-octo-adventure",
"path": "leetcode/198_house-robber.py",
"copies": "1",
"size": "1335",
"license": "mit",
"hash": -9088809548364366000,
"line_mean": 21.6440677966,
"line_max": 86,
"alpha_frac": 0.4172284644,
"autogenerated": false,
"ratio": 2.877155172413793,
"config... |
# 1 9 h
# 2 8 a g
# 3 7 b f
# 4 6 c e
# 5 d
from io import StringIO
class Solution:
def convert(self, s:str, num_rows: int) -> str:
if num_rows == 1:
return s
chars = [None] * len(s)
loop_size = 1 if num_rows == 1 else (num_rows - 1) ... | {
"repo_name": "y-usuzumi/survive-the-course",
"path": "leetcode/6.ZigZag_Conversion/main.py",
"copies": "1",
"size": "3817",
"license": "bsd-3-clause",
"hash": -4860767147748007000,
"line_mean": 38.6105263158,
"line_max": 103,
"alpha_frac": 0.4820621844,
"autogenerated": false,
"ratio": 3.1022258... |
''' 19-plot-transit-proba-mag-limits.py
=========================
AIM: Plots deepest achiveable magnitude according to 17-treat-ephemerids.py.
A minimum detection capability of 100% means that a whole orbit must be observable
INPUT: files: - <orbit_id>_misc/ephemerids_obs<transit_duration>h_<max_interruptions>inter_... | {
"repo_name": "kuntzer/SALSA-public",
"path": "19_plot_transit_proba_mag_limits.py",
"copies": "1",
"size": "9783",
"license": "bsd-3-clause",
"hash": -3155017024147321000,
"line_mean": 30.3557692308,
"line_max": 171,
"alpha_frac": 0.6493918021,
"autogenerated": false,
"ratio": 2.744949494949495,... |
"""19. Remove Nth Node From End of List
Medium
URL: https://leetcode.com/problems/remove-nth-node-from-end-of-list/
Given a linked list, remove the n-th node from the end of list and return
its head.
Example:
Given linked list: 1->2->3->4->5, and n = 2.
After removing the second node from the end, the linked list b... | {
"repo_name": "bowen0701/algorithms_data_structures",
"path": "lc0019_remove_nth_node_from_end_of_list.py",
"copies": "1",
"size": "2892",
"license": "bsd-2-clause",
"hash": -1116133990393282000,
"line_mean": 23.3025210084,
"line_max": 80,
"alpha_frac": 0.5605117566,
"autogenerated": false,
"rati... |
#1,a 2,b 3,c
class Node(object):
nextPointer = None
number = None
def removeNext(self):
if(self.nextPointer != None):
self.nextPointer = self.nextPointer.nextPointer
testList1 = Node()
testList1.number = 1
testList2 = Node()
testList2.number = 1
testList3 = Node()
testLis... | {
"repo_name": "petersrinivasan/neopeng",
"path": "scratch.py",
"copies": "1",
"size": "4681",
"license": "unlicense",
"hash": -5926890737106559000,
"line_mean": 27.5426829268,
"line_max": 103,
"alpha_frac": 0.6964323862,
"autogenerated": false,
"ratio": 3.682926829268293,
"config_test": true,
... |
# 1. ABBA
# 2. AABB
# 3. ABAABAAAAAAAAA
# if consecutive positions of A are apart by even number of positions then word is bubbly --- no this logic does not work for example #3.
import pdb
def isBubbly(word):
arr_A = []
arr_B = []
for i in range(len(word)):
if word[i] == 'A':
arr_A.appe... | {
"repo_name": "atishbits/101",
"path": "bubblyArray.py",
"copies": "1",
"size": "1453",
"license": "mit",
"hash": -3488390448324114400,
"line_mean": 22.8196721311,
"line_max": 137,
"alpha_frac": 0.4528561597,
"autogenerated": false,
"ratio": 3.3790697674418606,
"config_test": false,
"has_no_k... |
# 1a finished
def decimals(n):
temp = list(divmod(10,n))
yield temp[0]
while temp[1]:
temp = list(divmod(temp[1]*10,n))
yield temp[0]
return
# 1b finished
def genlimit(g, limit):
for i in range(limit):
yield next(g)
# 2 finished
def decimals2(n):
remainder = 1
record1 = [0]
record2 = [1]
while r... | {
"repo_name": "iamacewhite/COMSW3101",
"path": "hw2.py",
"copies": "1",
"size": "3211",
"license": "mit",
"hash": -1390300911266678000,
"line_mean": 19.7161290323,
"line_max": 127,
"alpha_frac": 0.5471815634,
"autogenerated": false,
"ratio": 2.821616871704745,
"config_test": false,
"has_no_ke... |
"""[-1-]Attribution-Share Alike 3.0 License, copyright (c) 2010 Pieter Hintjens, modified @alpaca-tc
[-2-]=====================================================================
[-3-]kvmsg - key-value message class for example applications
[-4-]
[-5-]Author: Min RK <benjaminrk@gmail.com>
[-6-]
"""
import struct #[-9-] f... | {
"repo_name": "alpaca-tc/comment_extractor",
"path": "spec/assets/source_code/python.py",
"copies": "1",
"size": "3781",
"license": "mit",
"hash": 4323281875604764700,
"line_mean": 26.2014388489,
"line_max": 100,
"alpha_frac": 0.5681036763,
"autogenerated": false,
"ratio": 3.3371579876434248,
"... |
# 1/bin/python
from deap import base
def _maturePopulation(population):
for W in range(len(population)):
try:
assert (population[W].Age)
except:
population[W].Age = 0
population[W].Age += 1
def _checkRetirement(individue, statistics, ageBoundary):
# (Minetti, ... | {
"repo_name": "Gab0/gekkoJaponicus",
"path": "promoterz/supplement/age.py",
"copies": "1",
"size": "1494",
"license": "mit",
"hash": -7418057726121785000,
"line_mean": 28.88,
"line_max": 83,
"alpha_frac": 0.6445783133,
"autogenerated": false,
"ratio": 3.5319148936170213,
"config_test": false,
... |
# 1.) Calculate lowest stats needed to win
# -Cheapest gear correlates to least stat bonuses
# a.) Most possible rounds is min(playerHP, bossHP)
# b.) # of rounds is min(boss_HP / (player_DMG - boss_AMR), player_HP / (boss_DMG - player_AMR))
# c.) Player wins if rounds * (player_DMG - boss_AMR) >= boss... | {
"repo_name": "twrightsman/advent-of-code-2015",
"path": "advent_day21_pt2.py",
"copies": "1",
"size": "2536",
"license": "unlicense",
"hash": -2349327138498958300,
"line_mean": 31.1139240506,
"line_max": 121,
"alpha_frac": 0.5871451104,
"autogenerated": false,
"ratio": 2.715203426124197,
"conf... |
#1. call the default constructor: variable = variable = NewsAPI.NewsAPI(2,1,2015,4,11,2016,'BP','35b806d26e76f895fe31669dea30f528c36c94e6')
#2. try to get data : variable.startGetData(), it will returns success if it is works or error (Check API key if it returns error)
#3. get the sentiment score in list format dou... | {
"repo_name": "ryanstrat/stock-predictions",
"path": "NewsAPI.py",
"copies": "1",
"size": "5991",
"license": "apache-2.0",
"hash": -2555928798839856000,
"line_mean": 38.1568627451,
"line_max": 350,
"alpha_frac": 0.723251544,
"autogenerated": false,
"ratio": 3.0566326530612247,
"config_test": fa... |
# 1. Cara mendefinisikan kelas
class PublicClass(object):
# 2. Cara mendefiniskan atribut bertipe int
__privateInt=0 #private
# 6. Cara mendefinisikan konstruktor
def __init__(self):
# 3. Cara mendefinisikan atribut bertipe string, dan mengisi dengan nilai awal
self.publicString="Hello"
# 5.Cara me... | {
"repo_name": "pascalalfadian/LanguagesExploration",
"path": "B/LanguagesExploration.py",
"copies": "2",
"size": "2151",
"license": "mit",
"hash": -6863973044293738000,
"line_mean": 38.1090909091,
"line_max": 82,
"alpha_frac": 0.7475592748,
"autogenerated": false,
"ratio": 2.950617283950617,
"c... |
# 1. Claim a message
# 2. Grab HTML
# 3. Delete message
# 4. Push more URLs
from bs4 import BeautifulSoup
import sys
from helpers import client
import requests
import urlparse
def scrape_generator(url):
parent = urlparse.urlsplit(url)
page = requests.get(url)
soup = BeautifulSoup(page.text, 'html.parser')
... | {
"repo_name": "ryansb/zaqar-webscraper-demo",
"path": "scraper.py",
"copies": "1",
"size": "1654",
"license": "mit",
"hash": -9025912232424904000,
"line_mean": 27.0338983051,
"line_max": 82,
"alpha_frac": 0.5507859734,
"autogenerated": false,
"ratio": 3.919431279620853,
"config_test": false,
... |
# 1. Clear result High word (Bytes 2 and 3)
# 2. Load Loop counter with 16.
# 3. Shift multiplier right
# 4. If carry (previous bit 0 of multiplier Low byte) set, add multiplicand to result High word.
# 5. Shift right result High word into result Low word/multiplier.
# 6. Shift right Low word/multi... | {
"repo_name": "paulscottrobson/vtl-1802",
"path": "expression/multiply.py",
"copies": "1",
"size": "1599",
"license": "mit",
"hash": -130821361926656580,
"line_mean": 26.1186440678,
"line_max": 113,
"alpha_frac": 0.6203877423,
"autogenerated": false,
"ratio": 2.5831987075928917,
"config_test": ... |
## 1. Computer components ##
print('Hello World!')
## 2. Data storage ##
my_int = 6
int_addr = id(my_int)
my_str = 'Alien'
str_addr = id(my_str)
## 4. Data storage in Python ##
import sys
my_int = 200
size_of_my_int = sys.getsizeof(my_int)
int1 = 10
int2 = 100000
str1 = "Hello"
str2 = "Hi"
int_diff = sys.getsize... | {
"repo_name": "vipmunot/Data-Analysis-using-Python",
"path": "Python Programming Advanced/Introduction to computer architecture-170.py",
"copies": "1",
"size": "1301",
"license": "mit",
"hash": -799057504789401200,
"line_mean": 14.686746988,
"line_max": 51,
"alpha_frac": 0.6087624904,
"autogenerate... |
# 1. convert tables to use 'tabu'
# Based on Wagner Macedo's filter.py posted at
# https://groups.google.com/forum/#!msg/pandoc-discuss/RUC-tuu_qf0/h-H3RRVt1coJ
import pandocfilters as pf
def latex(s):
return pf.RawBlock('latex', s)
def inlatex(s):
return pf.RawInline('latex', s)
def tbl_caption(s):
retu... | {
"repo_name": "wilsonCernWq/ospray",
"path": "doc/filter-latex.py",
"copies": "2",
"size": "1884",
"license": "apache-2.0",
"hash": -6274346409928951000,
"line_mean": 26.7058823529,
"line_max": 79,
"alpha_frac": 0.4729299363,
"autogenerated": false,
"ratio": 3.0436187399030694,
"config_test": f... |
# 1. copy this file to settings_secret.py
# 2. make sure the settings_secret.py file is ignored (should be listed in .gitignore)
# 3. EITHER...
# a) add your TWITTER secrets directly to this file in the `except:` block below
# **OR**
# b) set your environment variables to contain your keys (see below for env var... | {
"repo_name": "totalgood/twip",
"path": "twip/settings_template.py",
"copies": "1",
"size": "1074",
"license": "mit",
"hash": 8207027805120538000,
"line_mean": 43.75,
"line_max": 91,
"alpha_frac": 0.7458100559,
"autogenerated": false,
"ratio": 3.0685714285714285,
"config_test": false,
"has_no... |
## 1. Counting in Python ##
import sqlite3
conn = sqlite3.connect('factbook.db')
facts = conn.cursor().execute('select * from facts;').fetchall()
print(facts)
facts_count = len(facts)
## 2. Counting in SQL ##
conn = sqlite3.connect("factbook.db")
birth_rate_count = conn.cursor().execute('select count(birth_rate) fro... | {
"repo_name": "vipmunot/Data-Analysis-using-Python",
"path": "SQL and Databases Begineer/SQL Summary Statistics-181.py",
"copies": "1",
"size": "2414",
"license": "mit",
"hash": 6153737363980810000,
"line_mean": 34.5147058824,
"line_max": 128,
"alpha_frac": 0.7377796189,
"autogenerated": false,
"... |
# 1. Create a dictionary that connects the numbers 1-12 with each
# number's corresponding month. 1 --> January, for example.
months = {1:'January',
2:'February',
3:'March',
4:'April',
5:'May',
6:'June',
7:'July',
8:'August',
9:... | {
"repo_name": "Nethermaker/school-projects",
"path": "intro/dictionary_assignment.py",
"copies": "1",
"size": "2734",
"license": "mit",
"hash": -975624272765644500,
"line_mean": 22.4107142857,
"line_max": 76,
"alpha_frac": 0.5716898317,
"autogenerated": false,
"ratio": 3.6211920529801325,
"conf... |
# 1) Create an empty stack S.
# 2) Initialize current node as root
# 3) Push the current node to S and set current = current->left until current is NULL
# 4) If current is NULL and stack is not empty then
# a) Pop the top item from stack.
# b) Print the popped item, set current = popped_item->right
# c... | {
"repo_name": "saisankargochhayat/algo_quest",
"path": "leetcode/94. Inorder/iterative_solution.py",
"copies": "1",
"size": "1033",
"license": "apache-2.0",
"hash": 6044954042956955000,
"line_mean": 40.36,
"line_max": 85,
"alpha_frac": 0.577928364,
"autogenerated": false,
"ratio": 4.1155378486055... |
# 1.create projects skeleton based on defined scaffolds
#
# Project: https://github.com/molee1905/ShenMa
# License: MIT
#
import sublime, sublime_plugin
import os
import tempfile
import shutil
import re
import subprocess
import datetime, time
import json
SHORTCUTS_PATH_RE = re.compile(r'sc[/|\\]shortcuts', re.I)
I... | {
"repo_name": "molee1905/ShenMa",
"path": "sm.py",
"copies": "1",
"size": "5493",
"license": "mit",
"hash": -1436819093862397400,
"line_mean": 30.3657142857,
"line_max": 90,
"alpha_frac": 0.5452723629,
"autogenerated": false,
"ratio": 3.795988934993084,
"config_test": false,
"has_no_keywords"... |
# 1. Creates png files with ellipsis of various widths, heights,
# and blue intensity.
# 2. Creates user.json with gallery configuration with file
# list in fullfiles node and launches browser. Note that file
# must be named user.json.
import matplotlib.pyplot as plt
from matplotlib.patches import Ellipse
imp... | {
"repo_name": "rweigel/viviz",
"path": "demos/create_ellipse_gallery.py",
"copies": "1",
"size": "2087",
"license": "mit",
"hash": 7028335680115412000,
"line_mean": 27.602739726,
"line_max": 112,
"alpha_frac": 0.5706756109,
"autogenerated": false,
"ratio": 2.9644886363636362,
"config_test": fal... |
# 1) curve of big order by 30m, 60m, dayly
# 2) Alert at threshold
# 3) list possible watch list
#-*-coding:utf-8-*-
#!/usr/bin/python
# coding: UTF-8
"""
This script parse stock info
"""
import pandas as pd
import tushare as ts
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.dates as mpdates
i... | {
"repo_name": "yunfeiz/py_learnt",
"path": "quant/big_order_monitor.py",
"copies": "1",
"size": "2376",
"license": "apache-2.0",
"hash": 5277615488317966000,
"line_mean": 21.4150943396,
"line_max": 88,
"alpha_frac": 0.6296296296,
"autogenerated": false,
"ratio": 2.4444444444444446,
"config_test... |
# 1d approixmation to beta binomial model
# https://github.com/aloctavodia/BAP
import pymc3 as pm
import numpy as np
import seaborn as sns
import scipy.stats as stats
import matplotlib.pyplot as plt
import arviz as az
import math
#data = np.repeat([0, 1], (10, 3))
data = np.repeat([0, 1], (10, 1))
h = data.sum()
t =... | {
"repo_name": "probml/pyprobml",
"path": "scripts/beta_binom_approx_post_pymc3.py",
"copies": "1",
"size": "4414",
"license": "mit",
"hash": -5357475146503276000,
"line_mean": 25.1065088757,
"line_max": 66,
"alpha_frac": 0.6672710789,
"autogenerated": false,
"ratio": 2.616844602609727,
"config_... |
""" 1d array of prediction values with properties (labels, reference to the predictor)
"""
import numpy
from pySPACE.resources.data_types import base
class PredictionVector(base.BaseData):
""" Represents a prediction vector
It contains a label, a prediction and a reference to the predictor.
I doesn... | {
"repo_name": "pyspace/pyspace",
"path": "pySPACE/resources/data_types/prediction_vector.py",
"copies": "3",
"size": "7879",
"license": "bsd-3-clause",
"hash": 3188084685319099400,
"line_mean": 41.5891891892,
"line_max": 93,
"alpha_frac": 0.6062952151,
"autogenerated": false,
"ratio": 4.692674210... |
" 1D cylindrical PB, modelling crossection of pore "
# Comment: this is a prime example of simplicity and flexibility :)
# the file solves a real PDE with precise specifications but depends ONLY on core library functions!
from dolfin import *
from nanopores import *
from nanopores.physics.simplepnps import *
# --- cr... | {
"repo_name": "mitschabaude/nanopores",
"path": "scripts/toy_models/pnp1Dcyl.py",
"copies": "1",
"size": "1522",
"license": "mit",
"hash": -2864117952657960400,
"line_mean": 28.2692307692,
"line_max": 108,
"alpha_frac": 0.6931668857,
"autogenerated": false,
"ratio": 2.955339805825243,
"config_t... |
# # 1. Define a function max() that takes two numbers as arguments and returns the largest of them.
# # Use the if-then-else construct available in Python.
# # (It is true that Python has the max() function built in, but writing it yourself is nevertheless a good exercise.)
#
# def max (a, b):
# if a>b:
# r... | {
"repo_name": "openUniverse/singularity",
"path": "BensPractice/Practise2.py",
"copies": "1",
"size": "2825",
"license": "mit",
"hash": -4883824510394490000,
"line_mean": 36.1710526316,
"line_max": 134,
"alpha_frac": 0.5886725664,
"autogenerated": false,
"ratio": 3.491965389369592,
"config_test... |
1 def shuffle2(rules, datalines):
2 """An alternative way to code shuffle().
3 Instead of writing files at every step of the way, collects lines in a dictionary structure.
4 Initial tests on 2011-03-30 suggest that this might actually be _slower_.
5 Takes as arguments a l... | {
"repo_name": "harsha-mudi/shawkle",
"path": "shawkle-alt.py",
"copies": "1",
"size": "3154",
"license": "apache-2.0",
"hash": 972171087484712300,
"line_mean": 48.28125,
"line_max": 116,
"alpha_frac": 0.496829423,
"autogenerated": false,
"ratio": 4.332417582417582,
"config_test": false,
"has_... |
#1.def关键字
#2.函数名
#3.()
#4.函数体
#5.返回值
'''
def send(x,n):
try:
import smtplib
from email.mime.text import MIMEText
from email.header import Header
sender = '18761515328@163.com'
receiver = x
subject = 'python email test'
smtpserver = 'smtp.163.com'
usern... | {
"repo_name": "xiaoyongaa/ALL",
"path": "函数和常用模块/第一阶段/第一课.py",
"copies": "1",
"size": "1425",
"license": "apache-2.0",
"hash": -7724437380874339000,
"line_mean": 8.7559055118,
"line_max": 58,
"alpha_frac": 0.5052461663,
"autogenerated": false,
"ratio": 2.252727272727273,
"config_test": false,
... |
# 1. del: funkcije
#gender: female = 2, male = 0
def calculate_score_for_gender(gender):
if gender == "male":
return 0
else: return 2
#age: 0-100 if age < 10 --> 0, 11 < age < 20 --> 5, 21 < age < 35 --> 2, 36 < age < 50 --> 4, 50+ --> 1
def calculate_score_for_age(age):
if (age > 11 and age <= 20) or (age >... | {
"repo_name": "CodeCatz/litterbox",
"path": "ajda/complicajda.py",
"copies": "1",
"size": "5477",
"license": "mit",
"hash": 8154240385631336000,
"line_mean": 24.2396313364,
"line_max": 170,
"alpha_frac": 0.6605806098,
"autogenerated": false,
"ratio": 2.7412412412412412,
"config_test": false,
... |
import scipy.optimize as opt
from numpy import sqrt, log
#when solving numerically, it is assumed that all mach numbers are less than this
MAX_M = 100
MIN_M = 1e-6
#thermo properties
def getT0(T, gamma, M):
return T*(1 + (gamma-1)*M**2/2)
def getP0(P, gamma, M):
return P*(1 + (gamma-1)*M**2/2)*... | {
"repo_name": "USCLiquidPropulsionLaboratory/Engine-sizing-snake",
"path": "Flows1D.py",
"copies": "1",
"size": "3251",
"license": "mit",
"hash": 2254067939418139600,
"line_mean": 30.8585858586,
"line_max": 81,
"alpha_frac": 0.580129191,
"autogenerated": false,
"ratio": 2.3439077144917086,
"con... |
""" 1D Function plotter.
This example creates a simple 1D function examiner, illustrating the use of
ChacoPlotEditors for displaying simple plot relations, as well as TraitsUI
integration. Any 1D numpy/scipy.special function should work in the function
text box.
- Left-drag pans the plot.
- Mousewheel up and down zo... | {
"repo_name": "tommy-u/chaco",
"path": "examples/demo/basic/traits_editor.py",
"copies": "3",
"size": "3151",
"license": "bsd-3-clause",
"hash": 4105821228618536400,
"line_mean": 34.8068181818,
"line_max": 80,
"alpha_frac": 0.4642970486,
"autogenerated": false,
"ratio": 4.759818731117825,
"conf... |
"""1-D Gaussian Processes for Regression and Bayesian Optimization"""
# Author: Charles Franzen
# License: MIT
from functools import partial
import numpy as np
import numpy.linalg as LA
import pandas as pd
import matplotlib.pyplot as plt
from scipy import stats
import dillinger.kernel_functions as kern
# main Gaus... | {
"repo_name": "chipfranzen/dillinger",
"path": "dillinger/gaussian_process.py",
"copies": "1",
"size": "8314",
"license": "mit",
"hash": -4726010513304370000,
"line_mean": 33.5958333333,
"line_max": 79,
"alpha_frac": 0.5169215946,
"autogenerated": false,
"ratio": 3.7638259292837715,
"config_tes... |
# 1d grid approixmation to beta binomial model
# https://github.com/aloctavodia/BAP
import pymc3 as pm
import numpy as np
import pandas as pd
import scipy.stats as stats
import matplotlib.pyplot as plt
import arviz as az
def posterior_grid(heads, tails, grid_points=100):
grid = np.linspace(0, 1, grid_points)
... | {
"repo_name": "probml/pyprobml",
"path": "scripts/bb_grid_approx.py",
"copies": "1",
"size": "1039",
"license": "mit",
"hash": -2323872741914506000,
"line_mean": 26.3421052632,
"line_max": 66,
"alpha_frac": 0.7003853565,
"autogenerated": false,
"ratio": 2.867403314917127,
"config_test": false,
... |
'''1d linear AD equation.'''
import math
import numpy as np
import numpy.fft as fft
import pfasst.imex
class LinearAD(pfasst.imex.IMEXFEval):
Lx = 1.0
nu = 0.02
acst = 1.0
t0 = 1.0
def __init__(self, size, Lx=1.0, acst=1.0, nu=0.02, t0=1.0, **kwargs):
super(LinearAD, self).__init... | {
"repo_name": "memmett/PyPFASST",
"path": "tests/linearad.py",
"copies": "1",
"size": "1716",
"license": "bsd-2-clause",
"hash": 6755589115639598000,
"line_mean": 20.45,
"line_max": 89,
"alpha_frac": 0.4656177156,
"autogenerated": false,
"ratio": 2.6359447004608296,
"config_test": false,
"has... |
" 1D PNP, modelling reservoirs and membrane far away from pore "
from dolfin import *
from nanopores import *
from nanopores.physics.simplepnps import *
# --- create 1D geometry ---
h = 20.
hmem = 3.
domain = Interval(-h/2, h/2)
membrane = Interval(-hmem/2, hmem/2)
lowerb = domain.boundary("left")
upperb = domain.b... | {
"repo_name": "mitschabaude/nanopores",
"path": "scripts/toy_models/pnp1D.py",
"copies": "1",
"size": "1272",
"license": "mit",
"hash": -4181582711238732000,
"line_mean": 23,
"line_max": 116,
"alpha_frac": 0.6422955975,
"autogenerated": false,
"ratio": 2.735483870967742,
"config_test": false,
... |
"""1D quantum particle in a box."""
from __future__ import print_function, division
from sympy import Symbol, pi, sqrt, sin, Interval, S
from sympy.physics.quantum.operator import HermitianOperator
from sympy.physics.quantum.state import Ket, Bra
from sympy.physics.quantum.constants import hbar
from sympy.functions.... | {
"repo_name": "lidavidm/sympy",
"path": "sympy/physics/quantum/piab.py",
"copies": "124",
"size": "1756",
"license": "bsd-3-clause",
"hash": 8298416204019598000,
"line_mean": 24.4492753623,
"line_max": 67,
"alpha_frac": 0.6577448747,
"autogenerated": false,
"ratio": 3.251851851851852,
"config_t... |
"""1D quantum particle in a box."""
from sympy import Symbol, pi, sqrt, sin, conjugate, Interval, S
from sympy.physics.quantum.operator import HermitianOperator
from sympy.physics.quantum.state import Ket, Bra
from sympy.physics.quantum.constants import hbar
from sympy.physics.quantum.kronecker import KroneckerDelta
... | {
"repo_name": "tarballs-are-good/sympy",
"path": "sympy/physics/quantum/piab.py",
"copies": "1",
"size": "1700",
"license": "bsd-3-clause",
"hash": 3383580177551355400,
"line_mean": 24,
"line_max": 63,
"alpha_frac": 0.6547058824,
"autogenerated": false,
"ratio": 3.2015065913371,
"config_test": ... |
"""1D quantum particle in a box."""
from sympy import Symbol, pi, sqrt, sin, Interval, S
from sympy.physics.quantum.operator import HermitianOperator
from sympy.physics.quantum.state import Ket, Bra
from sympy.physics.quantum.constants import hbar
from sympy.functions.special.tensor_functions import KroneckerDelta
fr... | {
"repo_name": "flacjacket/sympy",
"path": "sympy/physics/quantum/piab.py",
"copies": "2",
"size": "1703",
"license": "bsd-3-clause",
"hash": 8265089972198359000,
"line_mean": 24.4179104478,
"line_max": 67,
"alpha_frac": 0.6564885496,
"autogenerated": false,
"ratio": 3.219281663516068,
"config_t... |
# 1d walk, FPT process
import random
import numpy as np
import matplotlib.pyplot as plt
# get simulation parameter values
f = open( 'input.txt', 'r+')
content = [x.strip('\n') for x in f.readlines()]
f.close()
runTotal = int(content[1])
N = float(content[2])
L = float(content[3])
vi = 0.40;
vf = 0.45;
dv = 0.05;
nv ... | {
"repo_name": "varennes/1dwalk",
"path": "1dwalk.py",
"copies": "1",
"size": "2329",
"license": "mit",
"hash": -9053713721988728000,
"line_mean": 24.5934065934,
"line_max": 67,
"alpha_frac": 0.4401030485,
"autogenerated": false,
"ratio": 2.9593392630241424,
"config_test": false,
"has_no_keywo... |
# --------------- 1. Explicit Logging
def info(msg):
print("INFO - {}".format(msg))
# some business logic with logging
def do_something1(n):
info("do_something1 called with: n={}".format(n))
return n + 1
# --------------- 2 a) Logging with self-made decorator
def with_logging1(fun):
def wrapper(... | {
"repo_name": "plipp/Python-Coding-Dojos",
"path": "katas/XX-Primers/decorator_sample.py",
"copies": "1",
"size": "2916",
"license": "mit",
"hash": 1063078293232352000,
"line_mean": 22.9016393443,
"line_max": 89,
"alpha_frac": 0.5665294925,
"autogenerated": false,
"ratio": 3.4549763033175354,
"... |
## 1. Exploring the data ##
# The first 5 rows of the data.
print(income.head())
lowest_income_county = income["county"][income["median_income"].idxmin()]
high_pop = income[income["pop_over_25"] > 500000]
lowest_income_high_pop_county = high_pop["county"][high_pop["median_income"].idxmin()]
## 2. Random numbers ##
... | {
"repo_name": "vipmunot/Data-Analysis-using-Python",
"path": "Probability Statistics Beginner/Distributions and sampling-28.py",
"copies": "1",
"size": "5749",
"license": "mit",
"hash": -9019339273218168000,
"line_mean": 29.4232804233,
"line_max": 120,
"alpha_frac": 0.7072534354,
"autogenerated": f... |
# [1] "Feature Pyramid Networks for Object Detection" - Tsung-Yi Lin, Piotr Dollár,
# Ross Girshick, Kaiming He, Bharath Hariharan, Serge Belongie, arxiv 2016
# https://arxiv.org/abs/1612.03144
#
# [2] "DSSD : Deconvolutional Single Shot Detector" - Cheng-Yang Fu, Wei Liu, Ananth Ranga,
# Ambri... | {
"repo_name": "chicm/carvana",
"path": "08-02/software/car-segment/net/imagenet/pyramidnet.py",
"copies": "2",
"size": "25198",
"license": "apache-2.0",
"hash": -7466655524780501000,
"line_mean": 36.2692307692,
"line_max": 129,
"alpha_frac": 0.5488826261,
"autogenerated": false,
"ratio": 2.945516... |
# 1. fn/names_url
import sys, unittest, json
sys.path.append('./')
sys.path.append('../')
import webapp
service = webapp.get_service(5004, 'fn/names_url')
class TestFnNamesUrl(webapp.WebappTestCase):
@classmethod
def get_service(self):
return service
def test_no_parameter(self):
"""See h... | {
"repo_name": "jar398/tryphy",
"path": "tests/test_fn_names_url.py",
"copies": "1",
"size": "4728",
"license": "bsd-2-clause",
"hash": 7092956164174308000,
"line_mean": 42.7777777778,
"line_max": 138,
"alpha_frac": 0.6429780034,
"autogenerated": false,
"ratio": 3.4815905743740796,
"config_test"... |
## 1. Geographic Data ##
import pandas as pd
airlines = pd.read_csv('airlines.csv')
airports = pd.read_csv('airports.csv')
routes = pd.read_csv('routes.csv')
print(airlines.iloc[0])
print(airports.iloc[0])
print(routes.iloc[0])
#What's the best way to link the data from these 3 different datasets together?
# We can li... | {
"repo_name": "vipmunot/Data-Analysis-using-Python",
"path": "Storytelling Data Visualization/Visualizing Geographic Data-223.py",
"copies": "1",
"size": "2587",
"license": "mit",
"hash": -5117652022457479000,
"line_mean": 32.1794871795,
"line_max": 102,
"alpha_frac": 0.6992655586,
"autogenerated":... |
def get_url(a_board, a_num):
result = []
a = 0
while a < a_num:
a_board_n = a_board[a]
a_href = a_board_n['href'].split('/')[0]
print('a_href = ', a_href)
if len(a_href) == 0:
board_href = a_board_n['href']
board_url = 'https://www.ptt.cc' + board_hre... | {
"repo_name": "AmberFu/ptt_crawler",
"path": "ptt_board_url.py",
"copies": "1",
"size": "8265",
"license": "mit",
"hash": -6821261631350505000,
"line_mean": 28.0640569395,
"line_max": 101,
"alpha_frac": 0.5238153545,
"autogenerated": false,
"ratio": 3.2615814696485623,
"config_test": false,
"... |
### 1. Get board Page html:
def get_js_page(url):
from bs4 import BeautifulSoup
from selenium import webdriver
# driver = webdriver.Firefox()
driver = webdriver.PhantomJS()
driver.get(url) # 把網址交給瀏覽器
pagesource = driver.page_source # 取得網頁原始碼
soup = BeautifulSoup(pagesource, "html.parser")
... | {
"repo_name": "AmberFu/ptt_crawler",
"path": "ptt_hotboards_v1.py",
"copies": "1",
"size": "2948",
"license": "mit",
"hash": -4770832903510172000,
"line_mean": 32.488372093,
"line_max": 114,
"alpha_frac": 0.5493055556,
"autogenerated": false,
"ratio": 3.1101511879049677,
"config_test": false,
... |
# 1 Gold Star
# The built-in <string>.split() procedure works
# okay, but fails to find all the words on a page
# because it only uses whitespace to split the
# string. To do better, we should also use punctuation
# marks to split the page into words.
# Define a procedure, split_string, that takes two
# inputs: the s... | {
"repo_name": "JoseALermaIII/python-tutorials",
"path": "pythontutorials/Udacity/CS101/Lesson 16 - Problem Set/Q4-Better Splitting.py",
"copies": "1",
"size": "1524",
"license": "mit",
"hash": -6791508595602956000,
"line_mean": 33.6363636364,
"line_max": 82,
"alpha_frac": 0.6456692913,
"autogenerat... |
# 1. go to the page
# 2. collect all links
# 3. check the contents against the keyword dictionary
# 4. rank the pages according to keyword contents
# 5. group external links in a separate dictionary
# sites to crawl:
# http://hackaday.com/
# http://hackaday.io/
# http://dangerousprototypes.com/
# http://www.theledart.... | {
"repo_name": "s8/octopart-cpl-gallery",
"path": "code/octopart_crawler.py",
"copies": "1",
"size": "3017",
"license": "mit",
"hash": 6987369205041670000,
"line_mean": 23.3387096774,
"line_max": 103,
"alpha_frac": 0.6771627444,
"autogenerated": false,
"ratio": 2.8275538894095593,
"config_test":... |
# 1gram, line
# '# 1574 1 1 1'
def read_line(line, n=1, version='20090715'):
parts = line.strip().split('\t')
return parts[0], int(parts[2])
def merge_lines(lines):
tokens = []
cur_token = None
cur_token_count = 0
for line in lines:
if cur_token == None:
cur_token = line[0... | {
"repo_name": "anderscui/spellchecker",
"path": "ngrams/read_ngram_tests.py",
"copies": "1",
"size": "1225",
"license": "mit",
"hash": -8556453844077711000,
"line_mean": 23.0196078431,
"line_max": 87,
"alpha_frac": 0.4995918367,
"autogenerated": false,
"ratio": 3.0625,
"config_test": false,
"... |
"""1H-13C(methyl) - Multiple Quantum CPMG (2-state)
Analyzes HyCx methyl group multiple quantum CPMG measured on site-specific
13CH3-labeled methyl groups in a highly deuterated background. This is a
simplified basis set, which assumes you are on-resonance for 13C (ie, off-
resonance effects are not taken into accoun... | {
"repo_name": "gbouvignies/chemex",
"path": "chemex/experiments/cpmg/ch3_mq.py",
"copies": "1",
"size": "3018",
"license": "bsd-3-clause",
"hash": 2170835028613479200,
"line_mean": 32.9101123596,
"line_max": 80,
"alpha_frac": 0.640490391,
"autogenerated": false,
"ratio": 3.0985626283367558,
"co... |
# 1: have scripts which extract from .pbit to .pbit.extract - gitignore .pbit (and .pbix), AND creates .pbix.chksum (which is only useful for versioning purposes - one can confirm the state of their pbix)
# - script basically extracts .pbit to new folder .pbit.extract, but a) also extracts double-zipped content, an... | {
"repo_name": "kodonnell/powerbi-vcs",
"path": "pbivcs.py",
"copies": "1",
"size": "5644",
"license": "mit",
"hash": 6026769030615471000,
"line_mean": 40.8074074074,
"line_max": 387,
"alpha_frac": 0.6576895819,
"autogenerated": false,
"ratio": 3.7551563539587494,
"config_test": false,
"has_no... |
# --1.-- hello
from django.http import HttpResponse
# --2.-- hello_template
# helper function that uses settings.py to find templates and get them
from django.template.loader import get_template
# templates have a Context object to insert data we have generated to the template
from django.template import Context
# ... | {
"repo_name": "pyjosh/djangoprojects",
"path": "django_test/article/tut1_views.py",
"copies": "1",
"size": "1123",
"license": "mit",
"hash": -8881926080553042000,
"line_mean": 28.5789473684,
"line_max": 82,
"alpha_frac": 0.696349065,
"autogenerated": false,
"ratio": 3.6699346405228757,
"config_... |
"""1H - Pure Anti-phase Proton CPMG
Analyzes amide proton chemical exchange that is maintained as anti-phase
magnetization throughout the CPMG block. This results in lower intrinsic
relaxation rates and therefore better sensitivity. The calculations use a 12x12,
2-spin exchange matrix:
[ Hx(a), Hy(a), Hz(a), 2HxNz(a)... | {
"repo_name": "gbouvignies/chemex",
"path": "chemex/experiments/cpmg/hn_ap.py",
"copies": "1",
"size": "2909",
"license": "bsd-3-clause",
"hash": 8403258207461491000,
"line_mean": 31.6853932584,
"line_max": 88,
"alpha_frac": 0.5971124098,
"autogenerated": false,
"ratio": 3.127956989247312,
"con... |
""" 1) implementing __call__ method in BingoCage class
which gives it a function like properties"""
import random
words = ['pandas', 'numpy', 'matplotlib', 'seaborn', 'Tenserflow', 'Theano']
def reverse(x):
"""Reverse a letter"""
return x[::-1]
def key_len(x):
"""Sorting a list by their length""... | {
"repo_name": "Aneesh540/python-projects",
"path": "NEW/one.py",
"copies": "1",
"size": "1237",
"license": "apache-2.0",
"hash": -674820254150940300,
"line_mean": 21.9074074074,
"line_max": 80,
"alpha_frac": 0.6127728375,
"autogenerated": false,
"ratio": 3.494350282485876,
"config_test": false,... |
# 1 - Import library
import pygame
from pygame.locals import *
import math
import random
# 2 - Initialize the game
pygame.init()
width, height = 640, 480
screen=pygame.display.set_mode((width, height))
keys = [False, False, False, False]
playerpos=[100,100]
acc=[0,0]
arrows=[]
badtimer=100
badtimer1=0
badguys=[[640,10... | {
"repo_name": "kp96/Galaxy-Wars",
"path": "game.py",
"copies": "1",
"size": "6735",
"license": "apache-2.0",
"hash": -2329969878622506000,
"line_mean": 32.1773399015,
"line_max": 147,
"alpha_frac": 0.5988121752,
"autogenerated": false,
"ratio": 3.0965517241379312,
"config_test": false,
"has_n... |
import pygame
import math
import random
import sys
from pygame.locals import *
__author__ = 'piratf'
__blog__ = 'http://piratf.github.io/'
# thank to Julian Meyer
# https://plus.google.com/u/0/117404693911977592313?rel=author
# DIY
class gameConfig(object):
def __init__(self):
self.castleCount = 4;
... | {
"repo_name": "piratf/python",
"path": "myCastle/myCastle.py",
"copies": "1",
"size": "8724",
"license": "mpl-2.0",
"hash": -6953928184163962000,
"line_mean": 35.8143459916,
"line_max": 183,
"alpha_frac": 0.6035075653,
"autogenerated": false,
"ratio": 3.1415196254951385,
"config_test": false,
... |
############1. import modules
import math
import tkinter
############2a. def classes
class Board:
def __init__(self, state,row_length):
self.state = state
self.row_length = row_length
self.cells = [Cells(self,x) for x in range(row_length**2)]
def advance_state(self):
self.sta... | {
"repo_name": "Trafire/gameoflife",
"path": "game_of_life3.py",
"copies": "1",
"size": "4795",
"license": "artistic-2.0",
"hash": -8820360692040151000,
"line_mean": 27.0409356725,
"line_max": 300,
"alpha_frac": 0.6229405631,
"autogenerated": false,
"ratio": 3.705564142194745,
"config_test": fal... |
# 1 Imports
import serial
import numpy as np
import matplotlib.pyplot as plt
import sys
from select import select
from time import sleep
from mpl_toolkits.mplot3d import Axes3D
# 2 GLOBAL FUNCTIONS
# Makesphere
def sphere():
u = np.linspace(0, 2 * np.pi, 100)
v = np.linspace(0, np.pi, 100)
x1 = 1 * np.ou... | {
"repo_name": "vpetrog/CapSens_3d",
"path": "Python/CapSens_3d.py",
"copies": "1",
"size": "1866",
"license": "mit",
"hash": -1674483276459868400,
"line_mean": 21.756097561,
"line_max": 93,
"alpha_frac": 0.5927116827,
"autogenerated": false,
"ratio": 2.7934131736526946,
"config_test": false,
... |
1import sys as s
import subprocess as sb
from time import time
from parsingInfo import parseInfo
from actions import userNodeSelectionAct,randomSubSamplingAct,parseList
from featuresVector import featuresCreate
from misc import mergeList
from preformat import process
#/!\ The list of samples ID is supposed to be the ... | {
"repo_name": "kuredatan/taxoclassifier",
"path": "main.py",
"copies": "1",
"size": "3192",
"license": "mit",
"hash": -4673505485289917000,
"line_mean": 47.3636363636,
"line_max": 138,
"alpha_frac": 0.6284461153,
"autogenerated": false,
"ratio": 3.9850187265917603,
"config_test": false,
"has_... |
## 1. Introduction ##
import matplotlib.pyplot as plt
import pandas as pd
movie_reviews = pd.read_csv("fandango_score_comparison.csv")
fig = plt.figure(figsize=(5,12))
ax1 = fig.add_subplot(4,1,1)
ax2 = fig.add_subplot(4,1,2)
ax3 = fig.add_subplot(4,1,3)
ax4 = fig.add_subplot(4,1,4)
ax1.set_xlim(0,5.0)
ax2.set_xlim(0... | {
"repo_name": "vipmunot/Data-Analysis-using-Python",
"path": "Probability Statistics Beginner/Challenge_ Descriptive Statistics-199.py",
"copies": "1",
"size": "5360",
"license": "mit",
"hash": -8992975822006001000,
"line_mean": 34.0392156863,
"line_max": 106,
"alpha_frac": 0.6972014925,
"autogener... |
## 1. Introduction ##
import pandas as pd
import matplotlib.pyplot as plt
women_degrees = pd.read_csv('percent-bachelors-degrees-women-usa.csv')
major_cats = ['Biology', 'Computer Science', 'Engineering', 'Math and Statistics']
fig = plt.figure(figsize=(12, 12))
for sp in range(0,4):
ax = fig.add_subplot(2,2,sp... | {
"repo_name": "vipmunot/Data-Analysis-using-Python",
"path": "Storytelling Data Visualization/Color, Layout, and Annotations-221.py",
"copies": "1",
"size": "3726",
"license": "mit",
"hash": 1087989128212456200,
"line_mean": 33.8317757009,
"line_max": 116,
"alpha_frac": 0.6425120773,
"autogenerated... |
## 1. Introduction ##
import pandas as pd
titanic_survival = pd.read_csv("titanic_survival.csv")
## 2. Finding the Missing Data ##
age = titanic_survival["age"]
print(age.loc[10:20])
age_is_null = pd.isnull(age)
age_null_true = age[age_is_null]
age_null_count = len(age_null_true)
print(age_null_count)
## 3. Whats t... | {
"repo_name": "vipmunot/Data-Analysis-using-Python",
"path": "Data Analysis with Pandas Intermediate/Working with Missing Data-12.py",
"copies": "1",
"size": "3414",
"license": "mit",
"hash": -5665321346692120000,
"line_mean": 28.188034188,
"line_max": 103,
"alpha_frac": 0.7059168131,
"autogenerate... |
## 1. Introduction ##
import sqlite3
conn = sqlite3.connect("factbook.db")
query_plan_one = conn.execute("explain query plan select * from facts where population > 1000000 and population_growth < 0.05;").fetchall()
print(query_plan_one)
## 2. Query plan for multi-column queries ##
conn = sqlite3.connect("factbook.db... | {
"repo_name": "vipmunot/Data-Analysis-using-Python",
"path": "SQL and Databases Advanced/Multi-column indexing-192.py",
"copies": "1",
"size": "1702",
"license": "mit",
"hash": -3558964067178076000,
"line_mean": 47.6571428571,
"line_max": 168,
"alpha_frac": 0.7555816686,
"autogenerated": false,
"... |
## 1. Introduction ##
import sqlite3
conn = sqlite3.connect('factbook.db')
schema = conn.cursor().execute('pragma table_info(facts);').fetchall()
for item in schema:
print(item)
## 3. Explain query plan ##
conn = sqlite3.connect("factbook.db")
query_plan_one = conn.execute("explain query plan select * from facts... | {
"repo_name": "vipmunot/Data-Analysis-using-Python",
"path": "SQL and Databases Advanced/Introduction to Indexing-191.py",
"copies": "1",
"size": "1237",
"license": "mit",
"hash": 7707703663825764000,
"line_mean": 36.5151515152,
"line_max": 115,
"alpha_frac": 0.7299919159,
"autogenerated": false,
... |
## 1. Introduction ##
strings = ["data science", "big data", "metadata"]
regex = "data"
## 2. Wildcards in Regular Expressions ##
strings = ["bat", "robotics", "megabyte"]
regex = "b.t"
## 3. Searching the Beginnings And Endings Of Strings ##
strings = ["better not put too much", "butter in the", "batter"]
bad_str... | {
"repo_name": "vipmunot/Data-Analysis-using-Python",
"path": "Python Programming Intermediate/Regular Expressions-164.py",
"copies": "1",
"size": "3090",
"license": "mit",
"hash": -6379589411207080000,
"line_mean": 24.1300813008,
"line_max": 88,
"alpha_frac": 0.6187702265,
"autogenerated": false,
... |
## 1. Introduction to the data ##
import pandas as pd
cars = pd.read_csv("auto.csv")
unique_regions = cars['origin'].unique()
print(unique_regions)
## 2. Dummy variables ##
dummy_cylinders = pd.get_dummies(cars["cylinders"], prefix="cyl")
cars = pd.concat([cars, dummy_cylinders], axis=1)
print(cars.head())
dummy_yea... | {
"repo_name": "vipmunot/Data-Analysis-using-Python",
"path": "Machine learning Intermediate/Multiclass classification-75.py",
"copies": "1",
"size": "1641",
"license": "mit",
"hash": 1720536649932301600,
"line_mean": 27.3103448276,
"line_max": 85,
"alpha_frac": 0.704448507,
"autogenerated": false,
... |
## 1. Introduction to the Data ##
import pandas
import matplotlib.pyplot as plt
%matplotlib inline
pisa = pandas.DataFrame({"year": range(1975, 1988),
"lean": [2.9642, 2.9644, 2.9656, 2.9667, 2.9673, 2.9688, 2.9696,
2.9698, 2.9713, 2.9717, 2.9725, 2.9742, 2... | {
"repo_name": "vipmunot/Data-Analysis-using-Python",
"path": "Machine learning Intermediate/Intermediate linear regression-91.py",
"copies": "1",
"size": "2453",
"license": "mit",
"hash": -8755501218436172000,
"line_mean": 21.7222222222,
"line_max": 90,
"alpha_frac": 0.6526701998,
"autogenerated": ... |
## 1. Introduction to the data ##
import pandas
import matplotlib.pyplot as plt
# Read data from csv
pga = pandas.read_csv("pga.csv")
# Normalize the data
pga.distance = (pga.distance - pga.distance.mean()) / pga.distance.std()
pga.accuracy = (pga.accuracy - pga.accuracy.mean()) / pga.accuracy.std()
print(pga.head()... | {
"repo_name": "vipmunot/Data-Analysis-using-Python",
"path": "Machine learning Intermediate/Gradient descent-120.py",
"copies": "1",
"size": "5374",
"license": "mit",
"hash": -4489831073113787000,
"line_mean": 29.3672316384,
"line_max": 90,
"alpha_frac": 0.6635653145,
"autogenerated": false,
"rat... |
# -1 is an invalid value, stands for empty spot, and used to differentiate full queue from empty
class MyCircularQueue:
def __init__(self, k: int):
self.queue = k*[-1]
self.front = 0 # index of frontmost spot in the queue (unless empty)
self.back = 0 # index of first empty spot behind the q... | {
"repo_name": "SelvorWhim/competitive",
"path": "LeetCode/DesignCircularQueue.py",
"copies": "1",
"size": "1355",
"license": "unlicense",
"hash": -925041307391984500,
"line_mean": 29.7954545455,
"line_max": 96,
"alpha_frac": 0.6007380074,
"autogenerated": false,
"ratio": 3.3374384236453203,
"co... |
# 1 Jan 1900 was a Monday.
# Thirty days has September,
# April, June and November.
# All the rest have thirty-one,
# Saving February alone,
# Which has twenty-eight, rain or shine.
# And on leap years, twenty-nine.
# A leap year occurs on any year evenly divisible by 4, but not on a century unless it... | {
"repo_name": "Chane-O/CloudComputing",
"path": "Lab3/Euler19.py",
"copies": "1",
"size": "1320",
"license": "mit",
"hash": 6118242797865544000,
"line_mean": 21.0166666667,
"line_max": 109,
"alpha_frac": 0.5174242424,
"autogenerated": false,
"ratio": 3.1578947368421053,
"config_test": false,
... |
# 1KHz_SW_OSX.py
#
# A mono _pure_ sinewave generator using STANDARD text mode Python 2.6.7 to at least 2.7.3.
# This DEMO kids level 1KHz generator is mainly for a MacBook Pro, (13 inch in my case), OSX 10.7.5 and above.
# It is another simple piece of testgear for the young amateur electronics enthusiast and
# uses p... | {
"repo_name": "ActiveState/code",
"path": "recipes/Python/578301_Platform_Independent_1KHz_Pure_Audio_Sinewave/recipe-578301.py",
"copies": "1",
"size": "2570",
"license": "mit",
"hash": 3911356146682183700,
"line_mean": 43.3103448276,
"line_max": 121,
"alpha_frac": 0.7214007782,
"autogenerated": f... |
# 1 max() function
def max(a,b):
if a > b:
return a
elif b > a:
return b
# 2 max_of_three function
def max_of_three(a,b,c):
myList = []
myList.append(a)
myList.append(b)
myList.append(c)
myList.sort()
return myList[len(myList)-1]
# 3 length of string/list
def length(thi... | {
"repo_name": "QuirinoC/Python",
"path": "verySimple1-15.py",
"copies": "1",
"size": "4026",
"license": "apache-2.0",
"hash": 7025417077723305000,
"line_mean": 21.0989010989,
"line_max": 80,
"alpha_frac": 0.5808055694,
"autogenerated": false,
"ratio": 2.8106219426974146,
"config_test": false,
... |
1##############################################
# combine reads over run over multiple lanes
##############################################
import os, sys, re
import collections
import glob
# script for linking files
scriptsdir = "/ifs/projects/proj029/src"
# first link to data in working directory
os.system("python... | {
"repo_name": "CGATOxford/proj029",
"path": "scripts/combine_lanes_rna.py",
"copies": "1",
"size": "1520",
"license": "bsd-3-clause",
"hash": -4403520974888712000,
"line_mean": 30.6666666667,
"line_max": 84,
"alpha_frac": 0.5730263158,
"autogenerated": false,
"ratio": 3.19327731092437,
"config_... |
1#
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writin... | {
"repo_name": "google-research/tiny-differentiable-simulator",
"path": "setup.py",
"copies": "1",
"size": "10828",
"license": "apache-2.0",
"hash": 996629850098382500,
"line_mean": 34.1558441558,
"line_max": 124,
"alpha_frac": 0.6535833025,
"autogenerated": false,
"ratio": 3.3637775706741224,
"... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.