text stringlengths 0 1.05M | meta dict |
|---|---|
# based on django.templates.loaders.filesystem
# imports # {{{
from django.conf import settings
from django.template import TemplateDoesNotExist
from django.utils._os import safe_join
from gitology.config import settings as gsettings
# }}}
# get_template_sources # {{{
def get_template_sources(template_name, template_... | {
"repo_name": "amitu/gitology",
"path": "src/gitology/d/themed_template_loader.py",
"copies": "1",
"size": "1402",
"license": "bsd-3-clause",
"hash": -6712394343213671000,
"line_mean": 33.1951219512,
"line_max": 113,
"alpha_frac": 0.6733238231,
"autogenerated": false,
"ratio": 4.017191977077364,
... |
# Based on DT-SLAM article:
# - "DT-SLAM: Deferred Triangulation for Robust SLAM", Herrera, Kim, Kannala, Pulli, Heikkila
# https://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=7035876
#
# code also available, it wasn't used for any reference though:
# - https://github.com/plumonito/dtslam/tree/master/cod... | {
"repo_name": "oknuutti/visnav-py",
"path": "visnav/algo/odometry.py",
"copies": "1",
"size": "50357",
"license": "mit",
"hash": 3576322545995087000,
"line_mean": 44.1144688645,
"line_max": 141,
"alpha_frac": 0.5516015648,
"autogenerated": false,
"ratio": 3.234232498394348,
"config_test": false... |
# Based on example from post "HTTPS Certificate Verification in Python With urllib2" -
# http://www.muchtooscrawled.com/2010/03/https-certificate-verification-in-python-with-urllib2/
import socket
import ssl
import httplib
import urllib2
# Path to a file containing trusted CA certificates
CA_CERTS = '/etc/apache2/key... | {
"repo_name": "meddius/yubisaslauthd",
"path": "yubico/httplib_ssl.py",
"copies": "1",
"size": "2139",
"license": "bsd-3-clause",
"hash": 2245084607634775000,
"line_mean": 32.9523809524,
"line_max": 95,
"alpha_frac": 0.6054230949,
"autogenerated": false,
"ratio": 4.0206766917293235,
"config_tes... |
"""Based on (express-graphql)[https://github.com/graphql/express-graphql/blob/master/src/renderGraphiQL.js] and
(subscriptions-transport-ws)[https://github.com/apollographql/subscriptions-transport-ws]"""
import json
import re
from typing import Any, Dict, Optional, Tuple
from jinja2 import Environment
from typing_ext... | {
"repo_name": "graphql-python/graphql-server-core",
"path": "graphql_server/render_graphiql.py",
"copies": "1",
"size": "11152",
"license": "mit",
"hash": 6973786528638740000,
"line_mean": 32.7878787879,
"line_max": 111,
"alpha_frac": 0.6492376682,
"autogenerated": false,
"ratio": 3.6774406332453... |
# Based on figure 3 of "Bayesian workflow",
# https://arxiv.org/abs/2011.01808
# Code is modified from Osvaldo Martin et al,
# "Bayesian Modeling and Comptuation In Python"
# https://github.com/aloctavodia/BMCP/blob/master/Code/chp_01bis/chp_01bis_prior_posterior_checks.ipynb
# The use of Cauchy priors for logistic ... | {
"repo_name": "probml/pyprobml",
"path": "scripts/logreg_prior.py",
"copies": "1",
"size": "2025",
"license": "mit",
"hash": -5221321613262164000,
"line_mean": 35.8,
"line_max": 103,
"alpha_frac": 0.6337123085,
"autogenerated": false,
"ratio": 2.927641099855282,
"config_test": false,
"has_no_... |
# Based on _FileCache from
# http://python-twitter.googlecode.com/svn/trunk/twitter.py
# Modified to pickle/unpickle data
import md5
import os
import tempfile
import cPickle
class FileCacheError(Exception):
'''Base exception class for FileCache related errors'''
class FileCache(object):
DEPTH = 3
def __ini... | {
"repo_name": "mihaip/mail-trends",
"path": "cache.py",
"copies": "3",
"size": "2824",
"license": "apache-2.0",
"hash": 3471294395905561600,
"line_mean": 29.6956521739,
"line_max": 74,
"alpha_frac": 0.6412889518,
"autogenerated": false,
"ratio": 3.6438709677419356,
"config_test": false,
"has_... |
# Based on Flask-SSLify, but stripped to what is needed
# and fixed to function with an app-factory
from flask import request, redirect, current_app
YEAR_IN_SECS = 31536000
# a list of user agents which HTTPS should not be enforced upon
EXCLUDE_USER_AGENTS = ("kube-probe", "go-http-client")
class SSL(object):
... | {
"repo_name": "getsentry/zeus",
"path": "zeus/utils/ssl.py",
"copies": "1",
"size": "2556",
"license": "apache-2.0",
"hash": 7793424093063170000,
"line_mean": 29.0705882353,
"line_max": 86,
"alpha_frac": 0.5680751174,
"autogenerated": false,
"ratio": 3.8904109589041096,
"config_test": false,
... |
## Based on Frank Liang's hyphenation algorithm
## Adapted from Ned Batchelder's public domain implementation for Python 2
import re
from functools import reduce
def build_break_tree(patterns):
def insert_pattern(tree, pattern):
# Convert the a pattern like 'a1bc3d4' into a string of chars 'abcd'
... | {
"repo_name": "ZetDude/KALEVBOT",
"path": "lib/breakword.py",
"copies": "1",
"size": "35041",
"license": "mit",
"hash": 2474864884680521000,
"line_mean": 67.7078431373,
"line_max": 100,
"alpha_frac": 0.8009474615,
"autogenerated": false,
"ratio": 1.8872731189745247,
"config_test": false,
"has... |
# Based on gearUtils-03.js by Dr A.R.Collins
# Latest version: <www.arc.id.au/gearDrawing.html>
# Calculation of Bezier coefficients for
# Higuchi et al. approximation to an involute.
# ref: YNU Digital Eng Lab Memorandum 05-1
from math import *
from svg import *
def genInvolutePolar(Rb, R): # Rb = base circle rad... | {
"repo_name": "lakeweb/spur-gear-gen",
"path": "project/docs/involute.py",
"copies": "1",
"size": "12841",
"license": "mit",
"hash": 5143943993807406000,
"line_mean": 39.7650793651,
"line_max": 102,
"alpha_frac": 0.5624172572,
"autogenerated": false,
"ratio": 3.053745541022592,
"config_test": f... |
# Based on get_access_token.py from python-twitter
import sys
import urllib
# parse_qsl moved to urlparse module in v2.6
try:
from urlparse import parse_qsl
except:
from cgi import parse_qsl
import oauth2 as oauth
from oauth_keys import SERVICE_PROVIDERS
if len(sys.argv) != 2:
print 'Usage: python get_oauth... | {
"repo_name": "mihaip/streamspigot",
"path": "app/datasources/get_oauth_access_token.py",
"copies": "1",
"size": "2064",
"license": "apache-2.0",
"hash": -973034661237572700,
"line_mean": 29.3529411765,
"line_max": 95,
"alpha_frac": 0.6831395349,
"autogenerated": false,
"ratio": 3.46890756302521,... |
# based on github.com/fusionbox/django-betterforms/betterforms/multiform.py
from collections import OrderedDict
from functools import reduce
from itertools import chain
from operator import add
from django.core.exceptions import NON_FIELD_ERRORS, ValidationError
from django.forms.utils import ErrorList
from django.ut... | {
"repo_name": "sanoma/django-arctic",
"path": "arctic/multiform.py",
"copies": "1",
"size": "6484",
"license": "mit",
"hash": -8819551285397727000,
"line_mean": 31.42,
"line_max": 79,
"alpha_frac": 0.5980876002,
"autogenerated": false,
"ratio": 4.0398753894081,
"config_test": false,
"has_no_k... |
# Based on github.com/lambci/docker-lambda/python2.7/run/runtime-mock.py version cf93693
from __future__ import print_function
import sys
import os
import random
import uuid
import time
import resource
import datetime
import json
# hijack stdout so it won't be taken by mistake
orig_stdout = os.fdopen(os.dup(1),"w")
os... | {
"repo_name": "minutelab/mless",
"path": "mlessd/runtime/runtimes/python/runtime-mock.py",
"copies": "1",
"size": "6229",
"license": "mit",
"hash": 3495826178874858000,
"line_mean": 26.5619469027,
"line_max": 127,
"alpha_frac": 0.5951196019,
"autogenerated": false,
"ratio": 3.396401308615049,
"... |
# Based on Guido's sample in https://www.artima.com/weblogs/viewpost.jsp?thread=101605
# with some small tweaks, and ported to Python 3.
#
# Tested with Python 3.4
#
# Eli Bendersky [http://eli.thegreenplace.net]
# This code is in the public domain.
#
# This part is the multimethod "library".
#
class _MultiMethod:
... | {
"repo_name": "eliben/code-for-blog",
"path": "2016/multiple-dispatch/python/multi.py",
"copies": "1",
"size": "2094",
"license": "unlicense",
"hash": 4109236431093127700,
"line_mean": 24.5365853659,
"line_max": 86,
"alpha_frac": 0.6318051576,
"autogenerated": false,
"ratio": 3.276995305164319,
... |
# Based on HD-CNN: HIERARCHICAL DEEP CONVOLUTIONAL
# NEURAL NETWORK FOR IMAGE CLASSIFICATION
# by Yan. Jagadeesh, DeCoste, Di, Piramuthu
# http://arxiv.org/pdf/1410.0736v3.pdf
from collections import defaultdict
from itertools import takewhile
from pprint import pprint
from sklearn.preprocessing import LabelEncoder
fr... | {
"repo_name": "JasonTam/ndsb2015",
"path": "tools/specialism.py",
"copies": "1",
"size": "1914",
"license": "mit",
"hash": -6773589920856918000,
"line_mean": 26.7391304348,
"line_max": 83,
"alpha_frac": 0.7042842215,
"autogenerated": false,
"ratio": 2.680672268907563,
"config_test": false,
"h... |
# based on http://anthony-tresontani.github.io/Django/2012/09/20/multilingual-search/
from django.conf import settings
from django.utils import translation
from haystack import connections
from haystack.backends import BaseEngine, BaseSearchBackend, BaseSearchQuery
from haystack.backends.simple_backend import SimpleEng... | {
"repo_name": "City-of-Helsinki/linkedevents",
"path": "multilingual_haystack/backends.py",
"copies": "1",
"size": "3251",
"license": "mit",
"hash": 5708407085298111000,
"line_mean": 32.1734693878,
"line_max": 85,
"alpha_frac": 0.672100892,
"autogenerated": false,
"ratio": 4.288918205804749,
"c... |
# based on http://anthony-tresontani.github.io/Django/2012/09/20/multilingual-search/
import re
from django.conf import settings
from django.utils import translation
from haystack import connections
from haystack.backends import BaseEngine, BaseSearchBackend, BaseSearchQuery
from haystack.constants import DEFAULT_ALIAS... | {
"repo_name": "kooditiimi/linkedevents",
"path": "multilingual_haystack/backends.py",
"copies": "1",
"size": "2317",
"license": "bsd-3-clause",
"hash": -5383181212059854000,
"line_mean": 35.7777777778,
"line_max": 85,
"alpha_frac": 0.678895123,
"autogenerated": false,
"ratio": 4.251376146788991,
... |
# Based on http://appengine-cookbook.appspot.com/recipe/extended-jsonify-function-for-dbmodel,
# with modifications for flask and performance.
# use json in Python 2.7, fallback to simplejson for Python 2.5
try:
import json
except ImportError:
import simplejson as json
from google.appengine.ext import db
from... | {
"repo_name": "kamens/gae_bingo",
"path": "jsonify.py",
"copies": "1",
"size": "4493",
"license": "mit",
"hash": -8032221944299868000,
"line_mean": 30.4195804196,
"line_max": 94,
"alpha_frac": 0.6056087247,
"autogenerated": false,
"ratio": 4.287213740458015,
"config_test": false,
"has_no_keyw... |
# based on http://badhessian.org/2012/10/collecting-real-time-twitter-data-with-the-streaming-api/
# with modifications by http://github.com/marciw
# requires Tweepy https://github.com/tweepy/tweepy
from tweepy import StreamListener
import json, time, sys
class TWaiter(StreamListener):
# see Tweepy for more info... | {
"repo_name": "marciw/sentiment",
"path": "twaiter.py",
"copies": "1",
"size": "1922",
"license": "apache-2.0",
"hash": 8038375003748119000,
"line_mean": 35.2641509434,
"line_max": 98,
"alpha_frac": 0.5858480749,
"autogenerated": false,
"ratio": 3.5461254612546127,
"config_test": false,
"has_... |
# Based on http://bpbio.googlecode.com/svn/trunk/interval_tree/interval_tree.py
class IntervalTree(object):
def __init__(self, intervals, depth=16, minbucket=64, _extent=None, maxbucket=512):
"""\
`intervals` a list of intervals *with start and stop* attributes. Assumed
to be sorted.
`depth` ... | {
"repo_name": "mihaip/intersquares",
"path": "app/base/interval_tree.py",
"copies": "1",
"size": "2278",
"license": "apache-2.0",
"hash": 2656723196153584000,
"line_mean": 33,
"line_max": 106,
"alpha_frac": 0.6299385426,
"autogenerated": false,
"ratio": 3.784053156146179,
"config_test": false,
... |
# Based on http://cocoawithlove.com/2010/09/minimalist-cocoa-programming.html
# by Juraj Sukop. This demo was eventually expanded into a more complete
# Cocoa library available at https://bitbucket.org/sukop/nspython .
from cffi import FFI
ffi = FFI()
ffi.cdef('''
typedef signed char BOOL;
typedef ... | {
"repo_name": "jayceyxc/hue",
"path": "desktop/core/ext-py/cffi-1.5.2/demo/cffi-cocoa.py",
"copies": "13",
"size": "3354",
"license": "apache-2.0",
"hash": 5912436829445234000,
"line_mean": 31.8823529412,
"line_max": 84,
"alpha_frac": 0.6794871795,
"autogenerated": false,
"ratio": 3.3011811023622... |
# Based on http://cocoawithlove.com/2010/09/minimalist-cocoa-programming.html
# by Juraj Sukop. This demo was eventually expanded into a more complete
# Cocoa library available at https://bitbucket.org/sukop/nspython .
from cffi import FFI
ffi = FFI()
ffi.cdef('''
typedef signed char BOOL;
... | {
"repo_name": "hipnusleo/laserjet",
"path": "resource/pypi/cffi-1.9.1/demo/cffi-cocoa.py",
"copies": "1",
"size": "3456",
"license": "apache-2.0",
"hash": 3236834138044096500,
"line_mean": 31.8823529412,
"line_max": 84,
"alpha_frac": 0.6594328704,
"autogenerated": false,
"ratio": 3.31669865642994... |
# Based on http://code.activestate.com/recipes/576362-list-system-process-and-process-information-on-win/
# License: MIT
from ctypes import c_long, c_int, c_uint, c_char, c_void_p
from ctypes import windll
from ctypes import Structure
from ctypes import sizeof, POINTER, pointer
# Constants
TH32CS_SNAPPROCESS = 2
# St... | {
"repo_name": "ActiveState/code",
"path": "recipes/Python/578133_Get_parent_process_pid_win32/recipe-578133.py",
"copies": "1",
"size": "2013",
"license": "mit",
"hash": 7149950788014434000,
"line_mean": 29.5,
"line_max": 105,
"alpha_frac": 0.7178340785,
"autogenerated": false,
"ratio": 2.8232819... |
# Based on http://code.activestate.com/recipes/577722-xml-to-python-dictionary-and-back/
# Create python xml structures compatible with
# http://search.cpan.org/~grantm/XML-Simple-2.18/lib/XML/Simple.pm
from lxml import etree
from itertools import groupby
def xml2d(e):
"""Convert an etree into a dict structure
... | {
"repo_name": "iDigBio/idb-spark",
"path": "lib/xmlDictTools.py",
"copies": "1",
"size": "3334",
"license": "mit",
"hash": -1930021166022505700,
"line_mean": 28.7678571429,
"line_max": 89,
"alpha_frac": 0.4766046791,
"autogenerated": false,
"ratio": 3.52431289640592,
"config_test": false,
"ha... |
# based on http://cs229.stanford.edu/proj2013/JimenezNguyen_MathFormulas_final_paper.pdf
# http://www.cs.cmu.edu/~guestrin/Class/10701/projects.html#image is the dataset
import sys
sys.path.append('/usr/local/lib/python2.7/site-packages/') # not necessary for all computers, depending on how OpenCV was installed
impor... | {
"repo_name": "nityas/6869-finalproject",
"path": "hog/preprocess.py",
"copies": "1",
"size": "1887",
"license": "mit",
"hash": 8026679869041333000,
"line_mean": 34.6037735849,
"line_max": 141,
"alpha_frac": 0.5903550609,
"autogenerated": false,
"ratio": 2.699570815450644,
"config_test": false,... |
# Based on: http://ginstrom.com/scribbles/2007/09/04/pretty-printing-a-table-in-python/
def format_num(num):
'''
Format a number according to given places.
Adds commas, etc. Will truncate floats into ints!
'''
try:
inum = int(num)
# return locale.format("%.*f", (0, inum), True)
... | {
"repo_name": "zhouhoo/conceptNet_55_client",
"path": "tools/pprint.py",
"copies": "1",
"size": "1336",
"license": "apache-2.0",
"hash": 7063611389517063000,
"line_mean": 25.1960784314,
"line_max": 87,
"alpha_frac": 0.5793413174,
"autogenerated": false,
"ratio": 3.443298969072165,
"config_test"... |
# Based on http://henritersteeg.wordpress.com/2009/03/30/generic-db-caching-in-google-app-engine
import logging
import weakref
# AppEngine imports
from google.appengine.ext import db
from google.appengine.api import datastore
# define a global, weakly referenced CACHE...
_cache = weakref.WeakValueDictiona... | {
"repo_name": "avastjohn/maventy_new",
"path": "db_cache.py",
"copies": "1",
"size": "1780",
"license": "bsd-3-clause",
"hash": -60070050211711896,
"line_mean": 32.9019607843,
"line_max": 97,
"alpha_frac": 0.6685393258,
"autogenerated": false,
"ratio": 3.5247524752475248,
"config_test": false,
... |
# Based on: http://isadoranun.github.io/tsfeat/FeaturesDocumentation.html
# JSAnimation import available at https://github.com/jakevdp/JSAnimation
import warnings
import numpy as np
import jinja2
from matplotlib import pyplot as plt
from matplotlib import animation
from JSAnimation import IPython_display
from IP... | {
"repo_name": "carpyncho/feets",
"path": "doc/source/tutorial.py",
"copies": "1",
"size": "7886",
"license": "mit",
"hash": -3166050397669662000,
"line_mean": 28.758490566,
"line_max": 208,
"alpha_frac": 0.5628962719,
"autogenerated": false,
"ratio": 3.4496937882764653,
"config_test": false,
... |
# Based on http://martyalchin.com/2008/jan/10/simple-plugin-framework/
from django.core.urlresolvers import reverse
class PluginMount(type):
def __init__(cls, name, bases, attrs):
if not hasattr(cls, 'plugins'):
# This branch only executes when processing the mount point itself.
# S... | {
"repo_name": "WoLpH/django-sentry",
"path": "sentry/plugins/__init__.py",
"copies": "2",
"size": "2928",
"license": "bsd-3-clause",
"hash": 4013227085019273000,
"line_mean": 32.6551724138,
"line_max": 97,
"alpha_frac": 0.5894808743,
"autogenerated": false,
"ratio": 4.575,
"config_test": false,... |
# based on http://moose.readthedocs.io/en/latest/user/py/quickstart/index.html
import moose
import numpy as np
import matplotlib.pyplot as plt
# model objects
model = moose.Neutral('/model') # create an umbrella path for all further moose objects
soma = moose.Compartment('/model/soma') # an equipotential compartment
... | {
"repo_name": "h-mayorquin/camp_india_2016",
"path": "tutorials/chemical switches/moose/passive_inject.py",
"copies": "1",
"size": "1030",
"license": "mit",
"hash": -857645839752314400,
"line_mean": 29.2941176471,
"line_max": 87,
"alpha_frac": 0.740776699,
"autogenerated": false,
"ratio": 2.88515... |
"""Based on http://msdn.microsoft.com/en-gb/library/windows/desktop/dd375731(v=vs.85).aspx"""
keycodes = {'LBUTTON': 0x01, # Left mouse button
'RBUTTON': 0x02, # Right mouse button
'CANCEL': 0x03, # Control-break processing
'MBUTTON': 0x04, # Middle mouse button (three-button mo... | {
"repo_name": "sisalik/automate",
"path": "automate/keycodes.py",
"copies": "1",
"size": "8448",
"license": "mit",
"hash": 579011065377839000,
"line_mean": 43.4631578947,
"line_max": 108,
"alpha_frac": 0.4720643939,
"autogenerated": false,
"ratio": 2.991501416430595,
"config_test": false,
"ha... |
# based on http://protips.readthedocs.io/link-roles.html
from docutils import nodes
from repo_util import run_cmd_get_output
def get_github_rev():
path = run_cmd_get_output('git rev-parse --short HEAD')
tag = run_cmd_get_output('git describe --exact-match')
print 'Git commit ID: ', path
if len(tag):
... | {
"repo_name": "dantonets/Pingzee-ESP32",
"path": "docs/link-roles.py",
"copies": "12",
"size": "1488",
"license": "apache-2.0",
"hash": -4913884475169299000,
"line_mean": 42.7647058824,
"line_max": 93,
"alpha_frac": 0.6317204301,
"autogenerated": false,
"ratio": 3.241830065359477,
"config_test"... |
# based on http://protips.readthedocs.io/link-roles.html
from __future__ import print_function
from __future__ import unicode_literals
import re
import os
from docutils import nodes
from local_util import run_cmd_get_output
def get_github_rev():
path = run_cmd_get_output('git rev-parse --short HEAD')
tag = ru... | {
"repo_name": "espressif/ESP8266_RTOS_SDK",
"path": "docs/link-roles.py",
"copies": "1",
"size": "2930",
"license": "apache-2.0",
"hash": 4360329425350998000,
"line_mean": 40.8571428571,
"line_max": 93,
"alpha_frac": 0.6163822526,
"autogenerated": false,
"ratio": 3.447058823529412,
"config_test... |
# based on http://protips.readthedocs.io/link-roles.html
import re
from docutils import nodes
from repo_util import run_cmd_get_output
def get_github_rev():
path = run_cmd_get_output('git rev-parse --short HEAD')
tag = run_cmd_get_output('git describe --exact-match')
print ('Git commit ID: ', path)
if... | {
"repo_name": "Hermiedapwdrman/esp-idf",
"path": "docs/link-roles.py",
"copies": "1",
"size": "1698",
"license": "apache-2.0",
"hash": 4461137346813523000,
"line_mean": 39.4285714286,
"line_max": 93,
"alpha_frac": 0.6001177856,
"autogenerated": false,
"ratio": 3.2653846153846153,
"config_test":... |
# based on http://reminiscential.wordpress.com/2012/04/07/realtime-notification-delivery-using-rabbitmq-tornado-and-websocket/
import json
import logging
import os
import socket
import autonetkit.config as config
import pkg_resources
import tornado
import tornado.websocket as websocket
# based on http://tornadogists... | {
"repo_name": "sysbot/autonetkit",
"path": "autonetkit/webserver.py",
"copies": "1",
"size": "16194",
"license": "bsd-3-clause",
"hash": -589094457112513200,
"line_mean": 35.5553047404,
"line_max": 126,
"alpha_frac": 0.5996047919,
"autogenerated": false,
"ratio": 3.9296287308905606,
"config_tes... |
# Based on: https://articles.leetcode.com/longest-palindromic-substring-part-ii/
def _process(s):
alt_chars = ['$', '#']
for char in s:
alt_chars.extend([char, '#'])
alt_chars += ['@']
return alt_chars
def _run_manacher(alt_chars):
palin_table = [0] * len(alt_chars)
center, right... | {
"repo_name": "sshh12/SchoolCode",
"path": "Algorithms/Misc/ManacherPalindrome.py",
"copies": "1",
"size": "1169",
"license": "mit",
"hash": -6369897518031042000,
"line_mean": 20.6481481481,
"line_max": 89,
"alpha_frac": 0.5534644996,
"autogenerated": false,
"ratio": 2.915211970074813,
"config_... |
# Based on: https://chase-seibert.github.io/blog/2014/03/21/python-multilevel-argparse.html
# Attempt at parsing the CLI commands, but became overly complex for a simple wrapper
import argparse
import inspect
import sys
from typing import Callable, List, Tuple
def get_members(cls, prefix: str = 'do_') -> List[Tuple[... | {
"repo_name": "KyleKing/My-Programming-Sketchbook",
"path": "Assorted_Snippets/python/cli_prototyping/multi-level-arg_parse-proto.py",
"copies": "1",
"size": "2295",
"license": "mit",
"hash": -6138742107459833000,
"line_mean": 36.0161290323,
"line_max": 91,
"alpha_frac": 0.6326797386,
"autogenerate... |
# based on http://scripts.irssi.org/scripts/bitlbee_tab_completion.pl
import weechat
SCRIPT_NAME = "bitlbee_completion"
SCRIPT_AUTHOR = "Roger Duran <rogerduran@gmail.com>"
SCRIPT_VERSION = "0.1"
SCRIPT_LICENSE = "GPL3"
SCRIPT_DESC = "Add tab completion to bitlbee commands"
OPTS = {
"server": None,
"channel"... | {
"repo_name": "esoterick/Dotfiles",
"path": "weechat/python/bitlbee_completion.py",
"copies": "1",
"size": "2959",
"license": "mit",
"hash": 5718022218868663000,
"line_mean": 27.180952381,
"line_max": 79,
"alpha_frac": 0.6137208516,
"autogenerated": false,
"ratio": 3.5310262529832936,
"config_t... |
# Based on https://djangosnippets.org/snippets/2283/
from django.db import transaction
from django.db.models import get_models, Model
from django.contrib.contenttypes.generic import GenericForeignKey
@transaction.atomic
def merge_model_objects(primary_object, alias_objects=None, keep_old=False):
"""
Use this ... | {
"repo_name": "YPCrumble/django-merge-model-instances",
"path": "merge_model_instances/test2.py",
"copies": "1",
"size": "5025",
"license": "mit",
"hash": 6426042971052727000,
"line_mean": 47.786407767,
"line_max": 148,
"alpha_frac": 0.6501492537,
"autogenerated": false,
"ratio": 4.28754266211604... |
# Based on https://djangosnippets.org/snippets/98/
import re
from django.db import models
class SlugNotCorrectlyPrePopulated(Exception):
pass
def _string_to_slug(s):
raw_data = s
# normalze string as proposed on:
# http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/251871
# by Aaron Bentle... | {
"repo_name": "simonv3/django-reading-list",
"path": "readers/utils/slugify.py",
"copies": "1",
"size": "3855",
"license": "mit",
"hash": 4408681498710529500,
"line_mean": 34.3669724771,
"line_max": 78,
"alpha_frac": 0.5234760052,
"autogenerated": false,
"ratio": 4.028213166144201,
"config_test... |
# Based on: https://fadeit.dk/blog/2015/10/12/mailgun-python-log-handler/
import os
import logging
import requests
class MailgunHandler(logging.Handler):
def __init__(self, api_url, api_key, sender, recipients, subject_prefix):
# run the regular Handler __init__
logging.Handler.__init__(self)
... | {
"repo_name": "mytardis/mytardis_ngs_ingestor",
"path": "mytardis_ngs_ingestor/utils/mailgun_handler.py",
"copies": "1",
"size": "1226",
"license": "bsd-3-clause",
"hash": -3897463332269532000,
"line_mean": 33.0555555556,
"line_max": 78,
"alpha_frac": 0.5522022838,
"autogenerated": false,
"ratio"... |
# Based on https://gist.github.com/1138554
#
# See http://tidy.sourceforge.net/docs/quickref.html for tidy options
import sublime, sublime_plugin, subprocess, re
class TidyHtmlCommand(sublime_plugin.TextCommand):
def run(self, edit):
command = 'tidy --indent auto -utf8 -w -q --tidy-mark no --indent-spaces 4 --s... | {
"repo_name": "akrabat/sublime-akrabat",
"path": "tidy_html.py.old.py",
"copies": "1",
"size": "1398",
"license": "mit",
"hash": 7268019764644608000,
"line_mean": 42.6875,
"line_max": 139,
"alpha_frac": 0.6874105866,
"autogenerated": false,
"ratio": 3.1066666666666665,
"config_test": false,
"... |
# Based on: https://gist.github.com/kch42/565419
from random import randrange as rand
from bibliopixel.colors import COLORS
from bibliopixel.colors.conversions import hue_helper
from bibliopixel.animation.game import Game
# The configuration
cols = 19
rows = 40
maxfps = 30
color_map = [
COLORS.Black,
COLORS... | {
"repo_name": "ManiacalLabs/BiblioPixelAnimations",
"path": "BiblioPixelAnimations/game/Tetris.py",
"copies": "2",
"size": "12321",
"license": "mit",
"hash": 8571790349768793000,
"line_mean": 32.3902439024,
"line_max": 142,
"alpha_frac": 0.4788572356,
"autogenerated": false,
"ratio": 3.6355857185... |
# Based on https://gist.github.com/michaelaye/702fff89930de42822d26e14fb182160
import csv
import os
import requests
from planetpy import pdstools as pds
def download_file(url, path):
with open(path, 'wb') as out_f:
response = requests.get(url, stream=True)
response.raise_for_status()
for ... | {
"repo_name": "zooniverse/MarsZoo",
"path": "data-import/fetch_metadata.py",
"copies": "1",
"size": "2049",
"license": "apache-2.0",
"hash": 1577266280216176400,
"line_mean": 33.15,
"line_max": 78,
"alpha_frac": 0.6700829673,
"autogenerated": false,
"ratio": 2.8859154929577464,
"config_test": f... |
# Based on: https://gist.github.com/snim2/255151
import pygame
import pygame.camera
from pygame.locals import *
import zbarlight
from PIL import Image
from urllib.parse import urlparse, parse_qs
from query import Query
from datetime import datetime
def scan_code(device, size):
pygame.init()
pygame.camera.init... | {
"repo_name": "vodka-bears/budget-fns",
"path": "budget/scan.py",
"copies": "1",
"size": "1552",
"license": "apache-2.0",
"hash": 2642809502374833000,
"line_mean": 28.3018867925,
"line_max": 61,
"alpha_frac": 0.612757732,
"autogenerated": false,
"ratio": 3.396061269146608,
"config_test": false,... |
# Based on https://github.com/adbar/trafilatura/blob/master/trafilatura/utils.py
import logging
import cchardet # For unknown encoding, see https://charset-normalizer.readthedocs.io/en/latest/ for more info
LOGGER = logging.getLogger(__name__)
def isutf8(data):
"""Simple heuristic to determine if a bytestring ... | {
"repo_name": "fhamborg/news-please",
"path": "newsplease/crawler/response_decoder.py",
"copies": "1",
"size": "1612",
"license": "apache-2.0",
"hash": 4068778500353122300,
"line_mean": 32.5833333333,
"line_max": 111,
"alpha_frac": 0.6718362283,
"autogenerated": false,
"ratio": 4.070707070707071,... |
#based on https://github.com/anlutro/botologist
import datetime
import dateutil.parser
import requests
import pytz
import sopel
def get_next_episode_info(show, output_timezone=pytz.timezone('UTC')):
query = {'q': show, 'embed': 'nextepisode'}
try:
response = requests.get('http://api.tvmaze.com/singlesear... | {
"repo_name": "ridelore/willie-modules",
"path": "tvmaze.py",
"copies": "2",
"size": "1962",
"license": "apache-2.0",
"hash": 7994666795732371000,
"line_mean": 28.6875,
"line_max": 80,
"alpha_frac": 0.6386340469,
"autogenerated": false,
"ratio": 2.928358208955224,
"config_test": false,
"has_n... |
# Based on: https://github.com/digitick/php-sepa-xml
# This app will take information for several payments and create a SEPA xml file for internet banking.
# It takes specifics for Rabobank (The Netherlands)
# https://www.rabobank.com/en/images/SEPA%20Credit%20Transfer%20format%20description%20v1.0.pdf
from decimal im... | {
"repo_name": "gannetson/sportschooldeopenlucht",
"path": "apps/sepa/sepa.py",
"copies": "1",
"size": "9674",
"license": "bsd-3-clause",
"hash": 3850262379499806000,
"line_mean": 31.793220339,
"line_max": 109,
"alpha_frac": 0.6135001034,
"autogenerated": false,
"ratio": 3.575018477457502,
"conf... |
## based on https://github.com/dmlc/mxnet/issues/1302
## Parses the model fit log file and generates a train/val vs epoch plot
import matplotlib.pyplot as plt
import numpy as np
import re
import argparse
parser = argparse.ArgumentParser(description='Parses log file and generates train/val curves')
parser.add_argument(... | {
"repo_name": "arank/mxnet",
"path": "example/kaggle-ndsb1/training_curves.py",
"copies": "15",
"size": "1093",
"license": "apache-2.0",
"hash": -5646274212154812000,
"line_mean": 29.3611111111,
"line_max": 94,
"alpha_frac": 0.6605672461,
"autogenerated": false,
"ratio": 2.9069148936170213,
"co... |
# Based on https://github.com/FontCustom/fontcustom/blob/master/lib/fontcustom/scripts/generate.py
import fontforge
import os
import sys
import hashlib
import json
from subprocess import call
from distutils.spawn import find_executable
args = json.load(sys.stdin)
f = fontforge.font()
f.encoding = 'UnicodeFull'
f.des... | {
"repo_name": "jnaO/grunt-webfont",
"path": "tasks/engines/fontforge/generate.py",
"copies": "1",
"size": "3396",
"license": "mit",
"hash": 4082030164382792000,
"line_mean": 25.53125,
"line_max": 199,
"alpha_frac": 0.6666666667,
"autogenerated": false,
"ratio": 2.8658227848101268,
"config_test"... |
# Based on https://github.com/FontCustom/fontcustom/blob/master/lib/fontcustom/scripts/generate.py
import fontforge
import os
import sys
import json
from subprocess import call
from distutils.spawn import find_executable
args = json.load(sys.stdin)
f = fontforge.font()
f.encoding = 'UnicodeFull'
f.copyright = ''
f.d... | {
"repo_name": "georgieff/grunt-webfont2",
"path": "tasks/engines/fontforge/generate.py",
"copies": "9",
"size": "3536",
"license": "mit",
"hash": 4232616336709139000,
"line_mean": 27.288,
"line_max": 175,
"alpha_frac": 0.6736425339,
"autogenerated": false,
"ratio": 2.915086562242374,
"config_te... |
# Based on https://github.com/FontCustom/fontcustom/blob/master/lib/fontcustom/scripts/generate.py
import fontforge
import os
import sys
import json
import re
from subprocess import call
from distutils.spawn import find_executable
args = json.load(sys.stdin)
f = fontforge.font()
f.encoding = 'UnicodeFull'
f.copyrigh... | {
"repo_name": "sapegin/grunt-webfont",
"path": "tasks/engines/fontforge/generate.py",
"copies": "1",
"size": "3828",
"license": "mit",
"hash": -7794817171871094000,
"line_mean": 27.7819548872,
"line_max": 175,
"alpha_frac": 0.6630094044,
"autogenerated": false,
"ratio": 2.9,
"config_test": fals... |
# Based on https://github.com/Garve/Evolutionary-Algorithm
from abc import ABC, abstractmethod
class Individual(ABC):
def __init__(self, value: dict = None, init_params: dict = None):
if value is not None:
self.value = value
else:
self.value = self._random_init(init_params)... | {
"repo_name": "donkirkby/domiculture",
"path": "evo.py",
"copies": "2",
"size": "3603",
"license": "mit",
"hash": 7433538278695530000,
"line_mean": 30.3304347826,
"line_max": 91,
"alpha_frac": 0.5614765473,
"autogenerated": false,
"ratio": 3.820784729586426,
"config_test": false,
"has_no_keyw... |
# Based on https://github.com/ikostrikov/pytorch-a3c
import torch
import torch.nn as nn
import torch.nn.functional as F
import numpy as np
def normalized_columns_initializer(weights, std=1.0):
# pylint: disable=E1101
out = torch.randn(weights.size())
out *= std / torch.sqrt(out.pow(2).sum(1).expand_as(out)... | {
"repo_name": "ibrica/universe-server",
"path": "models/A3C.py",
"copies": "1",
"size": "2455",
"license": "mit",
"hash": -5929357097716389000,
"line_mean": 33.0972222222,
"line_max": 72,
"alpha_frac": 0.5898167006,
"autogenerated": false,
"ratio": 2.9156769596199523,
"config_test": false,
"h... |
# Based on https://github.com/ikostrikov/pytorch-a3c
import torch
import torch.nn as nn
import torch.nn.functional as F
class ES(torch.nn.Module):
def __init__(self, num_inputs, action_space):
"""
Initialize network
"""
super(ES, self).__init__()
num_outputs = action_space.... | {
"repo_name": "ibrica/universe-server",
"path": "models/ES.py",
"copies": "1",
"size": "1457",
"license": "mit",
"hash": 1611859656768026000,
"line_mean": 30.0212765957,
"line_max": 70,
"alpha_frac": 0.540837337,
"autogenerated": false,
"ratio": 3.146868250539957,
"config_test": false,
"has_n... |
# based on https://github.com/keon/deep-q-learning/blob/master/dqn.py
from collections import deque
import numpy as np
import random
import torch
from torch import nn
from torch.autograd import Variable
import torch.nn.functional as F
from torch import optim
class DQNNetwork(nn.Module):
def __init__(self, actions_... | {
"repo_name": "arminnh/csai-deep-reinforcement-learning",
"path": "src/universe-driving/TORCH_DQN.py",
"copies": "1",
"size": "4812",
"license": "mit",
"hash": 897510889829958100,
"line_mean": 34.3823529412,
"line_max": 105,
"alpha_frac": 0.5789692436,
"autogenerated": false,
"ratio": 3.591044776... |
# Based on https://github.com/LumaPictures/pflow/blob/master/pflow/packet.py
class InformationPacket(object):
def __init__(self, value, owner=None):
self._value = value
self._owner = owner
def drop(self):
del self
def __str__(self):
return "{} owned by {}, payload {}, pa... | {
"repo_name": "baffelli/pyperator",
"path": "pyperator/IP.py",
"copies": "1",
"size": "1849",
"license": "mit",
"hash": -2431367793118007000,
"line_mean": 21.8271604938,
"line_max": 126,
"alpha_frac": 0.6068144943,
"autogenerated": false,
"ratio": 3.9935205183585314,
"config_test": false,
"ha... |
# based on https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/backends/backend_template.py
import types
from matplotlib._pylab_helpers import Gcf
from matplotlib.figure import Figure
from matplotlib.backend_bases import (
FigureCanvasBase, FigureManagerBase, GraphicsContextBase, RendererBase)
f... | {
"repo_name": "wookayin/python-imgcat",
"path": "imgcat/mpl_backend.py",
"copies": "1",
"size": "1253",
"license": "mit",
"hash": -6632752605175870000,
"line_mean": 27.4772727273,
"line_max": 107,
"alpha_frac": 0.744612929,
"autogenerated": false,
"ratio": 3.867283950617284,
"config_test": fals... |
# based on https://github.com/mpatacchiola/deepgaze/blob/master/examples/ex_dlib_pnp_head_pose_estimation_video.py
import numpy
import cv2
import dlib
# Antropometric constant values of the human head.
# Found on wikipedia and on:
# "Head-and-Face Anthropometric Survey of U.S. Respirator Users"
#
# X-Y-Z with X point... | {
"repo_name": "hudvin/brighteye",
"path": "tmp/head_pose.py",
"copies": "1",
"size": "6136",
"license": "apache-2.0",
"hash": 1005635643654015700,
"line_mean": 32.1675675676,
"line_max": 114,
"alpha_frac": 0.6041395046,
"autogenerated": false,
"ratio": 2.6188647033717456,
"config_test": false,
... |
# based on https://github.com/Newmu/Theano-Tutorials/blob/master/5_convolutional_net.py
import theano
from theano import tensor as T
from theano.sandbox.rng_mrg import MRG_RandomStreams as RandomStreams
import numpy as np
from load import mnist, nomnist
from theano.tensor.nnet.conv import conv2d
from theano.tensor.sign... | {
"repo_name": "laputian/dml",
"path": "newmu/convolutional_nomnist.py",
"copies": "1",
"size": "5190",
"license": "mit",
"hash": 5721229251772604000,
"line_mean": 32.4903225806,
"line_max": 108,
"alpha_frac": 0.6306358382,
"autogenerated": false,
"ratio": 2.649310872894334,
"config_test": true,... |
# Based on https://github.com/petkaantonov/bluebird/blob/master/src/promise.js
from collections import deque
from threading import local
if False:
from .promise import Promise
from typing import Any, Callable, Optional, Union # flake8: noqa
class Async(local):
def __init__(self, trampoline_enabled=True)... | {
"repo_name": "syrusakbary/pypromise",
"path": "promise/async_.py",
"copies": "2",
"size": "3959",
"license": "mit",
"hash": 6870829507062015000,
"line_mean": 28.3259259259,
"line_max": 78,
"alpha_frac": 0.5738822935,
"autogenerated": false,
"ratio": 3.8214285714285716,
"config_test": false,
... |
# Based on https://github.com/probml/pmtk3/blob/master/demos/bayesChangeOfVar.m
# MC on change of variables and empirical distribution, highlighting that
# modes are not, in general, preserved.
import numpy as np
import matplotlib.pyplot as plt
from scipy.stats import norm
import os
from pyprobml_utils import save_fig... | {
"repo_name": "probml/pyprobml",
"path": "scripts/bayes_change_of_var.py",
"copies": "1",
"size": "1637",
"license": "mit",
"hash": -4023179860912371700,
"line_mean": 34.5869565217,
"line_max": 103,
"alpha_frac": 0.7031154551,
"autogenerated": false,
"ratio": 2.742043551088777,
"config_test": f... |
# Based on https://github.com/probml/pmtk3/blob/master/demos/gaussSeqUpdateSigma1D.m
# Converted by John Fearns - jdf22@infradead.org
# Sequential updating of Sigma in 1d given fixed mean
import numpy as np
import matplotlib.pyplot as plt
from scipy.stats import norm
from scipy.stats import invgamma
from pypro... | {
"repo_name": "probml/pyprobml",
"path": "scripts/gauss_seq_update_sigma_1d.py",
"copies": "1",
"size": "2340",
"license": "mit",
"hash": -7586740352285629000,
"line_mean": 36.3606557377,
"line_max": 92,
"alpha_frac": 0.6952991453,
"autogenerated": false,
"ratio": 3.2409972299168976,
"config_te... |
# Based on https://github.com/probml/pmtk3/blob/master/demos/healthyLevels.m
# Converted by John Fearns - jdf22@infradead.org
# Josh Tenenbaum's Healthy Levels game
import numpy as np
import matplotlib.pyplot as plt
#from pyprobml_utils import save_fig
# Ensure stochastic reproducibility.
np.random.seed(11)
... | {
"repo_name": "probml/pyprobml",
"path": "scripts/healthy_levels_plot.py",
"copies": "1",
"size": "8209",
"license": "mit",
"hash": 2699570629924179000,
"line_mean": 37.4663461538,
"line_max": 124,
"alpha_frac": 0.6047021562,
"autogenerated": false,
"ratio": 3.0768365817091454,
"config_test": f... |
# Based on https://github.com/probml/pmtk3/blob/master/demos/NIXdemo2.m
# Converted by John Fearns - jdf22@infradead.org
# Compare some Normal Inverse Chi Squared Distributions
import numpy as np
import matplotlib.pyplot as plt
from scipy.stats import norm
from scipy.stats import invgamma
from mpl_toolkits.mpl... | {
"repo_name": "probml/pyprobml",
"path": "scripts/nix_plots.py",
"copies": "1",
"size": "2318",
"license": "mit",
"hash": 6761986876344721000,
"line_mean": 36,
"line_max": 120,
"alpha_frac": 0.6436583261,
"autogenerated": false,
"ratio": 2.7995169082125604,
"config_test": false,
"has_no_keywo... |
# Based on https://github.com/probml/pmtk3/blob/master/demos/numbersGame.m
# Rewritten by John Fearns - jdf22@infradead.org
# A smaller version of Josh Tenenbaum's Number Game
import numpy as np
import matplotlib.pyplot as plt
import math
import scipy.stats as stats
#from pyprobml_utils import save_fig
## H... | {
"repo_name": "probml/pyprobml",
"path": "scripts/numbers_game.py",
"copies": "1",
"size": "16368",
"license": "mit",
"hash": -5085824868978635000,
"line_mean": 45.8596491228,
"line_max": 142,
"alpha_frac": 0.6164467253,
"autogenerated": false,
"ratio": 3.7276246868594853,
"config_test": false,... |
# Based on https://github.com/probml/pmtk3/blob/master/demos/shrinkcovDemo.m
# Converted by John Fearns - jdf22@infradead.org
# Demo of the quality of shrinkage estimation of a covariance matrix
import numpy as np
import matplotlib.pyplot as plt
from pyprobml_utils import save_fig
# Ensure stochastic reproduc... | {
"repo_name": "probml/pyprobml",
"path": "scripts/shrinkcov_plots.py",
"copies": "1",
"size": "2847",
"license": "mit",
"hash": -3434134998122742300,
"line_mean": 37.0273972603,
"line_max": 104,
"alpha_frac": 0.6420793818,
"autogenerated": false,
"ratio": 2.9080694586312563,
"config_test": fals... |
"""Based on https://github.com/pypa/sampleproject/blob/master/setup.py."""
import io
# To use a consistent encoding
import os
# Always prefer setuptools over distutils
from setuptools import find_packages, setup
NAME = "housekeeper"
DESCRIPTION = "Housekeeper takes care of files"
AUTHOR = "Robin Andeer"
EMAIL = "man... | {
"repo_name": "Clinical-Genomics/housekeeper",
"path": "setup.py",
"copies": "1",
"size": "3614",
"license": "mit",
"hash": 8435667933386109000,
"line_mean": 37.4468085106,
"line_max": 94,
"alpha_frac": 0.6615938019,
"autogenerated": false,
"ratio": 4.011098779134295,
"config_test": false,
"h... |
# based on https://github.com/pypa/sampleproject/blob/master/setup.py
# see http://packaging.python.org/en/latest/tutorial.html#creating-your-own-project
from setuptools import setup, find_packages
from setuptools.command.install import install as stdinstall
import codecs
import os
import re
import sys
def find_v... | {
"repo_name": "prechelt/pseudonymizer",
"path": "setup.py",
"copies": "1",
"size": "3288",
"license": "mit",
"hash": 1511507420453706200,
"line_mean": 33.2604166667,
"line_max": 91,
"alpha_frac": 0.646593674,
"autogenerated": false,
"ratio": 3.8865248226950353,
"config_test": false,
"has_no_k... |
"""Based on: https://github.com/pypa/sampleproject."""
from setuptools import find_packages, setup
from os import path
# Get the long description from the README file
with open(path.join(path.abspath(path.dirname(__file__)), 'README.rst')) as f:
long_description = f.read()
tests_require = ['flake8', 'mock', 'pyt... | {
"repo_name": "tiagoshibata/exrsplit",
"path": "setup.py",
"copies": "1",
"size": "2400",
"license": "mit",
"hash": 7518717942664078000,
"line_mean": 32.3333333333,
"line_max": 94,
"alpha_frac": 0.6833333333,
"autogenerated": false,
"ratio": 3.902439024390244,
"config_test": true,
"has_no_key... |
"""A generic daemon class. Subclass and override the run() method.
Based on http://www.jejik.com/articles/2007/02/a_simple_unix_linux_daemon_in_python/
and https://github.com/sivy/pystatsd/blob/master/pystatsd/daemon.py
"""
import os
import sys
import time
import atexit
from signal import SIGTERM
class Daemon(ob... | {
"repo_name": "librato/librato-python-web",
"path": "librato_python_web/statsd/server/daemon.py",
"copies": "1",
"size": "4981",
"license": "bsd-3-clause",
"hash": 4863346005177054000,
"line_mean": 32.4295302013,
"line_max": 84,
"alpha_frac": 0.5783979121,
"autogenerated": false,
"ratio": 4.00724... |
# based on https://github.com/stackforge/flame/blob/master/flameclient/flame.py
template_skeleton = '''
heat_template_version: 2013-05-23
description: Generated template
parameters:
resources:
'''
class Resource(object):
"""Describes an OpenStack resource."""
def __init__(self, name, type, id=None, propertie... | {
"repo_name": "berendt/phoobe",
"path": "phoobe/resources.py",
"copies": "1",
"size": "1650",
"license": "apache-2.0",
"hash": 4555606896567412000,
"line_mean": 25.1904761905,
"line_max": 79,
"alpha_frac": 0.5206060606,
"autogenerated": false,
"ratio": 4.4,
"config_test": false,
"has_no_keywo... |
# based on https://github.com/tensorflow/models/tree/master/resnet
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import numpy as np
import tensorflow as tf
class Model(object):
"""ResNet model."""
def __init__(self, mode):
"""ResNet constructor.
... | {
"repo_name": "MadryLab/cifar10_challenge",
"path": "model.py",
"copies": "1",
"size": "6285",
"license": "mit",
"hash": 109079787398778600,
"line_mean": 32.7903225806,
"line_max": 89,
"alpha_frac": 0.5931583134,
"autogenerated": false,
"ratio": 3.175846387064174,
"config_test": false,
"has_n... |
# based on https://github.com/williamFalcon/hello/blob/main/hello.py
import os
import numpy as np
from argparse import ArgumentParser
import torch
from torch.utils.tensorboard import SummaryWriter
# add arguments
parser = ArgumentParser()
parser.add_argument('--number', default=0, type=int)
parser.add_argument('--foo... | {
"repo_name": "probml/pyprobml",
"path": "scripts/hello-grid.py",
"copies": "1",
"size": "1400",
"license": "mit",
"hash": 7609845725482802000,
"line_mean": 30.8181818182,
"line_max": 99,
"alpha_frac": 0.6892857143,
"autogenerated": false,
"ratio": 2.978723404255319,
"config_test": false,
"ha... |
# Based on https://github.com/wiseodd/generative-models/blob/master/GAN/vanilla_gan/gan_tensorflow.py
# Also see: http://wiseodd.github.io/techblog/2016/09/17/gan-tensorflow/
import tensorflow as tf
from tensorflow.examples.tutorials.mnist import input_data
import numpy as np
import matplotlib.pyplot as plt
import mat... | {
"repo_name": "random-forests/tensorflow-workshop",
"path": "archive/extras/vanilla_gan.py",
"copies": "1",
"size": "3584",
"license": "apache-2.0",
"hash": 6691921109143836000,
"line_mean": 28.1463414634,
"line_max": 126,
"alpha_frac": 0.6375558036,
"autogenerated": false,
"ratio": 2.54364797728... |
# Based on https://github.com/Woorank/tipo/
KEY_MISHITS_MAP = {
'1': [ '2', 'q' ],
'2': [ '1', 'q', 'w', '3' ],
'3': [ '2', 'w', 'e', '4' ],
'4': [ '3', 'e', 'r', '5' ],
'5': [ '4', 'r', 't', '6' ],
'6': [ '5', 't', 'y', '7' ],
'7': [ '6', 'y', 'u', '8' ],
'8': [ '7', 'u', 'i', '9' ],
'9': [ '8', 'i'... | {
"repo_name": "bogdan-kulynych/textfool",
"path": "typos.py",
"copies": "1",
"size": "3214",
"license": "mit",
"hash": -3379882267207208400,
"line_mean": 27.1929824561,
"line_max": 66,
"alpha_frac": 0.3624766646,
"autogenerated": false,
"ratio": 2.310567936736161,
"config_test": false,
"has_n... |
## Based on https://github.com/yanpanlau/DDPG-Keras-Torcs
import keras.backend as kbck
from keras.models import Model, Sequential
from keras.layers import Dense, Input, Activation
from keras.layers.normalization import BatchNormalization
import tensorflow as tf
HIDDEN1_UNITS = 200
HIDDEN2_UNITS = 100
class Actor(ob... | {
"repo_name": "deot95/Tesis",
"path": "Proyecto de Grado Ingeniería Electrónica/Workspace/RL/DDPG/actor.py",
"copies": "4",
"size": "2509",
"license": "mit",
"hash": -8214270702250609000,
"line_mean": 42.275862069,
"line_max": 119,
"alpha_frac": 0.6576325229,
"autogenerated": false,
"ratio": 3.47... |
## Based on https://github.com/yanpanlau/DDPG-Keras-Torcs
import keras
import keras.backend as kbck
from keras.models import Model
from keras.layers import Dense, Input
from keras.layers.normalization import BatchNormalization
from keras.layers.merge import add
import tensorflow as tf
HIDDEN1_UNITS = 100
HIDDEN2_UNIT... | {
"repo_name": "deot95/Tesis",
"path": "Proyecto de Grado Ingeniería Electrónica/Workspace/RL/DDPG/critic.py",
"copies": "4",
"size": "2270",
"license": "mit",
"hash": 3193152066071927000,
"line_mean": 41.0555555556,
"line_max": 112,
"alpha_frac": 0.6511013216,
"autogenerated": false,
"ratio": 3.2... |
# Based on: https://github.com/yhenon/keras-frcnn/blob/master/train_frcnn.py
# Clone repo: https://github.com/yhenon/keras-frcnn
# add this example into the repo with keras_exp in the PYTHONPATH and run.
# python train_frcnn_mgpu.py -p /path/to/pascalvoc/
from __future__ import division
import random
import pprint
imp... | {
"repo_name": "rossumai/keras-multi-gpu",
"path": "keras_tf_multigpu/examples/avolkov1/faster_rcnn/train_frcnn_mgpu.py",
"copies": "1",
"size": "14466",
"license": "mit",
"hash": -6685520556172298000,
"line_mean": 38.3097826087,
"line_max": 156,
"alpha_frac": 0.5927001244,
"autogenerated": false,
... |
# Based on https://hvelarde.blogspot.se/2014/01/how-to-get-statistics-about-your.html
# Requires github3.py, get it with "pip install github3.py"
import operator
from getpass import getpass
from pprint import pprint
from github3 import login
two_factor_code = ''
def prompt_two_factor():
global two_factor_code
... | {
"repo_name": "ErikBjare/activitywatch",
"path": "scripts/contributor-stats.py",
"copies": "1",
"size": "1926",
"license": "mit",
"hash": -616972867541055900,
"line_mean": 27.3235294118,
"line_max": 90,
"alpha_frac": 0.6163032191,
"autogenerated": false,
"ratio": 3.6967370441458733,
"config_tes... |
#based on https://proglib.io/p/real-time-object-detection/
# import the necessary packages
from imutils.video import VideoStream
from imutils.video import FPS
import numpy as np
import imutils
import time
import cv2
import os
path=os.path.join(os.path.abspath(os.curdir) , 'my_model.onnx')
args_confidence = 0.2
# in... | {
"repo_name": "bosonbeard/Funny-models-and-scripts",
"path": "3.Machine_learning/4.neural_networks/1. rt_webcam_class_PyTorch/rt_object_class_PTH_my.py",
"copies": "1",
"size": "2272",
"license": "unlicense",
"hash": 6100780066696409000,
"line_mean": 27.4125,
"line_max": 100,
"alpha_frac": 0.71082746... |
"""Based on https://semantria.com/download/documents/Semantria_API_Quick_Start_Guide.pdf
"""
import semantria
import uuid
import time
import logging
LOGGER = logging.getLogger('APICompare.Semantria')
def onError(sender, result):
LOGGER.error(result)
class Semantria:
def __init__(self, consumer_key, cons... | {
"repo_name": "skyttle/sentiment-evaluation",
"path": "semantria_api.py",
"copies": "2",
"size": "1345",
"license": "apache-2.0",
"hash": -7467246285297089000,
"line_mean": 27.6170212766,
"line_max": 88,
"alpha_frac": 0.6089219331,
"autogenerated": false,
"ratio": 3.746518105849582,
"config_tes... |
# based on https:#sites.google.com/site/tfagerscode/home/digipotx9cxxx
from nanpy.util import constrain
DIGIPOT_MAX_AMOUNT = 99
LOW, HIGH = 0, 1
INPUT, OUTPUT = 0, 1
class DigiPot():
_udLastValue = None
_currentValue = None
range = (0, DIGIPOT_MAX_AMOUNT)
def __init__(self, incPin, udPin, csPin):
... | {
"repo_name": "nanpy/nanpy",
"path": "nanpy/DigiPotX9Cxxx.py",
"copies": "1",
"size": "2231",
"license": "mit",
"hash": -1091183599050948200,
"line_mean": 27.2405063291,
"line_max": 70,
"alpha_frac": 0.5764231286,
"autogenerated": false,
"ratio": 3.5983870967741933,
"config_test": false,
"has... |
# Based on https://stackoverflow.com/a/3041990
def query_yes_no(question, default='yes'):
'''Ask a yes/no question via input() and return their answer.
'question' is a string that is presented to the user.
'default' is the presumed answer if the user just hits <Enter>.
It must be 'yes' (the default)... | {
"repo_name": "pastly/python-snippits",
"path": "src/userquery.py",
"copies": "1",
"size": "2813",
"license": "unlicense",
"hash": 8798975337877301000,
"line_mean": 41.6212121212,
"line_max": 79,
"alpha_frac": 0.6178457163,
"autogenerated": false,
"ratio": 3.9232914923291493,
"config_test": fal... |
# Based on https://stackoverflow.com/a/46600038 with some modifications
import re
from sphinx.directives.other import TocTree
def setup(app):
app.add_directive('toctree', TocTreeFilt, override=True)
return {'parallel_read_safe': True, 'parallel_write_safe': True, 'version': '0.1'}
class TocTreeFilt(TocTre... | {
"repo_name": "espressif/esp-idf",
"path": "docs/extensions/toctree_filter.py",
"copies": "1",
"size": "1495",
"license": "apache-2.0",
"hash": -6907701060405733000,
"line_mean": 33.7674418605,
"line_max": 89,
"alpha_frac": 0.6688963211,
"autogenerated": false,
"ratio": 3.8333333333333335,
"con... |
# Based on https://stackoverflow.com/a/62859169/562769
from typing import List
import fitz # install with 'pip install pymupdf'
def _parse_highlight(annot: fitz.Annot, wordlist: List) -> str:
points = annot.vertices
quad_count = int(len(points) / 4)
sentences = ["" for i in range(quad_count)]
for i... | {
"repo_name": "MartinThoma/algorithms",
"path": "PDF/extract_highlights_fitz.py",
"copies": "1",
"size": "1196",
"license": "mit",
"hash": 5747954841422029000,
"line_mean": 26.1818181818,
"line_max": 71,
"alpha_frac": 0.618729097,
"autogenerated": false,
"ratio": 3.26775956284153,
"config_test"... |
"""Based on https://stackoverflow.com/q/59978887/3219667.
Update: not working. May want to revisit
"""
import socket
from loguru import logger
HOST = '127.0.0.1'
PORT = 65439
ACK_TEXT = 'text_received'
def main():
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
sock.setsockopt(socket... | {
"repo_name": "KyleKing/My-Programming-Sketchbook",
"path": "Assorted_Snippets/python/socket_prototyping/server_makefile.py",
"copies": "1",
"size": "1059",
"license": "mit",
"hash": -5472494293630851000,
"line_mean": 23.6279069767,
"line_max": 79,
"alpha_frac": 0.5476864967,
"autogenerated": false... |
# Based on http://stackoverflow.com/a/2022629
class Event(list):
def __call__(self, *args, **kwargs):
for f in self[:]:
if "once" in dir(f) and f in self:
self.remove(f)
f(*args, **kwargs)
def __repr__(self):
return "Event(%s)" % list.__repr__(self)
... | {
"repo_name": "kustomzone/Fuzium",
"path": "core/src/util/Event.py",
"copies": "10",
"size": "1605",
"license": "mit",
"hash": -3076375008596888600,
"line_mean": 28.1818181818,
"line_max": 71,
"alpha_frac": 0.5096573209,
"autogenerated": false,
"ratio": 3.574610244988864,
"config_test": false,
... |
# Based on http://stackoverflow.com/a/5809952/689985
from django.test.simple import DjangoTestSuiteRunner
from django.test.simple import dependency_ordered
class ByPassableDBDjangoTestSuiteRunner(DjangoTestSuiteRunner):
def setup_databases(self, **kwargs):
from django.db import connections, DEFAULT_DB_ALI... | {
"repo_name": "boldprogressives/django-testrunner-use_live_db",
"path": "use_live_db/test_runner.py",
"copies": "1",
"size": "3826",
"license": "bsd-3-clause",
"hash": 7782556108939252000,
"line_mean": 48.0512820513,
"line_max": 115,
"alpha_frac": 0.6011500261,
"autogenerated": false,
"ratio": 4.... |
# based on http://stackoverflow.com/questions/2082387/reading-input-from-raw-input-without-having-the-prompt-overwritten-by-other-th
from rl import readline
from threading import Thread, Timer
from sys import stdout
from struct import unpack
from fcntl import ioctl
from termios import TIOCGWINSZ
prompt = '> '
def... | {
"repo_name": "hpk42/p4p",
"path": "attic/play_async_print2.py",
"copies": "1",
"size": "1101",
"license": "mit",
"hash": -4985740994632260000,
"line_mean": 26.525,
"line_max": 132,
"alpha_frac": 0.663941871,
"autogenerated": false,
"ratio": 3.4299065420560746,
"config_test": false,
"has_no_k... |
# based on http://stackoverflow.com/questions/21295068/how-can-i-create-a-relay-server-using-tulip-asyncio-in-python
import asyncio
from asyncio.queues import Queue, QueueEmpty
class Client(asyncio.Protocol):
def connection_made(self, transport):
self.connected = True
# save the transport
... | {
"repo_name": "yv84/pyph",
"path": "src/proxy/gs_proxy.py",
"copies": "1",
"size": "3752",
"license": "mit",
"hash": 8741434748612914000,
"line_mean": 37.2857142857,
"line_max": 116,
"alpha_frac": 0.6247334755,
"autogenerated": false,
"ratio": 4.038751345532831,
"config_test": false,
"has_no_... |
# Based on http://stackoverflow.com/questions/2333872/atomic-writing-to-file-with-python
import os
from contextlib import contextmanager
# We would ideally atomically replace any existing file with the new
# version. However, on Windows there's no Python-only solution prior
# to Python 3.3. (This library includes a C... | {
"repo_name": "hparik11/Deep-Learning-Nanodegree-Foundation-Repository",
"path": "reinforcement/gym/gym/utils/atomic_write.py",
"copies": "9",
"size": "1951",
"license": "mit",
"hash": -4101213126478046700,
"line_mean": 34.4727272727,
"line_max": 200,
"alpha_frac": 0.6560738083,
"autogenerated": fa... |
# Based on: https://towardsdatascience.com/clustering-the-us-population-observation-weighted-k-means-f4d58b370002
import random
import numpy as np
import scipy.spatial
def distance(p1,p2):
return np.linalg.norm(p1,p2)
def cluster_centroids(data,weights, clusters, k):
results=[]
for i in range(k):
results.... | {
"repo_name": "JeroenZegers/Nabu-MSSS",
"path": "nabu/postprocessing/reconstructors/weighted_kmeans.py",
"copies": "1",
"size": "1096",
"license": "mit",
"hash": -6882614435417415000,
"line_mean": 29.4444444444,
"line_max": 113,
"alpha_frac": 0.7144160584,
"autogenerated": false,
"ratio": 3.28143... |
# based on https://www.djangosnippets.org/snippets/1289/
# cleanup and made work for Python 3
from django import template
from django.template import Node, Variable
from django.utils.encoding import smart_text
from django.template.defaulttags import url
from django.template import VariableDoesNotExist
register = templ... | {
"repo_name": "vmogilev/soloist",
"path": "lib/breadcrumbs.py",
"copies": "1",
"size": "3554",
"license": "apache-2.0",
"hash": -4702044032695905000,
"line_mean": 27.416,
"line_max": 91,
"alpha_frac": 0.5765765766,
"autogenerated": false,
"ratio": 3.738947368421053,
"config_test": false,
"has... |
# Based on https://www.zufallsheld.de/2014/01/25/python-backup-script-revisited/
# http://amoffat.github.io/sh/
# Example
# /usr/bin/python /home/mathieu/Git/scripts/python/backup.py --logfile=/home/mathieu/logs/backup.log --trash /media/Media/ /media/Media-Backup
#!/usr/bin/env python
import os
from shutil i... | {
"repo_name": "MCORN/scripts",
"path": "python/backup.py",
"copies": "1",
"size": "2142",
"license": "apache-2.0",
"hash": -1840681375580384300,
"line_mean": 30.9538461538,
"line_max": 142,
"alpha_frac": 0.6942110177,
"autogenerated": false,
"ratio": 3.1639586410635157,
"config_test": false,
... |
# Based on http://watir.com/guides/form-example/
from nerodia.browser import Browser
from time import sleep # needed to perform sleep
from faker import Faker # needed for fake form data
import os # needed for file path
# Setup
browser = Browser(browser='chrome')
browser.window().maximize()
# Navigate to the Page
... | {
"repo_name": "lmtierney/watir-snake",
"path": "examples/form_example.py",
"copies": "1",
"size": "2382",
"license": "mit",
"hash": 188953397385634700,
"line_mean": 35.6461538462,
"line_max": 105,
"alpha_frac": 0.7426532326,
"autogenerated": false,
"ratio": 3.1887550200803214,
"config_test": tr... |
# Based on http://www.awebcoder.com/post/91001/extended-jsonify-function-for-appengine-s-db-model
import collections
import datetime
import inspect
import json
import logging
from dorthy.utils import camel_encode, native_str
PRIMITIVE_TYPES = (bool, int, float, str)
logger = logging.getLogger(__name__)
def dumps(o... | {
"repo_name": "barryloper/dorthy",
"path": "dorthy/json.py",
"copies": "2",
"size": "5502",
"license": "mit",
"hash": 1617179420032817400,
"line_mean": 33.6037735849,
"line_max": 112,
"alpha_frac": 0.596692112,
"autogenerated": false,
"ratio": 4.255220417633411,
"config_test": false,
"has_no_... |
## based on http://www.djangosnippets.org/snippets/706/
import gdata.contacts.service
from django.core.urlresolvers import reverse
from django.http import HttpResponseRedirect, get_host
from django.utils.html import escape
GOOGLE_CONTACTS_URI = "http://www.google.com/m8/feeds/"
def get_url_host(request):
if ... | {
"repo_name": "alex/pinax",
"path": "pinax/apps/authsub/views.py",
"copies": "3",
"size": "1259",
"license": "mit",
"hash": -6030621480103242000,
"line_mean": 26.9777777778,
"line_max": 77,
"alpha_frac": 0.6838760921,
"autogenerated": false,
"ratio": 3.5767045454545454,
"config_test": false,
... |
# Based on: http://www.djangosnippets.org/snippets/73/
#
# Modified by Sean Reifschneider to be smarter about surrounding page
# link context. For usage documentation see:
#
# http://www.tummy.com/Community/Articles/django-pagination/
from django import template
register = template.Library()
def paginator(co... | {
"repo_name": "artminster/artminster",
"path": "core/templatetags/paginator.py",
"copies": "1",
"size": "1659",
"license": "mit",
"hash": -8417161919125469000,
"line_mean": 32.8571428571,
"line_max": 85,
"alpha_frac": 0.6570223026,
"autogenerated": false,
"ratio": 3.590909090909091,
"config_tes... |
# Based on http://www.jejik.com/articles/2007/02/a_simple_unix_linux_daemon_in_python/
# By Sander Marechal (public domain)
import sys, os, time, atexit
from signal import SIGTERM
class Daemon:
"""
A generic daemon class.
Usage: subclass the Daemon class and override the run() method
"""
def __in... | {
"repo_name": "yozw/torch-dokx",
"path": "dokx-search/dokxDaemon.py",
"copies": "3",
"size": "3733",
"license": "bsd-3-clause",
"hash": 7899760576568215000,
"line_mean": 27.4961832061,
"line_max": 110,
"alpha_frac": 0.5103134208,
"autogenerated": false,
"ratio": 3.9670563230605738,
"config_test... |
#Based on http://www.math.rwth-aachen.de/~Gerhard.Hiss/Students/DiplomarbeitPfeiffer.pdf
#algorithm 3, 4
import itertools
#def dprint(*args, **kwargs): pass
dprint = print
def showValue(s, valueRepr=str):
"""printable representation of elements"""
if len(s) == 0:
return "e"
def escape(s):... | {
"repo_name": "dmishin/knuth_bendix",
"path": "knuth_bendix.py",
"copies": "1",
"size": "7344",
"license": "mit",
"hash": 8987488055506301000,
"line_mean": 30.2510638298,
"line_max": 112,
"alpha_frac": 0.5322712418,
"autogenerated": false,
"ratio": 3.3110910730387735,
"config_test": false,
"h... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.