text stringlengths 0 1.05M | meta dict |
|---|---|
# Based on http://www.nytimes.com/interactive/2012/08/05/sports/olympics/the-100-meter-dash-one-race-every-medalist-ever.html
from bokeh.models import (Arrow, ColumnDataSource, CustomJS, DataRange1d,
FixedTicker, HoverTool, Label, LinearAxis, NormalHead,
Range1d, Sin... | {
"repo_name": "ericmjl/bokeh",
"path": "examples/plotting/file/sprint.py",
"copies": "1",
"size": "5023",
"license": "bsd-3-clause",
"hash": -2820099624783941600,
"line_mean": 36.7669172932,
"line_max": 159,
"alpha_frac": 0.6669321123,
"autogenerated": false,
"ratio": 2.6918542336548765,
"confi... |
# Based on http://www.nytimes.com/interactive/2012/08/05/sports/olympics/the-100-meter-dash-one-race-every-medalist-ever.html
from __future__ import print_function
from bokeh.plotting import figure, show, output_file
from bokeh.models import (
ColumnDataSource,
Range1d, DataRange1d,
LinearAxis, SingleInte... | {
"repo_name": "rs2/bokeh",
"path": "examples/plotting/file/sprint.py",
"copies": "10",
"size": "5027",
"license": "bsd-3-clause",
"hash": 873633172196518800,
"line_mean": 35.4275362319,
"line_max": 159,
"alpha_frac": 0.6715735031,
"autogenerated": false,
"ratio": 2.673936170212766,
"config_test... |
# Based on http://www.voidspace.org.uk/python/weblog/arch_d7_2006_07_01.shtml
import tkinter as tk
class ToolTip(object):
def __init__(self, widget):
self.widget = widget
self.tipwindow = None
self.id = None
self.x = self.y = 0
def showtip(self, text):
"Display text in... | {
"repo_name": "Tarskin/MassyTools",
"path": "MassyTools/gui/tooltip.py",
"copies": "1",
"size": "1529",
"license": "apache-2.0",
"hash": 6481575336948999000,
"line_mean": 30.8541666667,
"line_max": 77,
"alpha_frac": 0.5376062786,
"autogenerated": false,
"ratio": 3.531177829099307,
"config_test"... |
# Based on http://www.voidspace.org.uk/python/weblog/arch_d7_2006_07_01.shtml
import tkinter as tk
class ToolTip(object):
def __init__(self, widget):
self.widget = widget
self.tipwindow = None
self.id = None
self.x = self.y = 0
def showtip(self, text):
"Display text i... | {
"repo_name": "Tarskin/HappyTools",
"path": "HappyTools/gui/tooltip.py",
"copies": "1",
"size": "1530",
"license": "apache-2.0",
"hash": -8194485796847753000,
"line_mean": 30.2244897959,
"line_max": 77,
"alpha_frac": 0.537254902,
"autogenerated": false,
"ratio": 3.533487297921478,
"config_test"... |
# based on ideas from https://github.com/dennybritz/cnn-text-classification-tf
import numpy as np
import json
def load_yelp(alphabet):
examples = []
labels = []
with open('./yelp-review-dataset/yelp_academic_dataset_review.json') as f:
i = 0
for line in f:
review = json.loads(... | {
"repo_name": "Twelve33/CharCNN",
"path": "preprocessing.py",
"copies": "1",
"size": "3633",
"license": "mit",
"hash": 3346031661014909400,
"line_mean": 36.84375,
"line_max": 98,
"alpha_frac": 0.5794109551,
"autogenerated": false,
"ratio": 3.2670863309352516,
"config_test": false,
"has_no_key... |
# based on ideas from https://github.com/dennybritz/cnn-text-classification-tf
import tensorflow as tf
class CharCNN(object):
"""
A CNN for text classification.
based on the Character-level Convolutional Networks for Text Classification paper.
"""
def __init__(self, num_classes=2, filter_sizes=(7... | {
"repo_name": "Twelve33/CharCNN",
"path": "model.py",
"copies": "1",
"size": "7246",
"license": "mit",
"hash": -7758767301976791000,
"line_mean": 50.0281690141,
"line_max": 118,
"alpha_frac": 0.5259453492,
"autogenerated": false,
"ratio": 3.261026102610261,
"config_test": false,
"has_no_keywo... |
"""ISO 8601 date time string parsing
Basic usage:
>>> import iso8601
>>> iso8601.parse_date("2007-01-25T12:00:00Z")
datetime.datetime(2007, 1, 25, 12, 0, tzinfo=<iso8601.iso8601.Utc ...>)
>>>
"""
import re
from datetime import datetime, timedelta, tzinfo
__all__ = ["parse_date", "ParseError"]
# Adapted from http... | {
"repo_name": "madgik/exareme",
"path": "Exareme-Docker/src/exareme/exareme-tools/madis/src/lib/iso8601.py",
"copies": "1",
"size": "5147",
"license": "mit",
"hash": -7758165931808996000,
"line_mean": 30.7716049383,
"line_max": 105,
"alpha_frac": 0.6337672431,
"autogenerated": false,
"ratio": 3.7... |
# Based on itk2.2/tests/widget.test code.
import Tkinter
import Test
import Pmw
Test.initialise()
class TestWidget(Pmw.MegaWidget):
def __init__(self, parent = None, **kw):
# Define the megawidget options.
optiondefs = (
('status', '', self._status),
('background', 'linen', ... | {
"repo_name": "leuschel/logen",
"path": "old_logen/pylogen/Pmw/Pmw_1_2/tests/MegaWidget_test.py",
"copies": "3",
"size": "4107",
"license": "apache-2.0",
"hash": 5577583645720220000,
"line_mean": 30.8372093023,
"line_max": 79,
"alpha_frac": 0.6208911614,
"autogenerated": false,
"ratio": 3.3942148... |
# Based on iwidgets2.2.0/buttonbox.itk code.
import types
import Tkinter
import Pmw
class ButtonBox(Pmw.MegaWidget):
def __init__(self, parent = None, **kw):
# Define the megawidget options.
INITOPT = Pmw.INITOPT
optiondefs = (
('labelmargin', 0, INITOPT),
('labelpos', No... | {
"repo_name": "eflowbeach/draw-your-taf",
"path": "Pmw/Pmw_1_3/lib/PmwButtonBox.py",
"copies": "6",
"size": "6987",
"license": "mit",
"hash": 759138816630292200,
"line_mean": 30.1919642857,
"line_max": 77,
"alpha_frac": 0.6424788894,
"autogenerated": false,
"ratio": 3.4623389494549057,
"config_... |
# Based on iwidgets2.2.0/dialog.itk and iwidgets2.2.0/dialogshell.itk code.
# Convention:
# Each dialog window should have one of these as the rightmost button:
# Close Close a window which only displays information.
# Cancel Close a window which may be used to change the state of
# ... | {
"repo_name": "silly-wacky-3-town-toon/SOURCE-COD",
"path": "Panda3D-1.10.0/Pmw/Pmw_1_3/lib/PmwDialog.py",
"copies": "6",
"size": "5697",
"license": "apache-2.0",
"hash": -4461853125469523500,
"line_mean": 29.9619565217,
"line_max": 75,
"alpha_frac": 0.6196243637,
"autogenerated": false,
"ratio":... |
# Based on iwidgets2.2.0/entryfield.itk code.
import re
import string
import types
import Tkinter
import Pmw
# Possible return values of validation functions.
OK = 1
ERROR = 0
PARTIAL = -1
class EntryField(Pmw.MegaWidget):
_classBindingsDefinedFor = 0
def __init__(self, parent = None, **kw):
# Define the ... | {
"repo_name": "silly-wacky-3-town-toon/SOURCE-COD",
"path": "Panda3D-1.10.0/Pmw/Pmw_1_3/lib/PmwEntryField.py",
"copies": "6",
"size": "13478",
"license": "apache-2.0",
"hash": -7610443967844998000,
"line_mean": 28.4279475983,
"line_max": 77,
"alpha_frac": 0.652544888,
"autogenerated": false,
"rat... |
# Based on iwidgets2.2.0/messagedialog.itk code.
import Tkinter
import Pmw
class MessageDialog(Pmw.Dialog):
def __init__(self, parent = None, **kw):
# Define the megawidget options.
INITOPT = Pmw.INITOPT
optiondefs = (
('borderx', 20, INITOPT),
('bordery', 20, INITOPT),
('icon... | {
"repo_name": "leuschel/logen",
"path": "old_logen/pylogen/Pmw/Pmw_1_2/lib/PmwMessageDialog.py",
"copies": "6",
"size": "1921",
"license": "apache-2.0",
"hash": 4384091546442817000,
"line_mean": 25.3150684932,
"line_max": 63,
"alpha_frac": 0.6548672566,
"autogenerated": false,
"ratio": 3.07852564... |
# Based on iwidgets2.2.0/promptdialog.itk code.
import Pmw
# A Dialog with an entryfield
class PromptDialog(Pmw.Dialog):
def __init__(self, parent = None, **kw):
# Define the megawidget options.
INITOPT = Pmw.INITOPT
optiondefs = (
('borderx', 20, INITOPT),
('bordery', 20, INITOPT),
)... | {
"repo_name": "toontownfunserver/Panda3D-1.9.0",
"path": "Pmw/Pmw_1_3/lib/PmwPromptDialog.py",
"copies": "6",
"size": "1532",
"license": "bsd-3-clause",
"hash": -3096006457386029600,
"line_mean": 29.0392156863,
"line_max": 70,
"alpha_frac": 0.6821148825,
"autogenerated": false,
"ratio": 3.3596491... |
# Based on iwidgets2.2.0/tests/entryfield.test code.
import Tkinter
import Test
import Pmw
Test.initialise()
_myValidators = {
'hello' : (lambda s: s == 'hello', len),
}
c = Pmw.EntryField
kw_1 = {'entry_width' : 12, 'labelpos' : 'n', 'label_text' : 'Entry Field:'}
tests_1 = (
(c.pack, (), {'padx' : 10, 'pad... | {
"repo_name": "leuschel/logen",
"path": "old_logen/pylogen/Pmw/Pmw_1_2/tests/EntryField_test.py",
"copies": "3",
"size": "3117",
"license": "apache-2.0",
"hash": -9165346414015937000,
"line_mean": 27.5963302752,
"line_max": 79,
"alpha_frac": 0.5717035611,
"autogenerated": false,
"ratio": 2.859633... |
# Based on iwidgets2.2.0/tests/labeledwidget.test code.
import Tkinter
import Test
import Pmw
Test.initialise()
c = Pmw.LabeledWidget
def _addListbox():
w = Test.currentWidget()
lb = Tkinter.Listbox(w.interior(), relief = 'sunken')
lb.pack(padx = 10, pady = 10)
def _testalignLabels():
w = Test.curr... | {
"repo_name": "mhcrnl/PmwTkEx",
"path": "src/Pmw/Pmw_1_3/tests/LabeledWidget_test.py",
"copies": "3",
"size": "1092",
"license": "apache-2.0",
"hash": -6844227455823318000,
"line_mean": 21.2857142857,
"line_max": 74,
"alpha_frac": 0.5750915751,
"autogenerated": false,
"ratio": 2.696296296296296,
... |
# Based on lazy pirate pattern
import zmq
import sys
import numpy
def recv_array(socket, flags=0, copy=True, track=False):
"""recv a numpy array"""
md = socket.recv_json(flags=flags)
msg = socket.recv(flags=flags, copy=copy, track=track)
buf = buffer(msg)
A = numpy.frombuffer(buf, dtype=md['dtype'... | {
"repo_name": "DawesLab/Camserver",
"path": "TestClient.py",
"copies": "1",
"size": "2036",
"license": "mit",
"hash": -4244321531216862000,
"line_mean": 28.5072463768,
"line_max": 66,
"alpha_frac": 0.5952848723,
"autogenerated": false,
"ratio": 3.8487712665406426,
"config_test": false,
"has_n... |
import numpy as np
def _vector_magnitude(arr):
# things that don't work here:
# * np.linalg.norm
# - doesn't broadcast in numpy 1.7
# - drops the mask from ma.array
# * using keepdims - broken on ma.array until 1.11.2
# * using sum - discards mask on ma.array unless entire vector is ... | {
"repo_name": "pierotofy/WebODM",
"path": "app/api/hillshade.py",
"copies": "2",
"size": "5517",
"license": "mpl-2.0",
"hash": -2881412354583315500,
"line_mean": 40.4887218045,
"line_max": 90,
"alpha_frac": 0.6253398586,
"autogenerated": false,
"ratio": 4.300077942322681,
"config_test": false,
... |
# Based on Matthew Taylor's MIT-Licensed automatatron (https://github.com/rhyolight/automatatron)
# modified by 7yl4r 09-2015
#
import math
def default_string_formatter(row, width=0):
side_padding = int(math.floor((width - len(row) )/ 2)) * " "
out = side_padding
for v in row:
if v:
c... | {
"repo_name": "Sciguymjm/CellularAutomata",
"path": "cellular_musician/ElementaryCAEngine.py",
"copies": "1",
"size": "5483",
"license": "mit",
"hash": 5955478255527414000,
"line_mean": 32.8456790123,
"line_max": 97,
"alpha_frac": 0.523618457,
"autogenerated": false,
"ratio": 3.807638888888889,
... |
# based on Megazig's modification of Treeki/Ninjifox's sel_parse.py
# modifications made 8 january 2014
import sys
import struct
from idc import *
# dol.py
class DOLHeader(object):
def __init__(self, data=None):
self.offsetText = [0 for x in xrange(7)]
self.offsetData = [0 for x in xrange(11)]
self.addressText ... | {
"repo_name": "andlabs/idapyscripts",
"path": "selparse.py",
"copies": "1",
"size": "15173",
"license": "mit",
"hash": 89740681883312850,
"line_mean": 28.9270216963,
"line_max": 232,
"alpha_frac": 0.6058129572,
"autogenerated": false,
"ratio": 2.845648912228057,
"config_test": false,
"has_no_... |
# Based on Michael Angeletti's MIT Licensed pycard
# https://github.com/orokusaki/pycard
import calendar
import datetime
import re
from .gateway import PaymentGateway
__all__ = ('Card',)
non_digit_regexp = re.compile(r'\D')
class Card(object):
"""
A credit card that may be valid or invalid.
"""
#... | {
"repo_name": "dmpayton/qualpay-python",
"path": "qualpay/card.py",
"copies": "1",
"size": "6679",
"license": "mit",
"hash": -564879969406560800,
"line_mean": 27.9134199134,
"line_max": 79,
"alpha_frac": 0.5647552029,
"autogenerated": false,
"ratio": 3.903565166569258,
"config_test": false,
"... |
# Based on Mike Dewar's excellent d3talk:
# https://github.com/mikedewar/d3talk
import json
import urllib
from operator import itemgetter
import time
from meetupapikey import getKey
"""
# The meetupapikey.py file should look like this:
def getKey():
return "PASTE_YOUR_KEY_HERE"
"""
def get_data(endpoint, params)... | {
"repo_name": "jimbo00000/meetup-attendance-graph",
"path": "data/get_meetup_attendance.py",
"copies": "1",
"size": "1486",
"license": "mit",
"hash": -7914352425636048000,
"line_mean": 22.9677419355,
"line_max": 60,
"alpha_frac": 0.6076716016,
"autogenerated": false,
"ratio": 3.513002364066194,
... |
# based on multilineplot example in matplotlib with MRI data (I think)
# uses line collections (might actually be from pbrain example)
# clm
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.collections import LineCollection
def stackplot(marray, seconds=None, start_time=None, ylabels=None, ax=None)... | {
"repo_name": "holgern/pyedflib",
"path": "demo/stacklineplot.py",
"copies": "1",
"size": "2409",
"license": "bsd-2-clause",
"hash": 1255750994874320600,
"line_mean": 28.0240963855,
"line_max": 87,
"alpha_frac": 0.6185139062,
"autogenerated": false,
"ratio": 3.2642276422764227,
"config_test": f... |
# Based on multiprocessing/connection.py (c) 2006-2008, R Oudkerk
from multiprocessing.connection import Listener, Client, ConnectionWrapper
from six import text_type, binary_type
from six import u,b
from six import print_
import os
pid = os.getpid()
from bytestrpickle import BytestrPickler, BytestrUnpickler
import... | {
"repo_name": "valhallasw/py2",
"path": "bPickleListener.py",
"copies": "1",
"size": "1413",
"license": "mit",
"hash": 7891377560821920000,
"line_mean": 29.0638297872,
"line_max": 76,
"alpha_frac": 0.7048832272,
"autogenerated": false,
"ratio": 3.6511627906976742,
"config_test": false,
"has_n... |
# Based on ncquick.py, by - M. Neish 2008/09/21
# ncquick.py was released as part of CCMval3.0
# - Read-only access
#####################################################
# Extended
# June 2014, Martin Juckes:
# Added routines to read all attributes.
# Refactored to creat a digest of file metadata: the digest is retu... | {
"repo_name": "martinjuckes/ceda_cc",
"path": "ceda_cc/ncq3.py",
"copies": "1",
"size": "10550",
"license": "bsd-3-clause",
"hash": -3178336475108397600,
"line_mean": 35.3793103448,
"line_max": 142,
"alpha_frac": 0.6134597156,
"autogenerated": false,
"ratio": 3.113931523022432,
"config_test": f... |
# Based on NeoPixel library and strandtest example by Tony DiCola (tony@tonydicola.com)
# To be used with a 12x1 NeoPixel LED stripe.
# Place the LEDs in a circle an watch the time go by ...
# red = hours
# blue = minutes 1-5
# green = seconds
# (To run the program permanently and with autostart use systemd.)
import t... | {
"repo_name": "wcthompson/theia",
"path": "modules/lights/rpi_ws281x/python/lit.py",
"copies": "1",
"size": "3704",
"license": "mit",
"hash": -6084232281977881000,
"line_mean": 35.3137254902,
"line_max": 87,
"alpha_frac": 0.6079913607,
"autogenerated": false,
"ratio": 3.3100983020554064,
"confi... |
# based on netlink.py at ....
# https://gforge.inria.fr/scm/viewvc.php/canso/trunk/tools/netlink.py?view=markup&revision=1360&root=mehani&pathrev=1360
# https://www.linuxjournal.com/article/7356?page=0,1
# http://smacked.org/docs/netlink.pdf
# RFC 3549 - https://tools.ietf.org/html/rfc3549
class NetLinkError(Exceptio... | {
"repo_name": "borjam/exabgp",
"path": "src/exabgp/netlink/__init__.py",
"copies": "3",
"size": "1863",
"license": "bsd-3-clause",
"hash": -8192067921772952000,
"line_mean": 31.6842105263,
"line_max": 120,
"alpha_frac": 0.4777241009,
"autogenerated": false,
"ratio": 2.6805755395683453,
"config_... |
# based on NFC Data Exchange Format (NDEF) Technical Specification from nfc-forum.org
# and http://androidxref.com/source/xref/external/libnfc-nxp/src/phFriNfc_NdefRecord.c
# line 87 - phFriNfc_NdefRecord_GetRecords()
import struct
import functools
class InvalidNdef(Exception):
pass
class Invalid... | {
"repo_name": "project-humix/humix-sense-nfc",
"path": "ndef-0.1/build/lib.linux-armv7l-2.7/ndef/ndef.py",
"copies": "2",
"size": "11674",
"license": "apache-2.0",
"hash": -7220142583422095000,
"line_mean": 27.3316582915,
"line_max": 118,
"alpha_frac": 0.5459996574,
"autogenerated": false,
"ratio... |
# Based on
# http://norvig.com/lispy.html
# http://norvig.com/lispy2.html
#
# http://julien.danjou.info/blog/2013/lisp-python-hy
#
# if (x.val() > 0) {
# z = f(a * x.val() + b[i]);
# }
#
# (if (> (val x) 0)
# (let z
# (f (+ (* a (val x))
# (aref b i)))))
#
#
# (if (> (val x) 0)
# (let z
# ... | {
"repo_name": "kopos/pyl",
"path": "lispy.py",
"copies": "1",
"size": "1871",
"license": "mit",
"hash": 6114785484863403000,
"line_mean": 22.0987654321,
"line_max": 63,
"alpha_frac": 0.4462854089,
"autogenerated": false,
"ratio": 2.8564885496183208,
"config_test": false,
"has_no_keywords": fa... |
# Based on
# https://github.com/dnouri/skorch/blob/master/notebooks/MNIST.ipynb
# Code using skorch and pure pytorch:
# https://github.com/dnouri/skorch/blob/master/examples/benchmarks/mnist.py
import numpy as np
from time import time
import torch
from torch import nn
import torch.nn.functional as F
from skorch i... | {
"repo_name": "probml/pyprobml",
"path": "scripts/mnist_skorch.py",
"copies": "1",
"size": "2307",
"license": "mit",
"hash": -6949460967204183000,
"line_mean": 26.7951807229,
"line_max": 78,
"alpha_frac": 0.6224534027,
"autogenerated": false,
"ratio": 2.830674846625767,
"config_test": true,
"... |
# Based on
# https://github.com/tensorflow/docs/blob/master/site/en/tutorials/keras/basic_classification.ipynb
# (MIT License)
from __future__ import absolute_import, division, print_function
from tensorflow import keras
import tensorflow as tf
import numpy as np
import matplotlib.pyplot as plt
import os
figdir = ".... | {
"repo_name": "probml/pyprobml",
"path": "scripts/cifar_viz_tf.py",
"copies": "1",
"size": "1045",
"license": "mit",
"hash": 8278081231127158000,
"line_mean": 20.7708333333,
"line_max": 99,
"alpha_frac": 0.6622009569,
"autogenerated": false,
"ratio": 2.831978319783198,
"config_test": false,
"... |
# Based on
# https://www.teachme.codes/numpy-docs/Meshgrid-SimulationExample/code/
# https://scicomp.stackexchange.com/questions/33325/can-i-solve-a-model-in-gekko-with-black-box-simulated-annealing-or-ga-solvers
import numpy as np
import matplotlib.pyplot as plt
import random
import math
import pyprobml_utils as pml... | {
"repo_name": "probml/pyprobml",
"path": "scripts/sim_anneal_demo.py",
"copies": "1",
"size": "4243",
"license": "mit",
"hash": -5022982126176162000,
"line_mean": 26.5584415584,
"line_max": 129,
"alpha_frac": 0.5691727551,
"autogenerated": false,
"ratio": 2.6854430379746836,
"config_test": fals... |
# Based on Niels analysis
from os.path import join
from pycqed.analysis import measurement_analysis as ma
from scipy import stats
import numpy as np
import pylab
# %matplotlib inline
from matplotlib import pyplot as plt
from numpy.linalg import inv
def two_qubit_ssro_fidelity(label, fig_format='png',
... | {
"repo_name": "DiCarloLab-Delft/PycQED_py3",
"path": "pycqed/analysis/multiplexed_RO_analysis.py",
"copies": "1",
"size": "11664",
"license": "mit",
"hash": 3165155721472675300,
"line_mean": 44.3852140078,
"line_max": 79,
"alpha_frac": 0.5423525377,
"autogenerated": false,
"ratio": 3.005410976552... |
# Based on Niels analysis
from os.path import join
from pycqed.analysis import measurement_analysis as ma
import numpy as np
import pylab
# %matplotlib inline
from matplotlib import pyplot as plt
from numpy.linalg import inv
def two_qubit_ssro_fidelity(label, fig_format='png',
qubit_labels... | {
"repo_name": "QudevETH/PycQED_py3",
"path": "pycqed/analysis/multiplexed_RO_analysis.py",
"copies": "1",
"size": "11620",
"license": "mit",
"hash": 5465614913819884000,
"line_mean": 44.390625,
"line_max": 79,
"alpha_frac": 0.5421686747,
"autogenerated": false,
"ratio": 2.9933024214322512,
"con... |
""" Based on numpy's approach to exposing compiler features via a config header.
Unfortunately that file is not exposed, so re-implement the portions we need.
"""
import os
import sys
import textwrap
from distutils.command.config import config as Config
from typing import List
OPTIONAL_FUNCTION_ATTRIBUTES = [
("HA... | {
"repo_name": "kwgoodman/bottleneck",
"path": "bottleneck/src/bn_config.py",
"copies": "1",
"size": "5497",
"license": "bsd-2-clause",
"hash": 4179673994442259000,
"line_mean": 26.078817734,
"line_max": 90,
"alpha_frac": 0.5797707841,
"autogenerated": false,
"ratio": 3.8147120055517,
"config_te... |
from osgeo import ogr, gdal
from string import Template
import tempfile
def GeomType2Name(type):
if type == ogr.wkbUnknown:
return 'wkbUnknown'
elif type == ogr.wkbPoint:
return 'wkbPoint'
elif type == ogr.wkbLineString:
return 'wkbLineString'
elif type == ogr.wkbPolygon:
... | {
"repo_name": "sourcepole/ogrtools",
"path": "ogrtools/pyogr/ogrvrt.py",
"copies": "1",
"size": "5203",
"license": "mit",
"hash": 544235602680848300,
"line_mean": 32.5677419355,
"line_max": 89,
"alpha_frac": 0.5652508168,
"autogenerated": false,
"ratio": 4.030209140201395,
"config_test": false,... |
# Based on one of the angular DI examples
import time
from collections import namedtuple
from jugular import Inject, Provide, Injector
def has(*args):
# I got tired of writing __init__s of "self.x = x"
has.i = getattr(has, 'i', -1)+1
return namedtuple("Base{}".format(has.i), args)
class Electricity(obje... | {
"repo_name": "dplepage/jugular",
"path": "jugular/coffee.py",
"copies": "1",
"size": "3625",
"license": "bsd-2-clause",
"hash": -227700512002335970,
"line_mean": 25.4598540146,
"line_max": 81,
"alpha_frac": 0.6772413793,
"autogenerated": false,
"ratio": 2.935222672064777,
"config_test": false,... |
from . import colors
from .render_context import RenderContext
class PyDepGraphDot(object):
def __init__(self, colored=True):
self.colored = colored
def render(self, depgraph, ctx):
with ctx.graph():
visited = set()
drawn = set()
for aname, bname in depgr... | {
"repo_name": "thebjorn/pydeps",
"path": "pydeps/depgraph2dot.py",
"copies": "1",
"size": "5529",
"license": "bsd-2-clause",
"hash": -2636181783967987700,
"line_mean": 33.9936708861,
"line_max": 73,
"alpha_frac": 0.532284319,
"autogenerated": false,
"ratio": 4.194992412746585,
"config_test": fa... |
# Based on override_server.py by Twisted Matrix Laboratories.
#
# Example :
# $ dig -p 10053 @127.0.0.1 -x 2001:db8::1 +short
# 2001-0db8-0000-0000-0000-0000-0000-0001.example.net.
#
from twisted.internet import reactor, defer
from twisted.names import client, dns, error, server
class DynamicResolver(object):
_my... | {
"repo_name": "ledeuns/ipv6ptr",
"path": "ipv6ptr.py",
"copies": "1",
"size": "1614",
"license": "mit",
"hash": 7628632987676761000,
"line_mean": 29.4528301887,
"line_max": 130,
"alpha_frac": 0.6282527881,
"autogenerated": false,
"ratio": 3.3006134969325154,
"config_test": false,
"has_no_keyw... |
## Based on PEP-354, copied and adapted from
## http://stackoverflow.com/questions/36932/
_enum_registry = {}
def enum_value_unpickler(names, value):
enum_class = _enum_registry.get(names, None) or Enum(*names)
return enum_class[value]
def Enum(*names):
"""
Constructs a class with named constants. T... | {
"repo_name": "qPCR4vir/orange3",
"path": "Orange/misc/enum.py",
"copies": "10",
"size": "2775",
"license": "bsd-2-clause",
"hash": 2048132079780105000,
"line_mean": 29.4945054945,
"line_max": 79,
"alpha_frac": 0.6169369369,
"autogenerated": false,
"ratio": 4.004329004329004,
"config_test": fal... |
""" based on phidl tutorial
"""
import pp
# ==============================================================================
# We'll start by assuming we have a function waveguide() which already exists
# and makes us a simple waveguide rectangle. Many functions like this
# exist in the pp.components library and are ... | {
"repo_name": "psiq/gdsfactory",
"path": "pp/samples/01_component.py",
"copies": "1",
"size": "2475",
"license": "mit",
"hash": 7791808730449498000,
"line_mean": 44.8333333333,
"line_max": 84,
"alpha_frac": 0.6274747475,
"autogenerated": false,
"ratio": 3.7162162162162162,
"config_test": false,... |
"""Based on phidl tutorial.
We'll start by assuming we have a function straight() which already exists
and makes us a simple straight rectangle. Many functions like this
exist in the pp.components library and are ready-for-use. We write this
one out fully just so it's explicitly clear what's happening
"""
import p... | {
"repo_name": "gdsfactory/gdsfactory",
"path": "pp/samples/01_component.py",
"copies": "1",
"size": "2375",
"license": "mit",
"hash": 3246161499334682600,
"line_mean": 43.8113207547,
"line_max": 84,
"alpha_frac": 0.6446315789,
"autogenerated": false,
"ratio": 3.7109375,
"config_test": false,
... |
#based on protowiki written by Paul Bissex, MIT licensed.
#see e-scribe.com for more information
from django.http import HttpResponse, HttpResponseRedirect, Http404
from django.shortcuts import render_to_response, get_object_or_404
from django import template
from django.template import RequestContext
from django.contr... | {
"repo_name": "jerem/django-rcsfield",
"path": "rcs/wiki/views.py",
"copies": "3",
"size": "4919",
"license": "bsd-3-clause",
"hash": -5459132573549535000,
"line_mean": 36.2727272727,
"line_max": 127,
"alpha_frac": 0.6554177678,
"autogenerated": false,
"ratio": 3.8610675039246467,
"config_test"... |
# Based on PyPA sampleproject setup.py
# https://github.com/pypa/sampleproject/blob/master/setup.py
# Always prefer setuptools over distutils
from setuptools import setup, find_packages
# To use a consistent encoding
from codecs import open
from os import path
here = path.abspath(path.dirname(__file__))
# Get the lo... | {
"repo_name": "ROldford/tvregex",
"path": "setup.py",
"copies": "1",
"size": "1421",
"license": "mit",
"hash": -2305365087081940000,
"line_mean": 31.2954545455,
"line_max": 65,
"alpha_frac": 0.6389866291,
"autogenerated": false,
"ratio": 3.809651474530831,
"config_test": false,
"has_no_keywor... |
# based on pyserial example
import sys
import threading
import socket
from IoTPy.detect_sfp_serial import detect_sfp_serial
class Redirector:
def __init__(self, serial_instance, socket):
self.serial = serial_instance
self.socket = socket
self._write_lock = threading.Lock()
self.ali... | {
"repo_name": "8devices/IoTPy",
"path": "IoTPy/serial_socket_server.py",
"copies": "1",
"size": "2892",
"license": "mit",
"hash": 930395924471271200,
"line_mean": 32.2413793103,
"line_max": 92,
"alpha_frac": 0.5363070539,
"autogenerated": false,
"ratio": 4.221897810218978,
"config_test": false,... |
# Based on python 2.7.12 by Seungwon Park
#
# change to python 3.6 by guitar79@gs.hs.kr
#
target = '1024_HMII.jpg'
import time
from datetime import date, timedelta
import urllib.request
from urllib.request import urlopen
from bs4 import BeautifulSoup
from sys import argv
script, starttime, endtime, hourgap = argv # ... | {
"repo_name": "seungwonpark/SunSpotTracker",
"path": "getdata_bs.py",
"copies": "1",
"size": "2686",
"license": "mit",
"hash": -800955286107281200,
"line_mean": 37.3714285714,
"line_max": 116,
"alpha_frac": 0.6273268801,
"autogenerated": false,
"ratio": 3.328376703841388,
"config_test": false,
... |
# Based on python 2.7.12
target = '1024_HMII.jpg'
import httplib
import time
from datetime import date, timedelta
from sys import argv
script, starttime, endtime, hourgap = argv # Input : starttime, endtime in '20160901'-like format
start_t = time.strptime(starttime, '%Y%m%d')
end_t = time.strptime(endtime, '%Y%m%d')
... | {
"repo_name": "seungwonpark/SunSpotTracker",
"path": "getdata.py",
"copies": "1",
"size": "2609",
"license": "mit",
"hash": -6914649748705829000,
"line_mean": 41.0806451613,
"line_max": 134,
"alpha_frac": 0.6136450747,
"autogenerated": false,
"ratio": 3.5114401076716018,
"config_test": false,
... |
# Based on Python 3.5.2 | Anaconda 4.1.1
# Print software information
print('This is SunSpotTracker. (c) Seungwon Park under the terms of the MIT License')
print('Source : https://github.com/seungwonpark/SunSpotTracker')
from sys import argv
script, bool_plot, bool_raw = argv # Input : whether or not to plot(show) th... | {
"repo_name": "seungwonpark/SunSpotTracker",
"path": "track.py",
"copies": "1",
"size": "4726",
"license": "mit",
"hash": -8140484073194892000,
"line_mean": 33.496350365,
"line_max": 161,
"alpha_frac": 0.6098180279,
"autogenerated": false,
"ratio": 3.4,
"config_test": false,
"has_no_keywords"... |
# based on python script from
# http://diyhpl.us/reprap/trunk/users/wizard23/python/lookupTables/KTY84-130.py
#
# adapted by Stemer114 for usage with 4.7k pull-up resistor
# and table format for teacup firmware
# https://github.com/Stemer114/Reprap_KTY-84-130
#
# generates a Lookuptable for the following termistor
# ... | {
"repo_name": "Stemer114/Reprap_KTY-84-130",
"path": "teacup/KTY84-130.py",
"copies": "1",
"size": "1926",
"license": "mit",
"hash": -7605933926584698000,
"line_mean": 25.027027027,
"line_max": 109,
"alpha_frac": 0.7237798546,
"autogenerated": false,
"ratio": 2.7165021156558535,
"config_test": ... |
# Based on Python's rlcompleter.py, under the Python license. Replacement for
# the function computing possible matches, with the following improvements:
# - Sort matches and eliminate duplicates.
# - Handle subscripting with [].
def undercmp(s1, s2):
"""Compare two strings, sorting leading underscores last."""
... | {
"repo_name": "ii0/bits",
"path": "python/rlcompleter_extra.py",
"copies": "3",
"size": "1972",
"license": "bsd-3-clause",
"hash": -1590825469464690400,
"line_mean": 32.4237288136,
"line_max": 78,
"alpha_frac": 0.6318458418,
"autogenerated": false,
"ratio": 3.8365758754863815,
"config_test": fa... |
# Based on Rapptz's RoboDanny's repl cog
import contextlib
import inspect
import logging
import re
import sys
import textwrap
import traceback
from io import StringIO
from typing import *
from typing import Pattern
import discord
from discord.ext import commands
# i took this from somewhere and i cant remember where
... | {
"repo_name": "10se1ucgo/LoLTrivia",
"path": "plugins/debug.py",
"copies": "1",
"size": "4487",
"license": "mit",
"hash": -866453898180844000,
"line_mean": 37.3333333333,
"line_max": 121,
"alpha_frac": 0.5915273133,
"autogenerated": false,
"ratio": 3.81053525913339,
"config_test": false,
"has... |
# Based on read_phd.m matlab reader
"""
Edward Barnard
2011-12-16 Initial version for PHD files v1.0 and v1.1
2012-01-25 Updated for PHD file v2.0
2012-10-03 Updated for handling PT2 files (TTTR mode)
2012-12-09 Added handy t2_event_ arrays
2013-11-20 (N. Borys) Fixed overflow problem due to implicit use of 32 bit
... | {
"repo_name": "ScopeFoundry/FoundryDataBrowser",
"path": "viewers/picoharp_tttr/picoharpdata.py",
"copies": "1",
"size": "13520",
"license": "bsd-3-clause",
"hash": 3820829410439180000,
"line_mean": 40.6,
"line_max": 130,
"alpha_frac": 0.524852071,
"autogenerated": false,
"ratio": 3.3251352680767... |
# based on Recipe 466302: Sorting big files the Python 2.4 way
# by Nicolas Lehuen
import os
from tempfile import gettempdir
from itertools import islice, cycle
from collections import namedtuple
import heapq
Keyed = namedtuple("Keyed", ["key", "obj"])
def merge(key=None, *iterables):
# based on code posted by S... | {
"repo_name": "ActiveState/code",
"path": "recipes/Python/576755_Sorting_big_files_Pyth26/recipe-576755.py",
"copies": "1",
"size": "3287",
"license": "mit",
"hash": 5650213577271727000,
"line_mean": 31.87,
"line_max": 91,
"alpha_frac": 0.582293885,
"autogenerated": false,
"ratio": 3.979418886198... |
from __future__ import absolute_import
import os
from _socket import gaierror
from gevent.hub import Waiter, get_hub
from minemeld.packages.gdns._ares import channel
class Dig(object):
ares_class = channel
# from arpa/nameser.h
NS_C_INVALID = 0 # Cookie
NS_C_IN = 1 # Internet
NS_C_2 = 2 # un... | {
"repo_name": "PaloAltoNetworks/minemeld-core",
"path": "minemeld/packages/gdns/dig.py",
"copies": "1",
"size": "4336",
"license": "apache-2.0",
"hash": -3208025670796274700,
"line_mean": 32.875,
"line_max": 76,
"alpha_frac": 0.588099631,
"autogenerated": false,
"ratio": 3.1420289855072463,
"co... |
# Based on Schreiber & Fitting
# See /doc/extra/phonon-scattering.lyx
from cslib import units, Settings
from cslib.dcs import DCS
from cslib.numeric import (log_interpolate)
from cstool.parse_input import read_input
from math import pi
import numpy as np
from numpy import (cos, expm1, log10)
from functools import ... | {
"repo_name": "eScatter/cstool",
"path": "cstool/phonon.py",
"copies": "1",
"size": "9859",
"license": "apache-2.0",
"hash": 1145041127032658800,
"line_mean": 35.6902985075,
"line_max": 79,
"alpha_frac": 0.5825282213,
"autogenerated": false,
"ratio": 2.9671092335546168,
"config_test": false,
... |
# Based on scripts at https://github.com/tensorflow/tensorflow/contrib/learn/python/learn/datasets/
'''Dataset utilities'''
import pickle
import collections
from os import path
from tensorflow.python.framework import dtypes
import numpy as np
Datasets = collections.namedtuple('Datasets', ['train', 'validation', 'te... | {
"repo_name": "jpypi/fifar",
"path": "input_data.py",
"copies": "1",
"size": "6035",
"license": "mit",
"hash": 8557386500900142000,
"line_mean": 33.683908046,
"line_max": 99,
"alpha_frac": 0.6071251036,
"autogenerated": false,
"ratio": 3.631167268351384,
"config_test": true,
"has_no_keywords"... |
## based on scrolledtext from stad lib.
##
from tkinter import *
from tkinter.ttk import *
from tkinter.constants import RIGHT, LEFT, Y, BOTH
class ScrolledListbox(Listbox):
def __init__(self, master=None, **kw):
self.frame = Frame(master)
self.vbar = Scrollbar(self.frame)
self.vbar.pack(s... | {
"repo_name": "Moggs/Workbench",
"path": "Moggs/scrolledlistbox.py",
"copies": "1",
"size": "1408",
"license": "apache-2.0",
"hash": -6582387110591413000,
"line_mean": 27.7346938776,
"line_max": 76,
"alpha_frac": 0.5710227273,
"autogenerated": false,
"ratio": 3.705263157894737,
"config_test": f... |
## based on scrolledtext from stad lib.
##
from tkinter import *
from tkinter.ttk import *
from tkinter.constants import RIGHT, LEFT, Y, BOTH
class ScrolledTreeview(Treeview):
def __init__(self, master=None, **kw):
self.frame = Frame(master)
self.vbar = Scrollbar(self.frame)
self.vbar.pack... | {
"repo_name": "Moggs/Workbench",
"path": "Moggs/scrolledtreeview.py",
"copies": "1",
"size": "1487",
"license": "apache-2.0",
"hash": 4254150768215091700,
"line_mean": 27.5961538462,
"line_max": 76,
"alpha_frac": 0.5655682582,
"autogenerated": false,
"ratio": 3.7645569620253165,
"config_test": ... |
""" Macros.py, part of django-macros, allows for creation of
macros within django templates.
"""
from re import match as regex_match
from django import template
from django.template.loader import get_template
register = template.Library()
def _setup_macros_dict(parser):
""" initiates the _macros attribute on t... | {
"repo_name": "nalourie/django-macros",
"path": "build/lib/macros/templatetags/macros.py",
"copies": "4",
"size": "14973",
"license": "mit",
"hash": -1806403522701615900,
"line_mean": 34.2305882353,
"line_max": 86,
"alpha_frac": 0.60595739,
"autogenerated": false,
"ratio": 4.306298533218292,
"c... |
# Based on spec summary at
# http://artis.imag.fr/~Xavier.Decoret/resources/xdkbibtex/bibtex_summary.html
from pygments.lexer import RegexLexer, bygroups, include
from pygments.token import Text, Comment, Keyword, String, Number, Other, \
Punctuation, Literal, Name
class BibtexLexer(RegexLexer):
name = 'B... | {
"repo_name": "madelfio/bibtex-pygments-lexer",
"path": "bibtex_lexer/__init__.py",
"copies": "1",
"size": "2575",
"license": "bsd-2-clause",
"hash": -5758792963468312000,
"line_mean": 31.5949367089,
"line_max": 81,
"alpha_frac": 0.4629126214,
"autogenerated": false,
"ratio": 3.8838612368024132,
... |
"""Sports scheduling problem.
We want to solve the problem of scheduling of team matches in a
double round robin tournament. Given a number of teams, we want
each team to encounter all other teams, twice, once at home, and
once away. Furthermore, you cannot meet the same team twice in the
same half-season.
Finally, ... | {
"repo_name": "google/or-tools",
"path": "examples/contrib/sports_schedule_sat.py",
"copies": "1",
"size": "23021",
"license": "apache-2.0",
"hash": 8028797076192178000,
"line_mean": 39.5264084507,
"line_max": 355,
"alpha_frac": 0.5895564534,
"autogenerated": false,
"ratio": 3.989428076256499,
... |
# Based on STScI's JWST calibration pipeline.
from __future__ import print_function
import os
import subprocess
import sys
from setuptools import setup, find_packages, Extension, Command
from glob import glob
# Open the README as the package long description
readme = open('README.rst', 'r')
README_TEXT = readme.read... | {
"repo_name": "mrlb05/Nifty4Gemini",
"path": "setup.py",
"copies": "2",
"size": "1507",
"license": "mit",
"hash": 4198450984396142600,
"line_mean": 30.3958333333,
"line_max": 124,
"alpha_frac": 0.6675514267,
"autogenerated": false,
"ratio": 3.7118226600985222,
"config_test": false,
"has_no_ke... |
# Based on super lightweight Simple Top-Down Parser from http://effbot.org/zone/simple-top-down-parsing.htm
# and https://bitbucket.org/emacsway/sqlbuilder/src/default/sqlbuilder/smartsql/contrib/evaluate.py
import re
from rope.base.utils import pycompat
from rope.base.oi.type_hinting import utils
from rope.base import... | {
"repo_name": "ruchee/vimrc",
"path": "vimfiles/bundle/vim-python/submodules/rope/rope/base/oi/type_hinting/evaluate.py",
"copies": "6",
"size": "9046",
"license": "mit",
"hash": -8564178755186267000,
"line_mean": 24.6260623229,
"line_max": 107,
"alpha_frac": 0.5517355737,
"autogenerated": false,
... |
#based on T1932 protocol
import usb.core
import time
import T1932_calibration
import ant
import sys
import binascii
import struct
import platform, glob
import os
from datetime import datetime
import argparse
if os.name == 'posix':
import serial
def fromcomp(val,bits):
if val>>(bits-1) == 1:
return 0-(val^(2**... | {
"repo_name": "john-38787364/antifier",
"path": "old-scripts/tacx-interface.py",
"copies": "1",
"size": "16333",
"license": "mit",
"hash": -4635780321883579000,
"line_mean": 45.933908046,
"line_max": 261,
"alpha_frac": 0.600991857,
"autogenerated": false,
"ratio": 3.2145246998622317,
"config_te... |
# Based on TensorFlow Examples
import tensorflow as tf
import numpy as np
from tensorflow.examples.tutorials.mnist import input_data
def init_weights(shape):
return tf.Variable(tf.random_normal(shape, stddev=0.01))
def model(X, w):
return tf.matmul(X, w) # notice we use the same model as linear regression,... | {
"repo_name": "AdityaSoni19031997/Machine-Learning",
"path": "__TensorFlow__/Logistic_Regression.py",
"copies": "1",
"size": "1619",
"license": "mit",
"hash": 2244195095575512600,
"line_mean": 40.5128205128,
"line_max": 170,
"alpha_frac": 0.7047560222,
"autogenerated": false,
"ratio": 3.297352342... |
""" Based on the AIMA Python code.
"""
from collections import deque
class CSP(object):
""" A finite-domain Constraint Satisfaction Problem.
Specified by the following:
vars:
A list of variables (ints or strings)
domains:
A dict holding for ea... | {
"repo_name": "sunilthorat09/code-for-blog",
"path": "2009/csp_for_euler68/csplib.py",
"copies": "13",
"size": "9926",
"license": "unlicense",
"hash": 5758542632364886000,
"line_mean": 34.7232472325,
"line_max": 82,
"alpha_frac": 0.5230707234,
"autogenerated": false,
"ratio": 4.7379474940334125,
... |
# Based on the data sheet from here:
# http://www.adafruit.com/datasheets/WS2812.pdf
from babyfood.pcb.PCBUnits import toMM
from babyfood.features.basic import CenteredRectangle, FilledCenteredRectangle, FilledCenteredCircle
from babyfood.components.ABC import AbstractSMAComponent
class WS2812(AbstractSMAComponent):... | {
"repo_name": "meawoppl/babyfood",
"path": "babyfood/components/ws2812.py",
"copies": "1",
"size": "1648",
"license": "bsd-2-clause",
"hash": -4189904362653551600,
"line_mean": 28.4285714286,
"line_max": 100,
"alpha_frac": 0.5934466019,
"autogenerated": false,
"ratio": 3.2250489236790605,
"conf... |
# Based on the example found at
# https://github.com/pyca/pyopenssl/blob/de0a71ec331102c4c5bb1470752e992cc85d731b/examples/certgen.py
"""
Certificate generation module.
"""
from OpenSSL import crypto
from hashlib import md5
DIGEST_ALGORITHM = "sha1"
def gen_key_pair():
"""
Create a public/private key pair.
... | {
"repo_name": "thefourtheye/simple-https-proxy",
"path": "gen_ca_cert.py",
"copies": "1",
"size": "2324",
"license": "mit",
"hash": 7945182170034566000,
"line_mean": 29.9866666667,
"line_max": 101,
"alpha_frac": 0.660929432,
"autogenerated": false,
"ratio": 3.3632416787264834,
"config_test": fa... |
## Based on the example of Google OR-Tools
## https://developers.google.com/optimization/bin/knapsack
import sys
import numpy as np
import pandas as pd
import sqlite3
from ortools.algorithms import pywrapknapsack_solver
def main():
filename = "saizeriya.db"
conn = sqlite3.connect(filename)
df ... | {
"repo_name": "zettsu-t/cPlusPlusFriend",
"path": "scripts/stock_price/max_calorie.py",
"copies": "1",
"size": "1212",
"license": "mit",
"hash": -2432109721062511000,
"line_mean": 31.6666666667,
"line_max": 73,
"alpha_frac": 0.6229372937,
"autogenerated": false,
"ratio": 3.3573407202216066,
"co... |
# Based on the excellent
# https://gist.github.com/karpathy/a4166c7fe253700972fcbc77e4ea32c5
# and uses Keras.
import os
import gym
import cv2
import argparse
import sys, glob
import numpy as np
import cPickle as pickle
from keras import backend as K
import matplotlib.pyplot as plt
from keras.models import Sequential
f... | {
"repo_name": "mkturkcan/Keras-Pong",
"path": "keras_pong.py",
"copies": "1",
"size": "4965",
"license": "mit",
"hash": -4206931707484586000,
"line_mean": 33.4861111111,
"line_max": 114,
"alpha_frac": 0.6839879154,
"autogenerated": false,
"ratio": 3.0497542997542997,
"config_test": false,
"ha... |
# # Based on the excellent UW Coursera Data Science Course Code:
# https://github.com/uwescience/datasci_course_materials/blob/master/assignment1/twitterstream.py
#
import oauth2 as oauth
import urllib2 as urllib
###########################################################################
## Fill these in using the RE... | {
"repo_name": "CrossD/Stuff",
"path": "Lecture_Code/Twitter/my_twitterstream.py",
"copies": "1",
"size": "2127",
"license": "mit",
"hash": 1716216531435844400,
"line_mean": 31.2272727273,
"line_max": 97,
"alpha_frac": 0.6361071932,
"autogenerated": false,
"ratio": 3.4811783960720133,
"config_te... |
# Copyright 2007 Google Inc.
#
# 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 writing... | {
"repo_name": "aswadrangnekar/khandelwal",
"path": "app/lib/console/app/model/session.py",
"copies": "13",
"size": "4353",
"license": "mit",
"hash": -5103086882410572000,
"line_mean": 31.9772727273,
"line_max": 80,
"alpha_frac": 0.7181254307,
"autogenerated": false,
"ratio": 3.8658969804618115,
... |
# Based on the Haskell program at the bottom, as seen on the haskell-cafe mailing list.
# 28/3/10. Transliterated into Python by Bernie.
#import resource
#import sys
# Increase max stack size from 8MB to 512MB
#resource.setrlimit(resource.RLIMIT_STACK, (2**29,-1))
#sys.setrecursionlimit(10**6)
# rangeK :: Int -> Int... | {
"repo_name": "bjpop/blip",
"path": "test/regression/programs/imaginary/range.py",
"copies": "4",
"size": "1369",
"license": "bsd-3-clause",
"hash": 3871337765659348500,
"line_mean": 24.3518518519,
"line_max": 87,
"alpha_frac": 0.5178962747,
"autogenerated": false,
"ratio": 2.6895874263261295,
... |
# Based on the implementation in django-postgres but with various fixes
# and form-integration.
#
# Once Django 1.8 supports this ootb this module can be removed.
import uuid
from django import forms
from django.core.exceptions import ValidationError
from django.db import models
from django.utils.translation import ug... | {
"repo_name": "recipi/recipi",
"path": "src/recipi/utils/db/uuid.py",
"copies": "1",
"size": "2470",
"license": "isc",
"hash": 6055126675795241000,
"line_mean": 28.0588235294,
"line_max": 71,
"alpha_frac": 0.5842105263,
"autogenerated": false,
"ratio": 4.395017793594306,
"config_test": false,
... |
# Based on the Izhikevich model published in IEEE Transactions on Neural Networks (2003) 14:1569-1572
# Original paper + MATLAB implementation available at: http://www.izhikevich.org/publications/spikes.htm
# This implemntation simulates a population of densely coupled, electrophysiologically diverse neurons
# and enab... | {
"repo_name": "maxentile/izhikevich-model",
"path": "src/main.py",
"copies": "1",
"size": "10724",
"license": "mit",
"hash": 5016514087899158000,
"line_mean": 38.8661710037,
"line_max": 137,
"alpha_frac": 0.640619172,
"autogenerated": false,
"ratio": 3.1237984270317507,
"config_test": false,
... |
# Based on the json-rpc specs: http://json-rpc.org/wiki/specification
# The main deviation is on the error treatment. The official spec
# would set the 'error' attribute to a string. This implementation
# sets it to a dictionary with keys: message/traceback/type
import json
import SocketServer
import sys
import traceb... | {
"repo_name": "robisen1/AndroidWifiCracker",
"path": "services/autocrack/jsonrpclib.py",
"copies": "1",
"size": "10168",
"license": "mit",
"hash": -6847311897269802000,
"line_mean": 31.0788643533,
"line_max": 78,
"alpha_frac": 0.5842840283,
"autogenerated": false,
"ratio": 4.339735381988903,
"c... |
"""lxml.etree protection"""
from __future__ import print_function, absolute_import
import threading
from lxml import etree as _etree
from defusedxml.lxml import DTDForbidden, EntitiesForbidden, NotSupportedError
LXML3 = _etree.LXML_VERSION[0] >= 3
__origin__ = "lxml.etree"
tostring = _etree.tostring
class Rest... | {
"repo_name": "onelogin/python-saml",
"path": "src/onelogin/saml2/xmlparser.py",
"copies": "1",
"size": "4730",
"license": "mit",
"hash": 847148643332638700,
"line_mean": 31.6206896552,
"line_max": 93,
"alpha_frac": 0.6746300211,
"autogenerated": false,
"ratio": 3.9548494983277593,
"config_test... |
# Based on the matplot script
# created by Eugene M. Izhikevich, February 25, 2003
# http://www.izhikevich.org/publications/net.m
import numpy as np
import matplotlib.pyplot as plt
# Excitatory and Inhibitatory synapses
Ne, Ni = 800, 200
re = np.random.rand(Ne, 1)
ri = np.random.rand(Ni, 1)
a = np.vstack((0.02*np.on... | {
"repo_name": "johannesmik/neurons",
"path": "MISC/izhikevich.py",
"copies": "2",
"size": "1320",
"license": "bsd-2-clause",
"hash": 4126183445639389700,
"line_mean": 32.8461538462,
"line_max": 77,
"alpha_frac": 0.5681818182,
"autogenerated": false,
"ratio": 2.3783783783783785,
"config_test": f... |
'''Based on the paper doi=10.1.1.89.7835
the tricubic interpolation of a regular possibly non uniform grid can be seen as a computation of 21 cubic splines.
A cubic spline is a special case of cubic interpolation, and in general these 21 cubic splines perform many redundant
calulations. Here we formulate the full tr... | {
"repo_name": "Joshuaalbert/IonoTomo",
"path": "src/ionotomo/geometry/tri_cubic.py",
"copies": "1",
"size": "5227",
"license": "apache-2.0",
"hash": -6561066054867470000,
"line_mean": 37.3007518797,
"line_max": 117,
"alpha_frac": 0.5833173905,
"autogenerated": false,
"ratio": 3.240545567265964,
... |
# Based on the pyotp: https://github.com/nathforge/pyotp
import base64
import hashlib
import hmac
import datetime
import time
import sys
class OTP(object):
def __init__(self, secret, digits=6):
self.secret = secret
def int_to_bytestring(self, int, padding=8):
"""
Turns ... | {
"repo_name": "jpf/Twilio-TFA",
"path": "example/totp-all-code.py",
"copies": "2",
"size": "2634",
"license": "mit",
"hash": -1443509712289296100,
"line_mean": 28.9882352941,
"line_max": 72,
"alpha_frac": 0.539483675,
"autogenerated": false,
"ratio": 3.789928057553957,
"config_test": false,
"... |
""" Based on the Python code or the C++ code provided in class as a starting point, implement the double linked listnode delete function. """
class Node(object):
def __init__(self, value):
self.value = value
self.next = None
self.prev = None
class List(object):
def __init__(self... | {
"repo_name": "megasan/210-CT",
"path": "coursework 11.py",
"copies": "1",
"size": "1684",
"license": "mit",
"hash": -3776321415069396000,
"line_mean": 30.3846153846,
"line_max": 141,
"alpha_frac": 0.4798099762,
"autogenerated": false,
"ratio": 4.374025974025974,
"config_test": false,
"has_no... |
# Based on the python URDF implementation by Antonio El Khoury
# Available at https://github.com/laas/robot_model_py
import string
from naoqi_tools.gazeboUrdf import *
from xml.dom.minidom import Document
from xml.dom import minidom
import sys
from numpy import array,pi
import re, copy
HUBO_JOINT_SUFFIX_MASK=r'([HKAS... | {
"repo_name": "suryaambrose/naoqi_bridge",
"path": "naoqi_tools/src/naoqi_tools/urdf.py",
"copies": "3",
"size": "47193",
"license": "bsd-3-clause",
"hash": 6077045270437059000,
"line_mean": 34.8337129841,
"line_max": 127,
"alpha_frac": 0.5664187485,
"autogenerated": false,
"ratio": 3.71891252955... |
# based on the setup.py from the original python-eway module at
# https://github.com/alexhayes/python-eway/
import os
from distutils.command.install import INSTALL_SCHEMES
from setuptools import setup
def fullsplit(path, result=None):
"""
Split a pathname into components (the opposite of os.path.join) in a
... | {
"repo_name": "fractalcat/python-eway-token",
"path": "setup.py",
"copies": "2",
"size": "2327",
"license": "mit",
"hash": -5523639243859137000,
"line_mean": 35.359375,
"line_max": 104,
"alpha_frac": 0.6510528578,
"autogenerated": false,
"ratio": 3.676145339652449,
"config_test": false,
"has_... |
from common import Task
import Trace
import Common
from common import pyparsing as p
from common import Collections
#
# Trace query language syntax definition
#
p.ParserElement.setDefaultWhitespaceChars(" \t\n")
selectStmt = p.Forward()
selectToken = p.Keyword("select", caseless = True)
fromToken ... | {
"repo_name": "skyostil/tracy",
"path": "src/analyzer/TraceQueryLanguage.py",
"copies": "1",
"size": "13118",
"license": "mit",
"hash": 8617579609617171000,
"line_mean": 30.795,
"line_max": 119,
"alpha_frac": 0.5988717792,
"autogenerated": false,
"ratio": 3.529190207156309,
"config_test": false... |
# based on the snippet from https://github.com/gabrielfalcao/HTTPretty/issues/387
import httpretty
import requests
from sure import expect
@httpretty.activate(allow_net_connect=False, verbose=True)
def test_match_with_port_no_slashes():
"Reproduce #387 registering host:port without trailing slash"
httpretty.r... | {
"repo_name": "gabrielfalcao/HTTPretty",
"path": "tests/bugfixes/nosetests/test_387_regex_port.py",
"copies": "1",
"size": "1130",
"license": "mit",
"hash": -7995189224972210000,
"line_mean": 42.4615384615,
"line_max": 95,
"alpha_frac": 0.7053097345,
"autogenerated": false,
"ratio": 3.20113314447... |
# Based on the Stack Overflow answers provided here - http://stackoverflow.com/a/6343321 and
# here - http://stackoverflow.com/a/8462170.
from django.template import Library, Node, TemplateSyntaxError, Variable
from django.conf import settings
register = Library()
# [From the SO answer]
# I found some tricks in URL... | {
"repo_name": "PrecisionMojo/pm-www",
"path": "www/templatetags/get_setting.py",
"copies": "2",
"size": "1619",
"license": "mit",
"hash": -7565971626369321000,
"line_mean": 32.0408163265,
"line_max": 92,
"alpha_frac": 0.6195182211,
"autogenerated": false,
"ratio": 3.891826923076923,
"config_tes... |
# Based on the ttypager and supporting functions from pydoc, under the Python
# license, with various improvements.
import bits
import bits.input
import contextlib
import itertools
import os
import os.path
import pager
import redirect
import string
import sys
import textwrap
from cStringIO import StringIO
def getpage... | {
"repo_name": "biosbits/bits",
"path": "python/ttypager.py",
"copies": "1",
"size": "6000",
"license": "bsd-3-clause",
"hash": 8869779934602414000,
"line_mean": 35.5853658537,
"line_max": 98,
"alpha_frac": 0.4821666667,
"autogenerated": false,
"ratio": 4.261363636363637,
"config_test": false,
... |
# Based on the ttypager and supporting functions from pydoc, under the Python
# license, with various improvements.
import bits
import contextlib
import itertools
import os
import os.path
import pager
import readline
import redirect
import string
import sys
import textwrap
from cStringIO import StringIO
def getpager(... | {
"repo_name": "ii0/bits",
"path": "python/ttypager.py",
"copies": "1",
"size": "5880",
"license": "bsd-3-clause",
"hash": 610250034406500500,
"line_mean": 35.2962962963,
"line_max": 98,
"alpha_frac": 0.4794217687,
"autogenerated": false,
"ratio": 4.276363636363636,
"config_test": false,
"has_... |
# Based on the ttypager and supporting functions from pydoc, under the Python
# license, with various improvements.
import bits
import contextlib
import pager
import redirect
import string
import sys
import textwrap
from cStringIO import StringIO
def getpager():
return ttypager
def plain(text):
"""Remove bol... | {
"repo_name": "mfleming/bits",
"path": "python/ttypager.py",
"copies": "1",
"size": "3851",
"license": "bsd-3-clause",
"hash": 3173841411025642000,
"line_mean": 34.6574074074,
"line_max": 97,
"alpha_frac": 0.4822124124,
"autogenerated": false,
"ratio": 4.241189427312776,
"config_test": false,
... |
# based on the work by praekelt
# https://github.com/praekelt/vumi/blob/develop/vumi/scripts/parse_log_messages.py
from dateutil.parser import parse as dateutil_parse
import json
import logging
import re
from django.conf import settings
from libya_elections.constants import INCOMING
from .models import VumiLog
logg... | {
"repo_name": "SmartElect/SmartElect",
"path": "audit/parser.py",
"copies": "1",
"size": "4595",
"license": "apache-2.0",
"hash": 8943721967867926000,
"line_mean": 37.9406779661,
"line_max": 97,
"alpha_frac": 0.5732317737,
"autogenerated": false,
"ratio": 3.6701277955271565,
"config_test": fals... |
# Based on the work of https://github.com/AlessandroZ/LaZagne/blob/master/Windows/lazagne/
from Crypto.Cipher import AES
import xml.etree.cElementTree as ET
import win32con, win32api, win32crypt
import base64, hashlib, os
import binascii, struct
class Skype():
def __init__(self):
options = {'command': '-s'... | {
"repo_name": "mehulj94/BrainDamage",
"path": "Echoes/skype.py",
"copies": "1",
"size": "5161",
"license": "apache-2.0",
"hash": 3659519721632377300,
"line_mean": 34.5931034483,
"line_max": 114,
"alpha_frac": 0.4938965317,
"autogenerated": false,
"ratio": 4.162096774193548,
"config_test": false... |
# Based on the work of https://github.com/AlessandroZ/LaZagne/blob/master/Windows/lazagne/
from ctypes import *
import sys, os, re, glob
from base64 import b64decode
from ConfigParser import RawConfigParser
import sqlite3
import json
import shutil
from itertools import product
from pyasn1.codec.der import decoder
from ... | {
"repo_name": "mehulj94/BrainDamage",
"path": "Echoes/Mozilla.py",
"copies": "1",
"size": "15855",
"license": "apache-2.0",
"hash": 7251665437986585000,
"line_mean": 32.7340425532,
"line_max": 114,
"alpha_frac": 0.5072847682,
"autogenerated": false,
"ratio": 4.201112877583466,
"config_test": fa... |
# Based on the work of https://github.com/AlessandroZ/LaZagne/blob/master/Windows/lazagne/
import struct
from ctypes import *
from ctypes.wintypes import DWORD
import win32cred
memcpy = cdll.msvcrt.memcpy
LocalFree = windll.kernel32.LocalFree
CryptUnprotectData = windll.crypt32.CryptUnprotectData
CRYPTPROTECT_UI_FORBI... | {
"repo_name": "mehulj94/BrainDamage",
"path": "Echoes/dotnet.py",
"copies": "1",
"size": "2835",
"license": "apache-2.0",
"hash": 7527146958572488000,
"line_mean": 29.4838709677,
"line_max": 109,
"alpha_frac": 0.5343915344,
"autogenerated": false,
"ratio": 3.9594972067039107,
"config_test": fal... |
# Based on the work of https://github.com/AlessandroZ/LaZagne/blob/master/Windows/lazagne/
import struct, os
class FtpNavigator():
def __init__(self):
pass
def decode(self, encode_password):
password = ''
for p in encode_password:
password += chr(struct.unpack('B', p)[0] ^... | {
"repo_name": "mehulj94/BrainDamage",
"path": "Echoes/ftpnavigator.py",
"copies": "1",
"size": "1668",
"license": "apache-2.0",
"hash": -1212289724167834400,
"line_mean": 29.8888888889,
"line_max": 90,
"alpha_frac": 0.4706235012,
"autogenerated": false,
"ratio": 3.790909090909091,
"config_test"... |
# Based on the work of https://github.com/AlessandroZ/LaZagne/blob/master/Windows/lazagne/
import struct, platform, win32cred
from ctypes import *
from ctypes.wintypes import DWORD
memcpy = cdll.msvcrt.memcpy
LocalFree = windll.kernel32.LocalFree
CryptUnprotectData = windll.crypt32.CryptUnprotectData
CRYPTPROTECT_UI_F... | {
"repo_name": "mehulj94/BrainDamage",
"path": "Echoes/network.py",
"copies": "1",
"size": "3191",
"license": "apache-2.0",
"hash": 2692546732037276000,
"line_mean": 28.5462962963,
"line_max": 109,
"alpha_frac": 0.5133187089,
"autogenerated": false,
"ratio": 4.144155844155844,
"config_test": fal... |
# Based on the work of https://github.com/AlessandroZ/LaZagne/blob/master/Windows/lazagne/
import win32con, win32api
class WinSCP():
def __init__(self):
self.hash = ''
self.username = ''
self.hostname = ''
# ------------------------------ Getters and Setters --------------------------... | {
"repo_name": "mehulj94/BrainDamage",
"path": "Echoes/winscp.py",
"copies": "1",
"size": "4699",
"license": "apache-2.0",
"hash": 1601096011369322000,
"line_mean": 27.8282208589,
"line_max": 120,
"alpha_frac": 0.5037241966,
"autogenerated": false,
"ratio": 3.9923534409515717,
"config_test": fal... |
# Based on the work of https://github.com/AlessandroZ/LaZagne/blob/master/Windows/lazagne/
import xml.etree.cElementTree as ET
import os, base64
class Filezilla():
def __init__(self):
options = {'command': '-f', 'action': 'store_true', 'dest': 'filezilla', 'help': 'filezilla'}
def run(self):
i... | {
"repo_name": "mehulj94/BrainDamage",
"path": "Echoes/Filezilla.py",
"copies": "1",
"size": "3024",
"license": "apache-2.0",
"hash": -2301478715659637200,
"line_mean": 37.2784810127,
"line_max": 102,
"alpha_frac": 0.4626322751,
"autogenerated": false,
"ratio": 4.616793893129771,
"config_test": ... |
# Based on the work of https://github.com/AlessandroZ/LaZagne/blob/master/Windows/lazagne/
import xml.etree.cElementTree as ET
import win32con, win32api
import os
class Putty():
def __init__(self):
pass
def run(self):
try:
database_path = self.get_default_database()
excep... | {
"repo_name": "mehulj94/BrainDamage",
"path": "Echoes/putty.py",
"copies": "1",
"size": "2207",
"license": "apache-2.0",
"hash": -5536991115452718000,
"line_mean": 29.2328767123,
"line_max": 119,
"alpha_frac": 0.4898051654,
"autogenerated": false,
"ratio": 4.1720226843100185,
"config_test": fal... |
# Based on the works of https://github.com/AlessandroZ/LaZagne/blob/master/Windows/lazagne/
import binascii
from Crypto.Cipher import AES
import win32con, win32api
class CoreFTP():
def __init__(self):
self
def get_secret(self):
return "hdfzpysvpzimorhk"
def decrypt(self, hex):
en... | {
"repo_name": "mehulj94/BrainDamage",
"path": "Echoes/Coreftp.py",
"copies": "1",
"size": "2005",
"license": "apache-2.0",
"hash": 6431771041319390000,
"line_mean": 29.3787878788,
"line_max": 117,
"alpha_frac": 0.5167082294,
"autogenerated": false,
"ratio": 3.6788990825688073,
"config_test": fa... |
# Based on the works of https://github.com/AlessandroZ/LaZagne/blob/master/Windows/lazagne/
import win32api, win32con, win32crypt
class Outlook():
def __init__(self):
options = {'command': '-o', 'action': 'store_true', 'dest': 'outlook',
'help': 'outlook - IMAP, POP3, HTTP, SMTP, LDPAP ... | {
"repo_name": "mehulj94/BrainDamage",
"path": "Echoes/outlook.py",
"copies": "1",
"size": "2430",
"license": "apache-2.0",
"hash": 4446061707463732000,
"line_mean": 38.8360655738,
"line_max": 115,
"alpha_frac": 0.5181069959,
"autogenerated": false,
"ratio": 3.6486486486486487,
"config_test": fa... |
# Based on the works of https://github.com/AlessandroZ/LaZagne/blob/master/Windows/lazagne/
import win32crypt
import os, base64
import xml.etree.cElementTree as ET
class Cyberduck():
def __init__(self):
pass
# find the user.config file containing passwords
def get_path(self):
if 'APPDATA'... | {
"repo_name": "mehulj94/BrainDamage",
"path": "Echoes/cyberduck.py",
"copies": "1",
"size": "2274",
"license": "apache-2.0",
"hash": 7530237055559639000,
"line_mean": 31.9565217391,
"line_max": 114,
"alpha_frac": 0.5224274406,
"autogenerated": false,
"ratio": 4.149635036496351,
"config_test": f... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.