commit
stringlengths
40
40
subject
stringlengths
1
1.49k
old_file
stringlengths
4
311
new_file
stringlengths
4
311
new_contents
stringlengths
1
29.8k
old_contents
stringlengths
0
9.9k
lang
stringclasses
3 values
proba
float64
0
1
7707e65ed591b890d91bcb7bf22923b8c17a113a
Add tests from Gregor's PR
readthedocs/rtd_tests/tests/test_api_permissions.py
readthedocs/rtd_tests/tests/test_api_permissions.py
from functools import partial from mock import Mock from unittest import TestCase from readthedocs.restapi.permissions import APIRestrictedPermission class APIRestrictedPermissionTests(TestCase): def get_request(self, method, is_admin): request = Mock() request.method = method request.use...
Python
0
44f70a0c8ea9613214ce6305c262a8508b4bc598
create add_user.py
add_user.py
add_user.py
#!/usr/bin/python import bluetooth print("Scanning for bluetooth devices in discoverable mode...") nearby_devices = bluetooth.discover_devices(lookup_names = True) for i, (addr, name) in enumerate(nearby_devices): print("[{}] {} {}".format(i, addr, name)) num = raw_input("Enter the number of your device (or typ...
Python
0.000005
c8c679221e0a36ac6074c0869bfc4b75d9745ae2
Create a.py
abc066/a.py
abc066/a.py
a, b, c = map(int, input().split()) print(min(a + b, b + c, a + c))
Python
0.000489
365152787cae36c12691e4da52a0575bd56d7d1b
Add tests for tril, triu and find
tests/cupyx_tests/scipy_tests/sparse_tests/test_extract.py
tests/cupyx_tests/scipy_tests/sparse_tests/test_extract.py
import unittest import numpy try: import scipy.sparse scipy_available = True except ImportError: scipy_available = False import cupy from cupy import testing from cupyx.scipy import sparse @testing.parameterize(*testing.product({ 'shape': [(8, 3), (4, 4), (3, 8)], 'a_format': ['dense', 'csr', 'c...
Python
0
a4d3056bbbe71d73d901c13927264157c9c51842
Add lc004_median_of_two_sorted_arrays.py
lc004_median_of_two_sorted_arrays.py
lc004_median_of_two_sorted_arrays.py
"""Leetcode 4. Median of Two Sorted Arrays Hard There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)). You may assume nums1 and nums2 cannot be both empty. Example 1: nums1 = [1, 3] nums2 = [2] The ...
Python
0.007128
8a836213f7466de51c6d3d18d1a5ba74bb28de4a
Add hdf5-vol-async package. (#26874)
var/spack/repos/builtin/packages/hdf5-vol-async/package.py
var/spack/repos/builtin/packages/hdf5-vol-async/package.py
# Copyright 2013-2021 Lawrence Livermore National Security, LLC and other # Spack Project Developers. See the top-level COPYRIGHT file for details. # # SPDX-License-Identifier: (Apache-2.0 OR MIT) from spack import * class Hdf5VolAsync(CMakePackage): """This package enables asynchronous IO in HDF5.""" homep...
Python
0
034fe49d29f229e8fafc6b1034fc2685cd896eb2
Create create-studio-item
my-ACG/create-studio-item/edit.py
my-ACG/create-studio-item/edit.py
# -*- coding: utf-8 -*- import argparse import csv import os import re import urllib.parse os.environ['PYWIKIBOT_DIR'] = os.path.dirname(os.path.realpath(__file__)) import pywikibot site = pywikibot.Site() site.login() datasite = site.data_repository() def main(studio): data = { 'labels': { ...
Python
0.000002
9b572d4f53b23f3dc51dbfb98d46d0daa68d3569
fix pep8 on core admin profile
opps/core/admin/profile.py
opps/core/admin/profile.py
# -*- coding: utf-8 -*- from django.contrib import admin from opps.core.models import Profile class ProfileAdmin(admin.ModelAdmin): pass admin.site.register(Profile, ProfileAdmin)
# -*- coding: utf-8 -*- from django.contrib import admin from opps.core.models import Profile class ProfileAdmin(admin.ModelAdmin): pass admin.site.register(Profile, ProfileAdmin)
Python
0
419e001591566df909b03ffd0abff12171b62491
Create binary_search_iter.py
binary_search_iter.py
binary_search_iter.py
#GLOBALS #======= FIRST_IDX = 0 def chop(number, int_list): list_size = length(int_list) start_idx = FIRST_IDX end_idx = list_size-1 current_idx = end_idx/2 itr_counter = list_size while itr_counter>0: current_value = int_list[current_idx] if current_value == number: return current_idx else if curren...
Python
0.000041
6c4c26f5383740257b8bca56ce1ea9011053aff6
add new package : keepalived (#14463)
var/spack/repos/builtin/packages/keepalived/package.py
var/spack/repos/builtin/packages/keepalived/package.py
# Copyright 2013-2020 Lawrence Livermore National Security, LLC and other # Spack Project Developers. See the top-level COPYRIGHT file for details. # # SPDX-License-Identifier: (Apache-2.0 OR MIT) from spack import * class Keepalived(AutotoolsPackage): """ Keepalived implements a set of checkers to dynamical...
Python
0
5ef097bc394ef5be9b723ca0732bb842ab82e9e1
Include app.wsgi into repository as an example #8
website/app.wsgi
website/app.wsgi
import sys from pathlib import Path path = Path(__file__) # when moving virual environment, update following line venv_location = str(path.parents[2]) # in Python3 there is no builtin execfile shortcut - let's define one def execfile(filename): globals = dict( __file__ = filename) exec(open(filename).read(),...
Python
0
397b7fbd676e283dc5203aa6c160a979c4e86305
Add convention seed command
project/api/management/commands/seed_convention.py
project/api/management/commands/seed_convention.py
# Django from django.core.management.base import BaseCommand import json from django.core.serializers import serialize from django.core.serializers.json import DjangoJSONEncoder from itertools import chain from api.factories import ( AppearanceFactory, AssignmentFactory, AwardFactory, ChartFactory, ...
Python
0.000001
fb0f5340d9dcd28725f43dc3b7f93def78bdab92
Add serialization tests for TMRegion
tests/unit/nupic/regions/tm_region_test.py
tests/unit/nupic/regions/tm_region_test.py
# ---------------------------------------------------------------------- # Numenta Platform for Intelligent Computing (NuPIC) # Copyright (C) 2017, Numenta, Inc. Unless you have an agreement # with Numenta, Inc., for a separate license for this software code, the # following terms and conditions apply: # # This progra...
Python
0
8d6676f2e19ab9df01c681b6590c6f4adb0f938c
add profile model
fbmsgbot/models/profile.py
fbmsgbot/models/profile.py
class Profile(): def __init__(self, **kwargs): self.first_name = kwargs['first_name'] self.last_name = kwargs['last_name'] self.profile_pic = kwargs['profile_pic'] self.locale = kwargs['locale'] self.timezone = kwargs['timezone'] self.gender = kwargs['gender']
Python
0.000001
7a3a6720a47f380cf20a06aaa47634675099bf92
Django learning site forms: add model forms QuizForm, TrueFalseQuestionForm, MultipleChoiceQuestionForm
python/django/learning_site_forms/courses/forms.py
python/django/learning_site_forms/courses/forms.py
from django import forms from . import models class QuizForm(forms.ModelForm): class Meta: model = models.Quiz fields = [ 'title', 'description', 'order', 'total_questions', ] class TrueFalseQuestionForm(forms.ModelForm): class Meta: ...
Python
0.997456
519b141349b4d39902416be560b989160d48b141
add echo_delay to estimate the delay between two wav files
echo_delay.py
echo_delay.py
import sys import wave import numpy as np from gcc_phat import gcc_phat if len(sys.argv) != 3: print('Usage: {} near.wav far.wav'.format(sys.argv[0])) sys.exit(1) near = wave.open(sys.argv[1], 'rb') far = wave.open(sys.argv[2], 'rb') rate = near.getframerate() N = rate window = np.hanning(N) while True:...
Python
0.000001
c71924d4baea473a36f0c22f0878fea7a9ff2800
Create constants.py
a2/constants.py
a2/constants.py
import re import time #first link to view the cruise base_link = 'https://www.princess.com/find/cruiseDetails.do?voyageCode=2801' #element to find button_element = 'md-hidden' #gets the current time time = time.strftime('%I:%M:%S') forming = 'building request' seperator = 'โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“...
Python
0.000006
3dcd012977d4dfea69ec4a51650ac9a4fd375842
add missing migration file
registration/migrations/0007_auto_20160416_1217.py
registration/migrations/0007_auto_20160416_1217.py
# -*- coding: utf-8 -*- # Generated by Django 1.9.2 on 2016-04-16 03:17 from __future__ import unicode_literals from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('registration', '0006_auto_20160416_1202'), ] operations = [ migrations.Alter...
Python
0.000001
64d675304b2d66d89e55dcff167d1dd20e6b000c
add fragment molecule class for monte carlo simulation
afm/molecule.py
afm/molecule.py
class FragmentMolecule(object): def __init__(self, composition): self.composition = composition def __str__(self): """ Return a string representation. """ return self.composition
Python
0
f3c2b9087a06b508a278cb8e6f79200caae1ac07
Add a tool to encode udot instructions in asm code so we compile on any toolchain.
standalone/encode.py
standalone/encode.py
import sys import re def encode_udot_vector(line): m = re.search( r'\budot[ ]+v([0-9]+)[ ]*.[ ]*4s[ ]*,[ ]*v([0-9]+)[ ]*.[ ]*16b[ ]*,[ ]*v([0-9]+)[ ]*.[ ]*16b', line) if not m: return 0, line match = m.group(0) accum = int(m.group(1)) lhs = int(m.group(2)) rhs = int(m.group(3)) assert a...
Python
0
74c23aff06485f323c45b24e7e3784dd3c72d576
Create dokEchoServer.py
dokEchoServer.py
dokEchoServer.py
#!/usr/bin/env python2.7 # Created by Adam Melton (.dok) referenceing https://bitmessage.org/wiki/API_Reference for API documentation # Distributed under the MIT/X11 software license. See the accompanying # file COPYING or http://www.opensource.org/licenses/mit-license.php. # This is an example of an echo server for P...
Python
0
fb8b1d7cb6e98e97fb383ca7457cb1cd237f8184
Add usernamer.py
examples/username.py
examples/username.py
# Madenning Username Generator # Returns first char of first name and first 7 chars of last name def usernamer(first_name, last_name): username = first_name[0] + last_name[:7] return username.lower() if __name__ == '__main__': # Testing assert usernamer("Joshua", "Wedekind") == "jwedekin" firs...
Python
0.000013
864329b8a84f8d7df71b9f1d13b43118b7a3f522
Remove consent status for draft participants (#2622)
rdr_service/tools/tool_libs/unconsent.py
rdr_service/tools/tool_libs/unconsent.py
import argparse from sqlalchemy import and_ from sqlalchemy.orm import Session from rdr_service.model.code import Code from rdr_service.model.consent_file import ConsentFile from rdr_service.model.participant import Participant from rdr_service.model.participant_summary import ParticipantSummary from rdr_service.mode...
Python
0
1417d5345d68ef67ba6e832bbc45b8f0ddd911bc
Create testTemplate.py
data_structures/linked_list/utils/testTemplate.py
data_structures/linked_list/utils/testTemplate.py
# A test template for Python solutions. import sys def TestMain(sol, log=sys.stdout, doNotLogPassed=True) -> bool: """ @param sol: the function to be tested. @param log: a stream or a file to log the tester output to. @param doNotLogPassed: if True, all successful tests will n...
Python
0.000001
969a424fae41d85ac141febab40d603f05b1b977
Add command to remove unused import statements
dev_tools/src/d1_dev/src-remove-unused-imports.py
dev_tools/src/d1_dev/src-remove-unused-imports.py
#!/usr/bin/env python # -*- coding: utf-8 -*- # This work was created by participants in the DataONE project, and is # jointly copyrighted by participating institutions in DataONE. For # more information on DataONE, see our web site at http://dataone.org. # # Copyright 2009-2016 DataONE # # Licensed under the Apache...
Python
0.000002
3ea318cf5c1b66106bf496d513efdd6e86d0f665
add vowpal_wabbit requirement installation
robustus/detail/install_vowpal_wabbit.py
robustus/detail/install_vowpal_wabbit.py
# ============================================================================= # COPYRIGHT 2013 Brain Corporation. # License under MIT license (see LICENSE file) # ============================================================================= import logging import os from requirement import RequirementException from u...
Python
0
30567284410b9bb7154b8d39e5dfe7bc4bb1b269
Add migration for on_delete SET_NULL
herald/migrations/0006_auto_20170825_1813.py
herald/migrations/0006_auto_20170825_1813.py
# -*- coding: utf-8 -*- # Generated by Django 1.9.8 on 2017-08-25 23:13 from __future__ import unicode_literals from django.conf import settings from django.db import migrations, models import django.db.models.deletion class Migration(migrations.Migration): dependencies = [ ('herald', '0005_merge_201704...
Python
0.000027
05ecbd6ea7692ac85a96b35a39ca4609f0a88d86
Create gapminder_data_analysis.py
gapminder_data_analysis.py
gapminder_data_analysis.py
# Importing the required libraries # Note %matplotlib inline works only for ipython notebook. It will not work for PyCharm. It is used to show the plot distributions %matplotlib inline import pandas as pd import numpy as np import matplotlib.pyplot as plt import seaborn as sns sns.set(color_codes=True) # Reading the d...
Python
0.000031
1999295556ba404c7542d2001d7fdca80de54b5f
update api
functions/bcftools/main.py
functions/bcftools/main.py
""" Lambda example with external dependency """ import logging from subprocess import Popen, PIPE import json logger = logging.getLogger() logger.setLevel(logging.INFO) def return_msg(out, err, status = 200): return { 'statusCode': status, 'body': json.dumps({"out": out, "err": er...
Python
0
f3c4bac262c6d09730b3f0c4a24639fde8b4d923
Add wsgi compatible example gunicorn application
gunicorn-app.py
gunicorn-app.py
from __future__ import unicode_literals import multiprocessing import gunicorn.app.base from gunicorn.six import iteritems def number_of_workers(): return (multiprocessing.cpu_count() * 2) + 1 def handler_app(environ, start_response): response_body = b'Works fine' status = '200 OK' response_head...
Python
0
cbf3d2bda86f6a1f3e6e1b975217bcde8c7fc0a9
Create fresh_tomatoes.py
fresh_tomatoes.py
fresh_tomatoes.py
import webbrowser import os import re # Styles and scripting for the page main_page_head = """ <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Favorite Movie!</title> <!-- Bootstrap 3 --> <link rel="stylesheet" href="https://netdna.bootstrapcdn.com/bootstrap/3.1.0/css/bootstrap.m...
Python
0.000342
8d8522c95492f034db2a43e95a6c9cd3fb60c798
Create glove2word2vec.py
glove2word2vec.py
glove2word2vec.py
#!/usr/bin/env python # -*- coding: utf-8 -*- # # Copyright (C) 2016 Manas Ranjan Kar <manasrkar91@gmail.com> # Licensed under the MIT License https://opensource.org/licenses/MIT """ CLI USAGE: python glove2word2vec.py <GloVe vector file> <Output model file> Convert GloVe vectors into Gensim compatible format to inst...
Python
0.000735
b4364727609fc17a33ab72d495e9e6d3a80480de
Add grab/spider/network_service.py
grab/spider/network_service.py
grab/spider/network_service.py
import time from six.moves.queue import Empty from grab.error import GrabNetworkError, GrabTooManyRedirectsError, GrabInvalidUrl from grab.util.misc import camel_case_to_underscore from grab.spider.base_service import BaseService def make_class_abbr(name): val = camel_case_to_underscore(name) return val.rep...
Python
0.000001
c718cf1d483b2570b886269cf990458b195500b5
Remove Access-Control-Allow-Origin after all
gratipay/utils/cache_static.py
gratipay/utils/cache_static.py
""" Handles caching of static resources. """ from base64 import b64encode from hashlib import md5 from aspen import Response ETAGS = {} def asset_etag(path): if path.endswith('.spt'): return '' if path in ETAGS: h = ETAGS[path] else: with open(path) as f: h = ETAGS[p...
""" Handles caching of static resources. """ from base64 import b64encode from hashlib import md5 from aspen import Response ETAGS = {} def asset_etag(path): if path.endswith('.spt'): return '' if path in ETAGS: h = ETAGS[path] else: with open(path) as f: h = ETAGS[p...
Python
0
2f6bfddbff166115e59db7763a62258a06b4e789
Apply orphaned migration
project/apps/api/migrations/0010_remove_chart_song.py
project/apps/api/migrations/0010_remove_chart_song.py
# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import models, migrations class Migration(migrations.Migration): dependencies = [ ('api', '0009_auto_20150722_1041'), ] operations = [ migrations.RemoveField( model_name='chart', name=...
Python
0
b3ab8fa855a08f0d63885b6df206715d1f36a817
Add DNS-over-HTTPS example script
mrequests/examples/dns-over-https.py
mrequests/examples/dns-over-https.py
import mrequests from urlencode import urlencode DOH_IP = "1.1.1.1" DOH_SERVER = b"cloudflare-dns.com" DOH_PATH = "/dns-query" def gethostbyname(name): params = urlencode({ "name": name, "type": "A" }) headers = { b"accept": b"application/dns-json", b"user-agent": b"mreque...
Python
0
4f765997c740f1f9b2dc985e7f3b0a467e8c311a
add code.
image_to_yymmdd_dir_by_EXIF.py
image_to_yymmdd_dir_by_EXIF.py
# -*- coding: utf-8 -*- from PIL import Image import os import shutil user_name = os.getlogin() # image/hoge.jpg, image/fuga.png, etc... src_dir = "/Users/" + user_name + "/Desktop/image/" # create dst_dir/yyyymmdd/ dst_dir = "/Users/" + user_name + "/Desktop/dst_dir/" if os.path.exists(dst_dir) == False: os.mk...
Python
0.000001
f7a1998f67a02530604e4b727c7600704e4eb341
update pelu to K2
keras_contrib/layers/advanced_activations.py
keras_contrib/layers/advanced_activations.py
from .. import initializers from keras.engine import Layer from .. import backend as K import numpy as np class PELU(Layer): """Parametric Exponential Linear Unit. It follows: `f(x) = alphas * (exp(x / betas) - 1) for x < 0`, `f(x) = (alphas / betas) * x for x >= 0`, where `alphas` & `betas` are l...
from .. import initializers from keras.engine import Layer from .. import backend as K import numpy as np class PELU(Layer): """Parametric Exponential Linear Unit. It follows: `f(x) = alphas * (exp(x / betas) - 1) for x < 0`, `f(x) = (alphas / betas) * x for x >= 0`, where `alphas` & `betas` are l...
Python
0
920dbe007501ea99b95c41f94fb8f4a48c40717a
Add SensorsCollector, which collects data from libsensors via PySensors
src/collectors/SensorsCollector/SensorsCollector.py
src/collectors/SensorsCollector/SensorsCollector.py
import diamond.collector import sensors class SensorsCollector(diamond.collector.Collector): """ This class collects data from libsensors. It should work against libsensors 2.x and 3.x, pending support within the PySensors Ctypes binding: http://pypi.python.org/pypi/PySensors/ Requires: 'sensors' to ...
Python
0
68e43eafc1bb8e060ee105bcc9e3c354486dfcd2
add unit tests for dataset.py
dataset_tests.py
dataset_tests.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Aug 28 16:18:02 2017 Unit tests for dataset.py @author: duc """ import unittest import dataset as ds import numpy as np from flesch_kincaid import get_flesch_grade_level as lvl from nltk.corpus import cmudict pronDict = cmudict.dict() class Dataset...
Python
0.000006
66f32607d9d140be2a8e71270862074c53121a68
Create dataUIwgt.py
pyside/pyside_basics/jamming/dataUIwgt.py
pyside/pyside_basics/jamming/dataUIwgt.py
from PySide import QtGui class Data(object): def __init__(self): self.requiredNames = "A B C D E".split(' ') self.availableActions = "Set Select Delete".split(' ') def Set(self, name): print "setting ", name def Select(self, name): print "selecting ", name de...
Python
0.000002
ae948c95ea0087f33f13ef3463dc022eda0301a2
Add a solution for the MadLibs lab
python/labs/make-a-short-story/mystory.py
python/labs/make-a-short-story/mystory.py
# Create a function for adjectives so I don't repeat myself in prompts. def get_adjective(): return raw_input("Give me an adjective: ") def get_noun(): return raw_input("Give me a noun: ") def get_verb(): return raw_input("Give me a verb: ") adjective1 = get_adjective() noun1 = get_noun() verb1 = get_ver...
Python
0.000008
3cf1eb01540a126ef6a38219f89a41a0f05ad63f
Format fixing
constants.py
constants.py
UNITS = "SI" UNIT_LENGTH = 1 UNIT_MASS = 1 UNIT_TIME = 1 DEFAULT_GRAVITATIONAL_CONSTANT = 6.673e-11 # m3 kg-1 s-2 DEFAULT_SPEED_OF_LIGHT = 299792458 # m s-1 DEFAULT_SOLAR_MASS = 1.98892e30 # kg DEFAULT_PARSEC = 3.08568025e16 # m DEFAULT_YEAR ...
Python
0.000001
476f2493576c55c0f412165e3c3ce8225599ba0a
Copy caller_checker.py
server/src/voodoo/gen2/caller_checker.py
server/src/voodoo/gen2/caller_checker.py
#!/usr/bin/python # -*- coding: utf-8 -*- # # Copyright (C) 2005 onwards University of Deusto # All rights reserved. # # This software is licensed as described in the file COPYING, which # you should have received as part of this distribution. # # This software consists of contributions made by many individuals, # list...
Python
0.000004
77b34390345208a6e0bc5ad30cdce62e42ca0c56
Add simple command to list speakers and tickets
wafer/management/commands/pycon_speaker_tickets.py
wafer/management/commands/pycon_speaker_tickets.py
import sys import csv from optparse import make_option from django.core.management.base import BaseCommand from django.contrib.auth.models import User from wafer.talks.models import ACCEPTED class Command(BaseCommand): help = "List speakers and associated tickets." option_list = BaseCommand.option_list + t...
Python
0
c2e882855ea56c265ef46646ec5e20f78d0ad064
add migrations for missing phaselogs after fixing bulk project status updates
bluebottle/projects/migrations/0028_auto_20170619_1555.py
bluebottle/projects/migrations/0028_auto_20170619_1555.py
# -*- coding: utf-8 -*- # Generated by Django 1.10.7 on 2017-06-19 13:55 from __future__ import unicode_literals import datetime from django.db import migrations def fix_phaselog_for_incorrect_project_statuses(apps, schema_editor): """ #BB-9886 : Fix to add a new project phase status logs for projects whose st...
Python
0
c628e5ed57effd4386c913b0cb47884e61c7db88
Use camera height, and display disk
research/triangulation_3/Triangulation.py
research/triangulation_3/Triangulation.py
# coding: utf-8 # In[1]: import numpy as np import matplotlib.pyplot as plt from math import sin, cos, tan, atan, pi from pylab import imread from mpl_toolkits.mplot3d import Axes3D # In[2]: image = imread("lines1.png") plt.imshow(image) plt.show() #### Formules de position # In[3]: def position(laser, gamma,...
Python
0
9cb5658c53a2202931e314ced3ee66714301a087
Create _im_rot_manual_detect.py
resources/_py_in/_im_rot_manual_detect.py
resources/_py_in/_im_rot_manual_detect.py
# PYTHON # MANISH DEVGAN # https://github.com/gabru-md # Program helps in detecting faces which are # tilted right or left! The detection is done by # rotating the image and the trying to detect the # potential faces in it! #BEGIN # importing import cv2 import numpy as np import os import sys # function to rot...
Python
0.000064
36ada2dc33ccb3cb1803f67a112e3559efd7e821
Add file to initialize item endpoint - Add item_fields
app/api/item.py
app/api/item.py
""" Routes for bucket_item Functionality""" # from flask import g # from flask import Blueprint, request, jsonify from flask_restplus import fields # from app.models.bucketlist import Bucketlist # from app import api item_fields = { 'id': fields.Integer, 'name': fields.String, 'date_created': fields.DateTi...
Python
0
6c34347dc0bac58ca4e8e25f355f6ad0f7295ccd
Find/replace with regular expressions
ocradmin/plugins/util_nodes.py
ocradmin/plugins/util_nodes.py
""" Nodes to perform random things. """ import re from nodetree import node, writable_node, manager from ocradmin.plugins import stages, generic_nodes NAME = "Utils" from HTMLParser import HTMLParser class HTMLContentHandler(HTMLParser): def __init__(self): HTMLParser.__init__(self) self._data =...
""" Nodes to perform random things. """ from nodetree import node, writable_node, manager from ocradmin.plugins import stages, generic_nodes NAME = "Utils" from HTMLParser import HTMLParser class HTMLContentHandler(HTMLParser): def __init__(self): HTMLParser.__init__(self) self._data = [] ...
Python
0.999564
bf53f738bb5408622b08eedb9b0b0c6f80487a0c
Create 0603_verbs_vehicles.py
2019/0603_verbs_vehicles.py
2019/0603_verbs_vehicles.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ NPR 2019-06-02 https://www.npr.org/2019/06/02/728600551/sunday-puzzle-lets-go-toe-to-toe?utm_medium=RSS&utm_campaign=sundaypuzzle Think of a verb in its present and past tense forms. Drop the first letter of each word. The result will name two vehicles. What are the...
Python
0.000036
60f54674cc7bb619d5275dbd49e346ecee276ff2
fix reload module
importloader.py
importloader.py
๏ปฟ#!/usr/bin/python # -*- coding: UTF-8 -*- def load(name): try: obj = __import__(name) reload(obj) return obj except: pass try: import importlib obj = importlib.__import__(name) importlib.reload(obj) return obj except: pass def loads(namelist): for name in namelist: obj = load(name) if obj...
Python
0.000001
152db7b696b949c67b5121d42fba28ec31eceb47
Create everyeno_keys.py
everyeno_keys.py
everyeno_keys.py
tumblr_consumer_key = '' tumblr_consumer_secret = '' tumblr_token_key = '' tumblr_token_secret = '' google_developerKey = '' twitter_consumer_key = '' twitter_consumer_secret = '' twitter_token_key = '' twitter_token_secret = '' discogs_user_token = ''
Python
0
faff5fc7665abfcbcf5ab497ca533d7d3d4e53ac
Split property system into it's own file.
ppapi/generators/idl_propertynode.py
ppapi/generators/idl_propertynode.py
#!/usr/bin/python # # Copyright (c) 2011 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. """ Hierarchical property system for IDL AST """ import re import sys from idl_log import ErrOut, InfoOut, WarnOut from idl_option i...
Python
0.000293
d86bdff73f2c90667c8cd07750cfc120ca8a5a7d
Add BERT example.
examples/bert.py
examples/bert.py
# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, ...
Python
0
768b6fd5f4af994ca9af1470cfcc7fa7eb216a8f
Add a binding.gyp file.
binding.gyp
binding.gyp
{ 'targets': [ { 'target_name': 'validation', 'cflags': [ '-O3' ], 'sources': [ 'src/validation.cc' ] }, { 'target_name': 'bufferutil', 'cflags': [ '-O3' ], 'sources': [ 'src/bufferutil.cc' ] } ] }
Python
0
c9e2a8eca6fbcfbf3ccf8fcc54a7652c9e377d38
Update Xspider Background Management Command
xspider/xspider/management/commands/run.py
xspider/xspider/management/commands/run.py
#!usr/bin/env python # -*- coding:utf-8 -*- # Create on 2017.2.20 import os import datetime import string import traceback import threading import multiprocessing import subprocess from django.core.management.base import BaseCommand, CommandError from django.conf import settings from scheduler.scheduler import Xspide...
Python
0
e9b8330d71e48702198117652768ba6791bc1401
adds hello world
app/helloworld.py
app/helloworld.py
#!/usr/local/bin/python3.7 from pprint import pprint from bson.objectid import ObjectId from pymongo import MongoClient import datetime client = MongoClient('mongodb://localhost:27017/') db = client.test_database collection = db.test_collection post = {"author": "Mike", "text": "My first blog post!", "tags": ...
Python
0.999588
3bbf06964452683d986db401556183f575d15a55
Add script for inserting project into DB
insert-project.py
insert-project.py
#!/usr/bin/env python3 import pymongo import subprocess import re from datetime import datetime import argparse from json import load as load_json import sys def _info(msg): sys.stdout.write(msg + '\n') sys.stdout.flush() cl_parser = argparse.ArgumentParser(description='Insert a project into Meteor\'s local...
Python
0.000001
28e483c32d3e946f0f9159fe7459531f284d50aa
Add shared counter support to cache.
app/molcounter.py
app/molcounter.py
from google.appengine.api import memcache from google.appengine.ext import db import random import collections import logging class GeneralCounterShardConfig(db.Model): """Tracks the number of shards for each named counter.""" name = db.StringProperty(required=True) num_shards = db.IntegerProperty(required=True...
Python
0
dbed291584150ef3d219c487f32b47a8f4907195
question 1.7
crack_1_7.py
crack_1_7.py
test = [[0,1,2,3], [1,0,2,3], [1,2,0,3], [1,2,3,0]] raw = [] col = [] length = len(test) for x in xrange(length): for y in xrange(length): if test[x][y] == 0: raw.append(x) col.append(y) for x in raw: for y in xrange(length): test[x][y] = 0 for y in col: for x in xrange(length): test[x][y] = 0 for ...
Python
0.999967
2c6700d7a16ec7e76847f3664655aaf6c8f171eb
Create test_servo5v.py
test/test_servo5v.py
test/test_servo5v.py
from gadgets.motors.servos import Servo5V import time import random servo = Servo5V(pin_number=12,freq=100) count = 0 while count < 185: time.sleep(0.1) servo.write(count) count += 5 servo.cleanup()
Python
0.000003
f177811b254376cba0b053fdeb1bda4e84382c7a
Add Tristam MacDonald's Shader class.
scikits/gpu/shader.py
scikits/gpu/shader.py
""" This module is based on code from http://swiftcoder.wordpress.com/2008/12/19/simple-glsl-wrapper-for-pyglet/ which is Copyright (c) 2008, Tristam MacDonald Permission is hereby granted, free of charge, to any person or organization obtaining a copy of the software and accompanying documentation covered by this ...
Python
0
7c9c95795dbbc5f64b532720f5749b58361c222b
add collector for http://www.dshield.org/
collectors/dshield.py
collectors/dshield.py
#!/usr/bin/python # -*- coding: utf-8 -*- import socket import requests import ipwhois from pprint import pprint def get_url(url): try: res = requests.get(url) except requests.exceptions.ConnectionError: raise requests.exceptions.ConnectionError("DNS lookup failures") else: if res...
Python
0
8fe73523b7141f93d8523e56a7c6a5cc2ed82051
Test case for ioddrivesnmp class
src/collectors/iodrivesnmp/test/testiodrivesnmp.py
src/collectors/iodrivesnmp/test/testiodrivesnmp.py
#!/usr/bin/python # coding=utf-8 ################################################################################ from test import CollectorTestCase from test import get_collector_config from iodrivesnmp import IODriveSNMPCollector class TestIODriveSNMPCollector(CollectorTestCase): def setUp(self, allowed_names...
Python
0
2460bd91632da0e6b02e0faf379fe27b273575bc
Add rotate.py
rotate.py
rotate.py
"""Funtion to rotate image 90 degress.""" def rotate(matrix): pass
Python
0.000004
7a068872a071af2e60bf24ca7a00b3f1e999f139
add request builder
builders.py
builders.py
# -*- coding: utf-8 -*- import json class PostBuilder(object): def __init__(self): self.parameters = { 'title': '', 'body': '', 'coediting': False, 'gist': False, 'private': False, 'tags': [], 'tweet': False } ...
Python
0
857a5cb7effa03e9cd700fa69ae4d3b231212754
Create business.py
business.py
business.py
# business logic here # - account managing # - create # - edit # - delete # - payment data -> tokens # - scripts running # - statistics
Python
0.000003
4a45256b614ebf8a8455562b63c1d50ec1521c71
add a test class for auth.py
BigStash/t/test_auth.py
BigStash/t/test_auth.py
from mock import Mock from testtools.matchers import Contains from testtools import TestCase class AuthTest(TestCase): def setUp(self): super(AuthTest, self).setUp() def tearDown(self): super(AuthTest, self).tearDown() def _makeit(self, *args, **kwargs): from BigStash.auth import...
Python
0.000002
c212d1c25095f3b6e2f88cfccdc5c49280b22be0
Add test for tilequeue changes related to #1387.
integration-test/1387-business-and-spur-routes.py
integration-test/1387-business-and-spur-routes.py
from . import FixtureTest class BusinessAndSpurRoutes(FixtureTest): def test_first_capitol_dr_i70_business(self): self.load_fixtures([ 'https://www.openstreetmap.org/relation/1933234', ]) # check that First Capitol Dr, part of the above relation, is given # a network ...
Python
0
672210c3af1a1b56a145b5265e5f316a1f6f36df
Add test folder
py3utils/test/__init__.py
py3utils/test/__init__.py
Python
0
7ec15caf8f2c9d0a21581261a356f6decc548061
Add some basic UI tests
test/ui_test.py
test/ui_test.py
from app import app import unittest class UiTestCase(unittest.TestCase): def setUp(self): self.app = app.test_client() def test_index(self): self.assertEqual(self.app.get('/').status_code, 200) def test_no_page(self): self.assertEqual(self.app.get('/missing-page').status_code, 200...
Python
0.000001
59cc25693f2185ddfe36370d7f6641b2795d4798
Test File Upload
ladybug/test.py
ladybug/test.py
import epw from comfort.pmv import PMV
Python
0.000001
e9105e4bb42ec8191b14519d10012dc79337f717
Create tournament.py
Intro_to_Relational_Databases/tournament.py
Intro_to_Relational_Databases/tournament.py
#!/usr/bin/env python # # tournament.py -- implementation of a Swiss-system tournament # import psycopg2 def connect(): """Connect to the PostgreSQL database. Returns a database connection.""" return psycopg2.connect("dbname=tournament") def deleteMatches(): """Remove all the match records from the dat...
Python
0.000001
d1b2d330d2a43814d89c7f17a347e425c434957d
Add Eoin's resampling function.
pyrate/tools/resampler.py
pyrate/tools/resampler.py
import pandas as pd import numpy # Does the resampling # Called internally, one of the wrapper functions should be called if its needed ###################### def convert_messages_to_hourly_bins(df,period='H',fillnans=False,run_resample=True): if df.empty: return df if run_resample: ...
Python
0.000001
3b064d6933ef7e910fab5634420358562866f1bc
Add test
tests/test_camera.py
tests/test_camera.py
# coding: utf-8 from __future__ import unicode_literals import unittest import tempfile import shutil from flask import Flask from pitools import camera app = Flask(__name__) app.register_blueprint(camera.blueprint) class CameraTestCase(unittest.TestCase): def setUp(self): self.workspace = tempfile.mkd...
Python
0.000005
7ddfb39256229aa8c985ed8d70a29479187c76ad
Create script for beta invites
lily/management/commands/generate_beta_invites.py
lily/management/commands/generate_beta_invites.py
import csv import gc import logging from datetime import date from hashlib import sha256 from django.conf import settings from django.core.files.storage import default_storage from django.core.management import call_command from django.core.management.base import BaseCommand from django.core.urlresolvers import revers...
Python
0
5bc089a98bf578fd0c56e3e50cf76888ee74aba2
Add py solution for 537. Complex Number Multiplication
py/complex-number-multiplication.py
py/complex-number-multiplication.py
import re class Solution(object): def complexNumberMultiply(self, a, b): """ :type a: str :type b: str :rtype: str """ pat = re.compile(r'(-?\d+)\+(-?\d+)i') mata = pat.match(a) matb = pat.match(b) a = int(mata.group(1)), int(mata.group(2)) ...
Python
0.000635
400ad736a271946569efa438e8fc9d00a7ce0075
test for #22
tests/test_issues.py
tests/test_issues.py
from tgbot import plugintest from tgbot.botapi import Update from test_plugin import TestPlugin class TestPluginTest(plugintest.PluginTestCase): def setUp(self): self.plugin = TestPlugin() self.bot = self.fake_bot( '', plugins=[self.plugin], ) self.received_...
Python
0.000001
06e82c471afa83bf0f08f0779b32dd8a09b8d1ba
Add py solution for 350. Intersection of Two Arrays II
py/intersection-of-two-arrays-ii.py
py/intersection-of-two-arrays-ii.py
from collections import Counter class Solution(object): def intersect(self, nums1, nums2): """ :type nums1: List[int] :type nums2: List[int] :rtype: List[int] """ c1, c2 = Counter(nums1), Counter(nums2) return list((c1 & c2).elements())
Python
0.001158
742e827178ee28663699acbb4a5f0ad5440649fc
add new keyboard_locks module
py3status/modules/keyboard_locks.py
py3status/modules/keyboard_locks.py
# -*- coding: utf-8 -*- """ Monitor CapsLock, NumLock, and ScrLock keys NumLock: Allows the user to type numbers by pressing the keys on the number pad, rather than having them act as up, down, left, right, page up, end, and so forth. CapsLock: When enabled, letters the user types will be in uppercase by default rath...
Python
0.000001
3ff7c739cfc688c757396c465799ab42638c4a80
Add toopher-pair utility
toopher-pair.py
toopher-pair.py
import StringIO import getpass import argparse import signal import time import os import sys from wsgiref import validate import configobj import toopher import validate from common import * TIMEOUT_PAIRING = 30 DEFAULT_USER_CONFIG_FILE = StringIO.StringIO("""\ # This is a user-specific Toopher configuration file...
Python
0.000013
9d7c348170fc0f9d339a2ef57a9e64b1ceaa7516
Add demo MNH event scraper
web/whim/core/scrapers/mnh.py
web/whim/core/scrapers/mnh.py
from datetime import datetime, timezone, time import requests from bs4 import BeautifulSoup from django.db import transaction from .base import BaseScraper from .exceptions import ScraperException from whim.core.models import Event, Source, Category from whim.core.utils import get_object_or_none from whim.core.time...
Python
0
632fea66f57f72d176fb8ad56f0cdaf5e4884110
add test for multi-arch disasm
tests/test_multiarch_disasm.py
tests/test_multiarch_disasm.py
import os.path import idb def test_armel_disasm(): cd = os.path.dirname(__file__) idbpath = os.path.join(cd, 'data', 'armel', 'ls.idb') with idb.from_file(idbpath) as db: api = idb.IDAPython(db) assert api.idc.GetDisasm(0x00002598) == 'push\t{r4, r5, r6, r7, r8, sb, sl, fp, lr}' as...
Python
0.000001
423554349177a5c8ed987f249b13fac9c8b8d79a
Add links to upgrade actions in the change log
gen-changelog.py
gen-changelog.py
# Writes a changelog in trac WikiFormatting based on a git log from __future__ import unicode_literals, division, absolute_import import codecs from itertools import ifilter import os import re import subprocess import sys import dateutil.parser import requests from flexget.utils.soup import get_soup out_path = 'Ch...
# Writes a changelog in trac WikiFormatting based on a git log from __future__ import unicode_literals, division, absolute_import import codecs from itertools import ifilter import os import re import subprocess import sys import dateutil.parser out_path = 'ChangeLog' if len(sys.argv) > 1: dir_name = os.path.dir...
Python
0
35b1fc5e43f553e95ad4c8a42c37ca66639d9120
add test for core.py
HARK/tests/test_core.py
HARK/tests/test_core.py
""" This file implements unit tests for interpolation methods """ from HARK.core import HARKobject import numpy as np import unittest class testHARKobject(unittest.TestCase): def setUp(self): self.obj_a = HARKobject() self.obj_b = HARKobject() def test_distance(self): self.assertRaise...
Python
0
be17fa5026fd7cd64ccfc6e7241137a3f864725b
add google doc generator
generate_gpad.py
generate_gpad.py
import httplib2 import webbrowser from apiclient.discovery import build from oauth2client import client flow = client.flow_from_clientsecrets( 'client_secret.json', scope=['https://www.googleapis.com/auth/drive.file', 'https://www.googleapis.com/auth/urlshortener'], redirec...
Python
0
e1fa00aac605d8aaa8544af706f50ef64896bf8a
build dataset
py/testdir_0xdata_only/sphere_gen.py
py/testdir_0xdata_only/sphere_gen.py
import time, sys, random, math sys.path.extend(['.','..','py']) # a truly uniform sphere # http://stackoverflow.com/questions/5408276/python-uniform-spherical-distribution # he offers the exact solution: http://stackoverflow.com/questions/918736/random-number-generator-that-produces-a-power-law-distribution/918782#918...
Python
0.000006
f9e6176bc43262882a0d50f4d850c04c3460b9d8
Add SS :-)
rna_pdb_tools/SecondaryStructure.py
rna_pdb_tools/SecondaryStructure.py
#!/usr/bin/env python # -*- coding: utf-8 -*- """Seq and secondary structure prediction""" import os import tempfile import shutil VARNA_PATH = '/Users/magnus/skills/rnax/varna_tut/' def draw_ss(title,seq, ss, img_out): """""" curr = os.getcwd() os.chdir(VARNA_PATH)#VARNAv3-93-src') print os.getcwd...
Python
0
e5fed1895b69d824e3dc773dd6c6f88974e24f67
discard module (#61452)
lib/ansible/modules/network/checkpoint/cp_mgmt_discard.py
lib/ansible/modules/network/checkpoint/cp_mgmt_discard.py
#!/usr/bin/python # -*- coding: utf-8 -*- # # Ansible module to manage CheckPoint Firewall (c) 2019 # # Ansible is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your op...
Python
0
1bd0669e67fc082cbd496b3aa54c6a6f6a0d5fce
Add grab.util.log::print_dict method for fuzzy displaying of dict objects in console
grab/util/log.py
grab/util/log.py
def repr_value(val): if isinstance(val, unicode): return val.encode('utf-8') elif isinstance(val, (list, tuple)): return '[%s]' % ', '.join(repr_val(x) for x in val) elif isinstance(val, dict): return '{%s}' % ', '.join('%s: %s' % (repr_val(x), repr_val(y)) for x, y in val.items()) ...
Python
0.000001
e5bd12b67f58c1a099c2bd2dd66b043b43969267
Add a tool to publish packages in the repo to pub. Review URL: https://codereview.chromium.org//11415191
tools/publish_pkg.py
tools/publish_pkg.py
#!/usr/bin/env python # # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file # for details. All rights reserved. Use of this source code is governed by a # BSD-style license that can be found in the LICENSE file. # # Script to push a package to pub. # # Usage: publish_pkg.py pkg_dir import os...
Python
0.000003
f734cbd91ff8997b9f2aac6bbec2238f8b5f7511
Create __init__.py
graf/__init__.py
graf/__init__.py
Python
0.000429
a1c2423c349757f4725ef1250b9de084a469683c
Fix indentation
ceph_medic/checks/cluster.py
ceph_medic/checks/cluster.py
from ceph_medic import metadata # # Error checks # def check_osds_exist(): code = 'ECLS1' msg = 'There are no OSDs available' osd_count = len(metadata['osds'].keys()) if not osd_count: return code, msg def check_nearfull(): """ Checks if the osd capacity is at nearfull """ c...
from ceph_medic import metadata # # Error checks # def check_osds_exist(): code = 'ECLS1' msg = 'There are no OSDs available' osd_count = len(metadata['osds'].keys()) if not osd_count: return code, msg def check_nearfull(): """ Checks if the osd capacity is at nearfull ...
Python
0.000065
84990a4ef20c2e0f42133ed06ade5ce2d4e98ae3
Save team member picture with extension.
chmvh_website/team/models.py
chmvh_website/team/models.py
import os from django.db import models def team_member_image_name(instance, filename): _, ext = os.path.splitext(filename) return 'team/{0}{1}'.format(instance.name, ext) class TeamMember(models.Model): bio = models.TextField( verbose_name='biography') name = models.CharField( max_...
from django.db import models def team_member_image_name(instance, filename): return 'team/{0}'.format(instance.name) class TeamMember(models.Model): bio = models.TextField( verbose_name='biography') name = models.CharField( max_length=50, unique=True, verbose_name='name')...
Python
0
bf993439a7c53bcffe099a61138cf8c17c39f943
Add Partner label factory
accelerator/migrations/0066_partnerlabel.py
accelerator/migrations/0066_partnerlabel.py
# Generated by Django 2.2.10 on 2021-08-24 13:27 from django.conf import settings from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('accelerator', '0065_organization_note'), ] operations = [ migrations.CreateModel( name='Partne...
Python
0
6f9dcee86d986f05e289b39f6b4700d5d302f551
add tests for base models
jsonrpc/tests/test_base.py
jsonrpc/tests/test_base.py
""" Test base JSON-RPC classes.""" import unittest from ..base import JSONRPCBaseRequest, JSONRPCBaseResponse class TestJSONRPCBaseRequest(unittest.TestCase): """ Test JSONRPCBaseRequest functionality.""" def test_data(self): request = JSONRPCBaseRequest() self.assertEqual(request.data, {})...
Python
0
216b96e7f36d8b72ccd3ddf6809f0cc5af14d15a
Add fat_ready.py
fat_ready.py
fat_ready.py
#!/usr/bin/env python3 '''Make all files in a directory suitable for copying to a FAT filesystem. ''' from __future__ import print_function import os import os.path import sys from six import u if __name__ == u('__main__'): if len(sys.argv) != 2: print(u('Usage: {} <directory to make FAT ready>').format...
Python
0.00007
b362f33e6c8c83fc01c97760fd24665f18e61adf
extract Axi_datapumpTC
hwtLib/amba/datapump/test.py
hwtLib/amba/datapump/test.py
from typing import Optional, List from hwt.serializer.combLoopAnalyzer import CombLoopAnalyzer from hwt.simulator.simTestCase import SingleUnitSimTestCase from hwtLib.amba.constants import RESP_OKAY from hwtLib.examples.errors.combLoops import freeze_set_of_sets from pyMathBitPrecise.bit_utils import mask, get_bit_ran...
Python
0.999998
40070b6bab49fa0bd46c1040d92bc476e557b19b
add algorithms.fractionation to assess gene loss, bites, etc.
algorithms/fractionation.py
algorithms/fractionation.py
#!/usr/bin/env python # -*- coding: UTF-8 -*- """ Catalog gene losses, and bites within genes. """ import sys from optparse import OptionParser from itertools import groupby from jcvi.formats.blast import Blast from jcvi.utils.range import range_minmax, range_overlap from jcvi.utils.cbook import gene_name from jcvi...
Python
0