commit stringlengths 40 40 | subject stringlengths 4 1.73k | repos stringlengths 5 127k | old_file stringlengths 2 751 | new_file stringlengths 2 751 | new_contents stringlengths 1 8.98k | old_contents stringlengths 0 6.59k | license stringclasses 13
values | lang stringclasses 23
values |
|---|---|---|---|---|---|---|---|---|
ebe0b558d80ca7b7e5e7be50cc7c053020dca9fe | create list app skeleton | kubodhi/flist,kubodhi/flist | app.py | app.py | #!/usr/bin/env python
from flask import Flask
app = Flask(__name__)
# define a list item class
class ListItem(Model):
@app.route('/add', methods=['POST'])
def add_item():
''' add items to the list '''
return "stub"
@app.route('/view')
def view_items():
''' view items in the list '''
return "stub"
... | mit | Python | |
a23eb3f9a921676a3b91ff48b073f9cf4d15cfaa | Create bot.py | hanuchu/fuiibot | bot.py | bot.py | from twython import Twython, TwythonError
from PIL import Image
import os, random, statistics, time
APP_KEY = ''
APP_SECRET = ''
OAUTH_TOKEN = ''
OAUTH_TOKEN_SECRET = ''
brightness_threshold = 35
seconds_between_tweets = 600
def tweet():
twitter = Twython(APP_KEY, APP_SECRET, OAUTH_TOKEN, OAUTH_TOKEN_SECRET)
acce... | apache-2.0 | Python | |
3bb4f078f2a03b334c2b44378be2b01e54fb7b37 | Add command load beginner categories | MTG/freesound-datasets,MTG/freesound-datasets,MTG/freesound-datasets,MTG/freesound-datasets | datasets/management/commands/load_beginner_categories.py | datasets/management/commands/load_beginner_categories.py | from django.core.management.base import BaseCommand
import json
from datasets.models import Dataset, TaxonomyNode
class Command(BaseCommand):
help = 'Load field easy categories from json taxonomy file. ' \
'Use it as python manage.py load_beginner_categories.py ' \
'DATASET_ID PATH/TO/TAOXNO... | agpl-3.0 | Python | |
a06995a686c0509f50a481e7d7d41bb35ffe8f19 | add simple improved Sieve Of Eratosthenes Algorithm (#1412) | TheAlgorithms/Python | maths/prime_sieve_eratosthenes.py | maths/prime_sieve_eratosthenes.py | '''
Sieve of Eratosthenes
Input : n =10
Output : 2 3 5 7
Input : n = 20
Output: 2 3 5 7 11 13 17 19
you can read in detail about this at
https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes
'''
def prime_sieve_eratosthenes(num):
"""
print the prime numbers upto n
>>> prime_sieve_eratosthenes(10)
... | mit | Python | |
f50c1b067375ea8835c814b55484c416fbba6bf5 | Add test_utils.py; for running containers & http server for test fixture data | scottx611x/refinery-higlass-docker,scottx611x/refinery-higlass-docker,scottx611x/refinery-higlass-docker | test_utils.py | test_utils.py | import _thread
import docker
import logging
import os
import socket
from http.server import HTTPServer, SimpleHTTPRequestHandler
class TestFixtureServer(object):
def __init__(self):
self.port = 9999
self.ip = self.get_python_server_ip()
def get_python_server_ip(self):
# https://stac... | mit | Python | |
40c0d855ba50f39433d6e06f31f4a993a1c98160 | add python | jpgroup/democode,jpgroup/democode,yufree/democode,yufree/democode,jpgroup/democode,jpgroup/democode,yufree/democode,yufree/democode,jpgroup/democode,yufree/democode,yufree/democode,jpgroup/democode | pythontips.py | pythontips.py | # basic
# This is a comment!
# Storing a string to the variable s
s = "Hello world, world"
# printing the type. It shows 'str' which means it is a string type
print type(s)
# printing the number of characters in the string.
print len(s)
# Python gave me an error below! I guess we can't change individual parts of a str... | mit | Python | |
f44e4fe8fe7f66258241c77680b2bbf58a6f7d0a | Add basic tests for dics_epochs | Eric89GXL/mne-python,drammock/mne-python,lorenzo-desantis/mne-python,kingjr/mne-python,jniediek/mne-python,jaeilepp/mne-python,nicproulx/mne-python,teonlamont/mne-python,wmvanvliet/mne-python,teonlamont/mne-python,dgwakeman/mne-python,Odingod/mne-python,lorenzo-desantis/mne-python,cjayb/mne-python,alexandrebarachant/mn... | mne/beamformer/tests/test_dics.py | mne/beamformer/tests/test_dics.py | import os.path as op
from nose.tools import assert_true, assert_raises
import numpy as np
import mne
from mne.datasets import sample
from mne.beamformer import dics_epochs
from mne.time_frequency import compute_csd
data_path = sample.data_path()
fname_data = op.join(data_path, 'MEG', 'sample', 'sample_audvis-ave.fi... | bsd-3-clause | Python | |
ca5d276a512fccfe9ed0c7a89a48a13b61d67a55 | Add Display.py | PaulieC/sprint1_Council,PaulieC/rls-c,PaulieC/sprint5-Council,PaulieC/sprint2-Council,PaulieC/sprint1_Council_a,PaulieC/sprint1_Council_b,PaulieC/sprint3-Council,geebzter/game-framework | Display.py | Display.py | __author__ = 'Tara Crittenden'
# Displays the state of the game in a simple text format.
import Observer
import Message
class Display(Observer.Observer):
#Determine which method to display
def notify(self, msg):
if msg.msgtype == 1:
#start of a tournament
display_start_tourna... | apache-2.0 | Python | |
e6e92fb3afff0403091c221328f9023e0e391b0b | Add eventlisten script to watch events on the master and minion | saltstack/salt,saltstack/salt,saltstack/salt,saltstack/salt,saltstack/salt | tests/eventlisten.py | tests/eventlisten.py | '''
Use this script to dump the event data out to the terminal. It needs to know
what the sock_dir is.
This script is a generic tool to test event output
'''
# Import Python libs
import optparse
import pprint
import os
import time
import tempfile
# Import Salt libs
import salt.utils.event
def parse():
'''
P... | apache-2.0 | Python | |
703d97150de1c74b7c1a62b59c1ff7081dec8256 | Add an example of resolving a known service by service name | jstasiak/python-zeroconf | examples/resolver.py | examples/resolver.py | #!/usr/bin/env python3
""" Example of resolving a service with a known name """
import logging
import sys
from zeroconf import Zeroconf
TYPE = '_test._tcp.local.'
NAME = 'My Service Name'
if __name__ == '__main__':
logging.basicConfig(level=logging.DEBUG)
if len(sys.argv) > 1:
assert sys.argv[1:] =... | lgpl-2.1 | Python | |
039a07bde5975cb6ce40edc43bbd3d931ac5cc92 | Test borda ranking and spearman. | charanpald/APGL | exp/influence2/test/RankAggregatorTest.py | exp/influence2/test/RankAggregatorTest.py | import numpy
import unittest
import logging
from exp.influence2.RankAggregator import RankAggregator
import scipy.stats.mstats
import numpy.testing as nptst
class RankAggregatorTest(unittest.TestCase):
def setUp(self):
numpy.random.seed(22)
def testSpearmanFootrule(self):
lis... | bsd-3-clause | Python | |
afec3bf59fd454d61d5bc0024516610acfcb5704 | Add 1D data viewer. | stefanv/lulu | examples/viewer1D.py | examples/viewer1D.py | from __future__ import print_function
import numpy as np
from viewer import Viewer
from enthought.traits.api import Array
from enthought.chaco.api import Plot, ArrayPlotData, HPlotContainer, gray
import lulu
class Viewer1D(Viewer):
image = Array
result = Array
def _reconstruction_default(self):
... | bsd-3-clause | Python | |
d9ff51c74c4b41128bc8e2fe61811dba53e7da17 | Create test_client.py | chidaobanjiu/MANA2077,chidaobanjiu/MANA2077,chidaobanjiu/MANA2077,chidaobanjiu/Flask_Web,chidaobanjiu/Loocat.cc,chidaobanjiu/Loocat.cc,chidaobanjiu/Flask_Web,chidaobanjiu/Loocat.cc,chidaobanjiu/MANA2077,chidaobanjiu/MANA2077,chidaobanjiu/MANA2077,chidaobanjiu/Flask_Web,chidaobanjiu/Flask_Web | tests/test_client.py | tests/test_client.py | import unittest
from app import create_app, db
from app.models import User, Role
class FlaskClientTestCase(unittest.TestCase):
def setUp(self):
self.app = create_app('testing')
self.app_context = self.app.app_context()
self.app_context.push()
db.create_all()
Role.insert_role... | mit | Python | |
d37d831e54fbaebab427c9a5b88cb7eb358b31af | transform data to website via Post & Get | MiracleWong/aming_python,MiracleWong/aming_python | WebScraping/4.py | WebScraping/4.py | #!/usr/bin/python
# encoding:utf-8
import sys
import urllib, urllib2
import re
dic = {'hostname': 'n2', 'ip': '2.2.2.2'}
# url = 'http://127.0.0.1:8000/db/' + '?' + urllib.urlencode(dic)
url = 'http://127.0.0.1:8000/db/'
response = urllib2.urlopen(url, urllib.urlencode(dict))
print response.read()
| mit | Python | |
35a9576dce86c9c3d32c6cc32effb7a8f6c2b706 | Test DjangoAMQPConnection if Django is installed. Closes #10. | ask/carrot,ask/carrot | tests/test_django.py | tests/test_django.py | import os
import sys
import unittest
import pickle
import time
sys.path.insert(0, os.pardir)
sys.path.append(os.getcwd())
from tests.utils import AMQP_HOST, AMQP_PORT, AMQP_VHOST, \
AMQP_USER, AMQP_PASSWORD
from carrot.connection import DjangoAMQPConnection, AMQPConnection
from UserDict import ... | bsd-3-clause | Python | |
0390209498c2a604efabe13595e3f69f7dcbd577 | Add script for path init. | myfavouritekk/TPN | tools/init.py | tools/init.py | #!/usr/bin/env python
"""Setup paths for TPN"""
import os.path as osp
import sys
def add_path(path):
if path not in sys.path:
sys.path.insert(0, path)
this_dir = osp.dirname(__file__)
ext_dir = osp.join(this_dir, '..', 'external')
# Add py-faster-rcnn paths to PYTHONPATH
frcn_dir = osp.join(this_dir, ... | mit | Python | |
bcfd9808377878f440cc030178b33e76eb4f031c | Add presubmit check to catch use of PRODUCT_NAME in resources. | anirudhSK/chromium,ChromiumWebApps/chromium,Fireblend/chromium-crosswalk,jaruba/chromium.src,Jonekee/chromium.src,dednal/chromium.src,crosswalk-project/chromium-crosswalk-efl,markYoungH/chromium.src,hgl888/chromium-crosswalk-efl,Jonekee/chromium.src,ondra-novak/chromium.src,Jonekee/chromium.src,Pluto-tv/chromium-crossw... | chrome/app/PRESUBMIT.py | chrome/app/PRESUBMIT.py | # Copyright 2013 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.
"""Presubmit script for changes affecting chrome/app/
See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
for more details about the... | bsd-3-clause | Python | |
f2807e7505598abdc0f11c8d593655c3dc61c323 | add legislative.apps | opencivicdata/python-opencivicdata-django,opencivicdata/python-opencivicdata-django,opencivicdata/python-opencivicdata,opencivicdata/python-opencivicdata,opencivicdata/python-opencivicdata-django | opencivicdata/legislative/apps.py | opencivicdata/legislative/apps.py | from django.apps import AppConfig
import os
class BaseConfig(AppConfig):
name = 'opencivicdata.legislative'
verbose_name = 'Open Civic Data - Legislative'
path = os.path.dirname(__file__)
| bsd-3-clause | Python | |
cd7364467de45d63e89eab4e745e29dff9906f69 | Add crawler for 'dogsofckennel' | jodal/comics,datagutten/comics,datagutten/comics,datagutten/comics,jodal/comics,datagutten/comics,jodal/comics,jodal/comics | comics/comics/dogsofckennel.py | comics/comics/dogsofckennel.py | from comics.aggregator.crawler import CreatorsCrawlerBase
from comics.core.comic_data import ComicDataBase
class ComicData(ComicDataBase):
name = 'Dogs of C-Kennel'
language = 'en'
url = 'https://www.creators.com/read/dogs-of-c-kennel'
rights = 'Mason Mastroianni, Mick Mastroianni, Johnny Hart'
clas... | agpl-3.0 | Python | |
0c1ae2fb40e5af5cf732e7ec8e10d2e145be2eb2 | add run.py | bkzhn/simple-migrator | run.py | run.py | """Simple Migrator."""
__author__ = 'bkzhn'
if __name__ == '__main__':
print('== Simple Migrator ==')
| mit | Python | |
0d6a31ade487bea9f0b75b1c3e295176fb3a7555 | Add savecpython script | alex/codespeed,nomeata/codespeed,cykl/codespeed,alex/codespeed,cykl/codespeed,nomeata/codespeed | tools/savecpython.py | tools/savecpython.py | # -*- coding: utf-8 -*-
import urllib, urllib2
from datetime import datetime
SPEEDURL = 'http://127.0.0.1:8000/'#'http://speed.pypy.org/'
HOST = "bigdog"
def save(project, revision, results, options, branch, executable, int_options, testing=False):
testparams = []
#Parse data
data = {}
current_date = ... | lgpl-2.1 | Python | |
91773cb6a09f710002e5be03ab9ec0c19b2d6ea3 | Add script to extract rows from terms. | BitFunnel/BitFunnel,BitFunnel/BitFunnel,danluu/BitFunnel,danluu/BitFunnel,BitFunnel/BitFunnel,danluu/BitFunnel,danluu/BitFunnel,BitFunnel/BitFunnel,danluu/BitFunnel,BitFunnel/BitFunnel,danluu/BitFunnel,BitFunnel/BitFunnel | src/Scripts/show-term-convert.py | src/Scripts/show-term-convert.py | # Convert from show term to list of rows associated with each term.
import re
term_regex = re.compile("Term\(\"(\S+)\"\)")
rowid_regex = re.compile("\s+RowId\((\S+),\s+(\S+)\)")
this_term = ""
with open("/tmp/show.results.txt") as f:
for line in f:
rowid_match = rowid_regex.match(line)
if rowid_ma... | mit | Python | |
710f6ed188b6139f6469d61775da4fb752bac754 | Create __init__.py | mrpurplenz/mopidy-ampache | mopidy_ampache/__init__.py | mopidy_ampache/__init__.py | from __future__ import unicode_literals
import os
from mopidy import ext, config
__version__ = '1.0.0'
class AmpacheExtension(ext.Extension):
dist_name = 'Mopidy-Ampache'
ext_name = 'ampache'
version = __version__
def get_default_config(self):
conf_file = os.path.join(os.path.dirname(__fi... | mit | Python | |
2cd081a6a7c13b40b5db8f667d03e93353630830 | Create leetcode-78.py | jeremykid/FunAlgorithm,jeremykid/FunAlgorithm,jeremykid/FunAlgorithm,jeremykid/FunAlgorithm | python_practice/leetCode/leetcode-78.py | python_practice/leetCode/leetcode-78.py | class Solution:
def subsets(self, nums: List[int]) -> List[List[int]]:
if nums == []:
return [[]]
sub = self.subsets(nums[1:])
newSub = []
for i in sub:
newI = i + [nums[0]]
newSub.append(newI)
sub.extend(newSub)
return sub... | mit | Python | |
56f8dd435981a28bcb026da0edb395aabd515c29 | Add a frist test for create_random_data | khchine5/opal,khchine5/opal,khchine5/opal | opal/tests/test_command_create_random_data.py | opal/tests/test_command_create_random_data.py | """
Unittests for opal.management.commands.create_random_data
"""
from mock import patch, MagicMock
from opal.core.test import OpalTestCase
from opal.management.commands import create_random_data as crd
class StringGeneratorTestCase(OpalTestCase):
def test_string_generator(self):
mock_field = MagicMock(n... | agpl-3.0 | Python | |
826c3e3b2787e25d040b3ddf7c4bdabde3da4158 | Add tasks.py the new and improved celery_tasks.py | CenterForOpenScience/scrapi,mehanig/scrapi,alexgarciac/scrapi,CenterForOpenScience/scrapi,erinspace/scrapi,erinspace/scrapi,ostwald/scrapi,mehanig/scrapi,jeffreyliu3230/scrapi,felliott/scrapi,fabianvf/scrapi,felliott/scrapi,icereval/scrapi,fabianvf/scrapi | scrapi/tasks.py | scrapi/tasks.py | import os
import logging
import importlib
from datetime import datetime
from celery import Celery
import settings
app = Celery()
app.config_from_object(settings)
logger = logging.getLogger(__name__)
def import_consumer(consumer_name):
return importlib.import_module('scrapi.consumers.{}'.format(consumer_name)... | apache-2.0 | Python | |
3f1663f7cf32b590affb7a306bcc2711b17af296 | Add a monitor example. | dustin/twitty-twister | example/user_stream_monitor.py | example/user_stream_monitor.py | #!/usr/bin/env python
#
# Copyright (c) 2012 Ralph Meijer <ralphm@ik.nu>
# See LICENSE.txt for details
"""
Print Tweets on a user's timeline in real time.
This connects to the Twitter User Stream API endpoint with the given OAuth
credentials and prints out all Tweets of the associated user and of the
accounts the us... | mit | Python | |
ac3cd54b93aa6d5cddaac89016d09b9e6747a301 | allow bazel 0.7.x (#1467) | rkpagadala/mixer,istio/old_mixer_repo,istio/old_mixer_repo,istio/old_mixer_repo,rkpagadala/mixer,rkpagadala/mixer | check_bazel_version.bzl | check_bazel_version.bzl | def _parse_bazel_version(bazel_version):
# Remove commit from version.
version = bazel_version.split(" ", 1)[0]
# Split into (release, date) parts and only return the release
# as a tuple of integers.
parts = version.split("-", 1)
# Turn "release" into a tuple of strings
version_tuple = ()... | def _parse_bazel_version(bazel_version):
# Remove commit from version.
version = bazel_version.split(" ", 1)[0]
# Split into (release, date) parts and only return the release
# as a tuple of integers.
parts = version.split("-", 1)
# Turn "release" into a tuple of strings
version_tuple = ()... | apache-2.0 | Python |
b40d064ac5b4e01f11cdb1f6b7ce7f1a0a968be5 | Create set_memory_example.py | ahmadfaizalbh/Chatbot | examples/set_memory_example.py | examples/set_memory_example.py | from chatbot import Chat, register_call
import os
import warnings
warnings.filterwarnings("ignore")
@register_call("increment_count")
def memory_get_set_example(session, query):
name=query.strip().lower()
# Get memory
old_count = session.memory.get(name, '0')
new_count = int(old_count) + 1
# Set m... | mit | Python | |
12b7d2b2296b934675f2cca0f35d059a67f58e7f | Create ComputeDailyWage.py | JupiterLikeThePlanet/PostMates | ComputeDailyWage.py | ComputeDailyWage.py | ################################ Compute daily wage
def computepay ( w , m , e , g ):
total = float(wage) - (float(mileage)/float(gas)) - float(expenses)
return total
try:
input = raw_input('Enter Wages: ')
wage = float(input)
input = raw_input('Enter Miles: ')
mileage = float(input)
input... | mit | Python | |
2429c0bdf5c2db5c2b40dc43d0a4c277e20d72fa | add 0001 | Yrthgze/prueba-sourcetree2,Show-Me-the-Code/python,Yrthgze/prueba-sourcetree2,Show-Me-the-Code/python,Yrthgze/prueba-sourcetree2,Yrthgze/prueba-sourcetree2,Show-Me-the-Code/python,Yrthgze/prueba-sourcetree2,Show-Me-the-Code/python,Show-Me-the-Code/python,Yrthgze/prueba-sourcetree2,Show-Me-the-Code/python | Jaccorot/0001/0001.py | Jaccorot/0001/0001.py | #!/usr/local/bin/python
#coding=utf-8
#第 0001 题:做为 Apple Store App 独立开发者,你要搞限时促销,为你的应用生成激活码(或者优惠券),
#使用 Python 如何生成 200 个激活码(或者优惠券)?
import uuid
def create_code(num, length):
#生成”num“个激活码,每个激活码含有”length“位
result = []
while True:
uuid_id = uuid.uuid1()
temp = str(uuid_id).replace('-', '')[:le... | mit | Python | |
6913674358d226953c1090ab7c8f5674dac1816c | add 0007 | Show-Me-the-Code/python,Yrthgze/prueba-sourcetree2,Yrthgze/prueba-sourcetree2,Yrthgze/prueba-sourcetree2,Show-Me-the-Code/python,Yrthgze/prueba-sourcetree2,Show-Me-the-Code/python,Yrthgze/prueba-sourcetree2,Yrthgze/prueba-sourcetree2,Show-Me-the-Code/python,Show-Me-the-Code/python,Show-Me-the-Code/python | Jaccorot/0007/0007.py | Jaccorot/0007/0007.py | #!/usr/bin/python
#coding:utf-8
"""
第 0007 题:有个目录,里面是你自己写过的程序,统计一下你写过多少行代码。包括空行和注释,但是要分别列出来。
"""
import os
def walk_dir(path):
file_path = []
for root, dirs, files in os.walk(path):
for f in files:
if f.lower().endswith('py'):
file_path.append(os.path.join(root, f))
re... | mit | Python | |
f8093f59b77e481231aeca49ef057a4602d21b2e | add tests for appconfig | artefactual/archivematica,artefactual/archivematica,artefactual/archivematica,artefactual/archivematica | src/archivematicaCommon/tests/test_appconfig.py | src/archivematicaCommon/tests/test_appconfig.py | from __future__ import absolute_import
import os
import StringIO
from django.core.exceptions import ImproperlyConfigured
import pytest
from appconfig import Config
CONFIG_MAPPING = {
'search_enabled': [
{'section': 'Dashboard', 'option': 'disable_search_indexing', 'type': 'iboolean'},
{'section'... | agpl-3.0 | Python | |
06dd6ed476549d832159b1dbfe4d415579b4d067 | add wrapper | fontify/fontify,fontify/fontify,fontify/fontify,fontify/fontify | scripts/fontify.py | scripts/fontify.py | #!/usr/bin/env python2
import argparse
import tempfile
import shutil
import os
import crop_image
def check_input(image):
if not os.path.isfile(image):
raise FileNotFoundError
_, ext = os.path.splitext(image)
if ext.lower() not in [".jpg", ".png"]:
raise ValueError("Unrecognized image exten... | mit | Python | |
5509839e0af89467eb14ee178807e2898202101b | Add port-security extension API test cases | skyddv/neutron,neoareslinux/neutron,barnsnake351/neutron,dims/neutron,jerryz1982/neutron,mandeepdhami/neutron,SamYaple/neutron,wenhuizhang/neutron,suneeth51/neutron,glove747/liberty-neutron,JianyuWang/neutron,mahak/neutron,dhanunjaya/neutron,sebrandon1/neutron,wolverineav/neutron,openstack/neutron,jumpojoy/neutron,bigs... | neutron/tests/api/test_extension_driver_port_security.py | neutron/tests/api/test_extension_driver_port_security.py | # Copyright 2015 OpenStack Foundation
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless requ... | apache-2.0 | Python | |
6ca1d9f4a3b8a518661409166a9918a20eb61655 | fix wansu cdn url | gravyboat/streamlink,streamlink/streamlink,streamlink/streamlink,chhe/streamlink,bastimeyer/streamlink,melmorabity/streamlink,javiercantero/streamlink,gravyboat/streamlink,chhe/streamlink,melmorabity/streamlink,back-to/streamlink,beardypig/streamlink,javiercantero/streamlink,bastimeyer/streamlink,beardypig/streamlink,b... | src/streamlink/plugins/app17.py | src/streamlink/plugins/app17.py | import re
from streamlink.plugin import Plugin
from streamlink.plugin.api import http, useragents
from streamlink.stream import HLSStream, RTMPStream, HTTPStream
API_URL = "https://api-dsa.17app.co/api/v1/liveStreams/getLiveStreamInfo"
_url_re = re.compile(r"https://17.live/live/(?P<channel>[^/&?]+)")
_status_re = r... | import re
from streamlink.plugin import Plugin
from streamlink.plugin.api import http, useragents
from streamlink.stream import HLSStream, RTMPStream, HTTPStream
API_URL = "https://api-dsa.17app.co/api/v1/liveStreams/getLiveStreamInfo"
_url_re = re.compile(r"https://17.live/live/(?P<channel>[^/&?]+)")
_status_re = r... | bsd-2-clause | Python |
7f51b7a1b6a319595df5c360bae0264386e590e9 | add support for tucao.cc | cnbeining/you-get,lilydjwg/you-get,j4s0nh4ck/you-get,runningwolf666/you-get,chares-zhang/you-get,cnbeining/you-get,qzane/you-get,flwh/you-get,zmwangx/you-get,specter4mjy/you-get,smart-techs/you-get,pastebt/you-get,Red54/you-get,smart-techs/you-get,rain1988/you-get,dream1986/you-get,pitatensai/you-get,FelixYin66/you-get... | src/you_get/extractors/tucao.py | src/you_get/extractors/tucao.py | #!/usr/bin/env python
__all__ = ['tucao_download']
from ..common import *
# import re
import random
import time
from xml.dom import minidom
#1. <li>type=tudou&vid=199687639</li>
#2. <li>type=tudou&vid=199506910|</li>
#3. <li>type=video&file=http://xiaoshen140731.qiniudn.com/lovestage04.flv|</li>
#4 may ? <li>type=vid... | mit | Python | |
617e6741a06fd63f22ec9b28090e39c120061a84 | Add the `vulnerability_tickets.py` sample security plugin to deny access to tickets with "security" or "vulnerability" in the `keywords` or `summary` fields. | moreati/trac-gitsvn,moreati/trac-gitsvn,exocad/exotrac,moreati/trac-gitsvn,dafrito/trac-mirror,dafrito/trac-mirror,exocad/exotrac,exocad/exotrac,moreati/trac-gitsvn,dokipen/trac,dafrito/trac-mirror,exocad/exotrac,dokipen/trac,dokipen/trac,dafrito/trac-mirror | sample-plugins/vulnerability_tickets.py | sample-plugins/vulnerability_tickets.py | from trac.core import *
from trac.config import ListOption
from trac.perm import IPermissionPolicy, IPermissionRequestor, PermissionSystem
from trac.ticket.model import Ticket
class SecurityTicketsPolicy(Component):
"""
Require the VULNERABILITY_VIEW permission to view any ticket with the words
"security"... | bsd-3-clause | Python | |
b8ab0280ffd76419b7418c39a9f0b9d8131a9d39 | Add merge migration | dimagi/commcare-hq,dimagi/commcare-hq,dimagi/commcare-hq,dimagi/commcare-hq,dimagi/commcare-hq | corehq/apps/users/migrations/0022_merge_20200814_2045.py | corehq/apps/users/migrations/0022_merge_20200814_2045.py | # Generated by Django 2.2.13 on 2020-08-14 20:45
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('users', '0021_add_view_apps_permission'),
('users', '0021_invitation_email_status'),
]
operations = [
]
| bsd-3-clause | Python | |
cff300eecbbf6189fe7fc9fe4fafd718b414c80e | add command to create root | avlach/univbris-ocf,avlach/univbris-ocf,avlach/univbris-ocf,avlach/univbris-ocf | src/python/expedient/clearinghouse/commands/management/commands/create_default_root.py | src/python/expedient/clearinghouse/commands/management/commands/create_default_root.py | '''Command to create default administrators.
Created on Aug 26, 2010
@author: jnaous
'''
from django.core.management.base import NoArgsCommand
from django.conf import settings
from django.contrib.auth.models import User
class Command(NoArgsCommand):
help = "Creates the default root user specified by " \
... | bsd-3-clause | Python | |
760c0fb41ae9e6fd5307563b1cda6eaa8e6336af | add try order | sue-chain/sample | lab/try_order.py | lab/try_order.py | # -*- coding: utf-8 -*-
# pylint: disable=broad-except
"""try except return finally 执行顺序
无论except是否执行,finally都会执行,且最后执行
无论try except是否有return(有return时,程序暂存返回值),finally都会执行, 且最后执行
except, finally中return,则会覆盖之前暂存的返回值, so,不要在finally中写return
"""
import logging
__authors__ = ['"sue.chain" <sue.chain@gmail.com>']
loggi... | apache-2.0 | Python | |
787f956539eb5e41467e04b8239ae571fad60da7 | Implement code to return how many characters to delete to make 2 strings into an anagram | arvinsim/hackerrank-solutions | all-domains/tutorials/cracking-the-coding-interview/strings-making-anagrams/solution.py | all-domains/tutorials/cracking-the-coding-interview/strings-making-anagrams/solution.py | # https://www.hackerrank.com/challenges/ctci-making-anagrams
# Python 3
def delete_char_at(s, i):
return s[:i] + s[i+1:]
def number_needed(a, b):
counter = 0
loop_over, reference = (a, b) if len(a) > len(b) else (b, a)
for character in loop_over:
index = reference.find(character)
if i... | mit | Python | |
fe088ec159b4b395bcf463cf7ff31db7f7409fcf | Move czml utils computation to core | poliastro/poliastro | src/poliastro/core/czml_utils.py | src/poliastro/core/czml_utils.py | import numpy as np
from numba import njit as jit
@jit
def intersection_ellipsoid_line(x, y, z, u1, u2, u3, a, b, c):
"""Intersection of an ellipsoid defined by its axes a, b, c with the
line p + λu.
Parameters
----------
x, y, z: float
A point of the line
u1, u2, u3: float
The... | mit | Python | |
b906082034822a825ec2963864b32d6619cf938a | Add testing functions for join and relabel | pratapvardhan/scikit-image,oew1v07/scikit-image,paalge/scikit-image,GaZ3ll3/scikit-image,emon10005/scikit-image,rjeli/scikit-image,youprofit/scikit-image,ajaybhat/scikit-image,pratapvardhan/scikit-image,warmspringwinds/scikit-image,ofgulban/scikit-image,SamHames/scikit-image,chintak/scikit-image,vighneshbirodkar/scikit... | skimage/segmentation/tests/test_join.py | skimage/segmentation/tests/test_join.py | import numpy as np
from numpy.testing import assert_array_equal, assert_raises
from skimage.segmentation import join_segmentations, relabel_from_one
def test_join_segmentations():
s1 = np.array([[0, 0, 1, 1],
[0, 2, 1, 1],
[2, 2, 2, 1]])
s2 = np.array([[0, 1, 1, 0],
... | bsd-3-clause | Python | |
6b38f963cf555576157f063e9c026a94814f93a2 | Fix all target for managed install. | hgl888/chromium-crosswalk-efl,Just-D/chromium-1,mogoweb/chromium-crosswalk,axinging/chromium-crosswalk,Chilledheart/chromium,crosswalk-project/chromium-crosswalk-efl,Pluto-tv/chromium-crosswalk,PeterWangIntel/chromium-crosswalk,ChromiumWebApps/chromium,patrickm/chromium.src,Chilledheart/chromium,anirudhSK/chromium,mogo... | build/android/tests/multiple_proguards/multiple_proguards.gyp | build/android/tests/multiple_proguards/multiple_proguards.gyp | # Copyright (c) 2013 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.
{
'variables': {
'chromium_code': 1,
'package_name': 'multiple_proguard',
},
'targets': [
{
'target_name': 'multiple_proguards_tes... | # Copyright (c) 2013 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.
{
'variables': {
'chromium_code': 1,
'package_name': 'multiple_proguard',
},
'targets': [
{
'target_name': 'multiple_proguards_tes... | bsd-3-clause | Python |
c8bcdf4d586277df940b8fd9f977cd72305b5e85 | add StatusReportView | byteweaver/django-skrill | skrill/views.py | skrill/views.py | from django import http
from django.views.generic.base import View
from skrill.models import PaymentRequest, StatusReport
class StatusReportView(View):
def post(self, request, *args, **kwargs):
payment_request = PaymentRequest.objects.get(pk=request.POST['transaction_id'])
report = StatusReport()... | bsd-3-clause | Python | |
12c3ded4ed05e34a0a44163abd5ae08ab0289c4c | Create Score-Calculator.py | 3xbun/elab-cpe | Score-Calculator.py | Score-Calculator.py | midterm = float(input())
if midterm >= 0:
if midterm <= 60:
final = float(input())
if final >= 0:
if final <= 60:
total = midterm + final
avg = total/2
print('Total: ' + str(total))
print('Average: ' + str(avg))
| mit | Python | |
3b0fdecb60b9c5e8a104564d5703c85c97c10f27 | Introduce an ExtruderStack class | fieldOfView/Cura,ynotstartups/Wanhao,hmflash/Cura,hmflash/Cura,fieldOfView/Cura,ynotstartups/Wanhao,Curahelper/Cura,Curahelper/Cura | cura/Settings/ExtruderStack.py | cura/Settings/ExtruderStack.py | # Copyright (c) 2017 Ultimaker B.V.
# Cura is released under the terms of the AGPLv3 or higher.
from UM.MimeTypeDatabase import MimeType, MimeTypeDatabase
from UM.Settings.ContainerStack import ContainerStack
from UM.Settings.ContainerRegistry import ContainerRegistry
class ExtruderStack(ContainerStack):
def __in... | agpl-3.0 | Python | |
1e996e3cf1c8e067bbbb8bf23f93b34202b4cd44 | add 401 | aenon/OnlineJudge,aenon/OnlineJudge | leetcode/1.Array_String/401.BinaryWatch.py | leetcode/1.Array_String/401.BinaryWatch.py | # 401. Binary Watch
# A binary watch has 4 LEDs on the top which represent the hours (0-11), and the 6 LEDs on the bottom represent the minutes (0-59).
# Each LED represents a zero or one, with the least significant bit on the right.
# off off on on
# off on on off off ... | mit | Python | |
5712da6095594360be9010b0fe6b85606ec1e2d0 | Add regression test for #891 | oroszgy/spaCy.hu,recognai/spaCy,aikramer2/spaCy,spacy-io/spaCy,spacy-io/spaCy,aikramer2/spaCy,Gregory-Howard/spaCy,explosion/spaCy,oroszgy/spaCy.hu,oroszgy/spaCy.hu,oroszgy/spaCy.hu,honnibal/spaCy,recognai/spaCy,recognai/spaCy,aikramer2/spaCy,spacy-io/spaCy,honnibal/spaCy,Gregory-Howard/spaCy,explosion/spaCy,explosion/... | spacy/tests/regression/test_issue891.py | spacy/tests/regression/test_issue891.py | # coding: utf8
from __future__ import unicode_literals
import pytest
@pytest.mark.xfail
@pytest.mark.parametrize('text', ["want/need"])
def test_issue891(en_tokenizer, text):
"""Test that / infixes are split correctly."""
tokens = en_tokenizer(text)
assert len(tokens) == 3
assert tokens[1].text == "/"... | mit | Python | |
d11ac35410252c108dcd7e8d2ae03df2abc4697b | add statsquid cli util | bcicen/statsquid | statsquid/statsquid.py | statsquid/statsquid.py | #!/usr/bin/env python
import os,sys,logging,signal
from argparse import ArgumentParser
#from . import __version__
from listener import StatListener
from collector import StatCollector
__version__ = 'alpha'
log = logging.getLogger('statsquid')
class StatSquid(object):
"""
StatSquid
params:
- role(st... | mit | Python | |
59160eeb24f6311dafce2db34a40f8ba879fd516 | Add test showing taint for attr store | github/codeql,github/codeql,github/codeql,github/codeql,github/codeql,github/codeql,github/codeql,github/codeql,github/codeql,github/codeql,github/codeql,github/codeql,github/codeql,github/codeql,github/codeql | python/ql/test/experimental/dataflow/tainttracking/defaultAdditionalTaintStep/test_attr.py | python/ql/test/experimental/dataflow/tainttracking/defaultAdditionalTaintStep/test_attr.py | # Add taintlib to PATH so it can be imported during runtime without any hassle
import sys; import os; sys.path.append(os.path.dirname(os.path.dirname((__file__))))
from taintlib import *
# This has no runtime impact, but allows autocomplete to work
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from ..taintlib... | mit | Python | |
4dbeb72f8c07bcb5e91c71792651b448142beff9 | add script for wrapping shell commands and sending the result to datadog as events | DataDog/dogapi,DataDog/dogapi | src/dogapi/wrap.py | src/dogapi/wrap.py | import sys
import subprocess
import time
from StringIO import StringIO
from optparse import OptionParser
from dogapi import dog_http_api as dog
from dogapi.common import get_ec2_instance_id
class Timeout(Exception): pass
def poll_proc(proc, sleep_interval, timeout):
start_time = time.time()
returncode = None... | bsd-3-clause | Python | |
1f92af62d1a58e496c2ce4251676fca3b571e8f1 | Add missing specification model tests | ismailsunni/healthsites,ismailsunni/healthsites,ismailsunni/healthsites,ismailsunni/healthsites | django_project/localities/tests/test_model_Specification.py | django_project/localities/tests/test_model_Specification.py | # -*- coding: utf-8 -*-
from django.test import TestCase
from django.db import IntegrityError
from .model_factories import (
SpecificationF,
DomainF,
AttributeF
)
class TestModelSpecification(TestCase):
def test_model_repr(self):
dom = DomainF.create(id=1, name='A domain')
attr = Att... | bsd-2-clause | Python | |
15298dd59aabd817b3b160910b423d3448c9e189 | Test for overriding __import__. | pfalcon/micropython,pfalcon/micropython,pfalcon/micropython,pfalcon/micropython,pfalcon/micropython | tests/import/import_override.py | tests/import/import_override.py | import import1b
assert import1b.var == 123
import builtins
org_import = builtins.__import__
def my_import(*args):
# MicroPython currently doesn't pass globals/locals, so don't print them
# CPython3.5 and lower for "from pkg.mod import foo" appear to call
# __import__ twice - once with 5 args, and once ... | mit | Python | |
02bf100a05ed6267ab3fb618c52150fc2d4884f2 | Add some basic tests around contact parsing | Eyepea/aiosip,sangoma/aiosip | tests/test_contact_parsing.py | tests/test_contact_parsing.py | import aiosip
def test_simple_header():
header = aiosip.Contact.from_header('<sip:pytest@127.0.0.1:7000>')
assert not header['name']
assert dict(header['params']) == {}
assert dict(header['uri']) == {'scheme': 'sip',
'user': 'pytest',
... | apache-2.0 | Python | |
f5720f2609bcb19ffca308a3589c8e6171d1f8b7 | Add test cases for removepunctuation | sknorr/suse-doc-style-checker,sknorr/suse-doc-style-checker,sknorr/suse-doc-style-checker | tests/test_removepunctuation.py | tests/test_removepunctuation.py | #
import pytest
from sdsc.textutil import removepunctuation
@pytest.mark.parametrize("end", [True, False])
@pytest.mark.parametrize("start", [True, False])
@pytest.mark.parametrize("data", [
# 0 - no quotes
'word',
# 1 - single quote at the start
'¸word',
# 2 - single quote at the end
'word... | lgpl-2.1 | Python | |
e8309903b54598358efc20092760fe933cbd8ce7 | check if a string is a permutation of anohter string | HeyIamJames/CodingInterviewPractice,HeyIamJames/CodingInterviewPractice | CrackingCodingInterview/1.3_string_permutation.py | CrackingCodingInterview/1.3_string_permutation.py | """
check if a string is a permutation of anohter string
"""
#utalize sorted, perhaps check length first to make faster
| mit | Python | |
6dde05fc401ff615b44dc101bfb7775c65535e79 | Create 2.6_circularlinkedlist.py | HeyIamJames/CodingInterviewPractice,HeyIamJames/CodingInterviewPractice | CrackingCodingInterview/2.6_circularlinkedlist.py | CrackingCodingInterview/2.6_circularlinkedlist.py | """
return node at begining of a cricularly linked list
"""
| mit | Python | |
3d64d0be14ea93f53303ead80dcb024c9f8d4b2d | Create save_course_source.py | StepicOrg/Stepic-API | examples/save_course_source.py | examples/save_course_source.py | # Run with Python 3
# Saves all step sources into foldered structure
import os
import json
import requests
import datetime
# Enter parameters below:
# 1. Get your keys at https://stepic.org/oauth2/applications/
# (client type = confidential, authorization grant type = client credentials)
client_id = "..."
client_secre... | mit | Python | |
cb2deafae258625f0c4ec8bb68713b391129a27c | add migration of help text changes | bruecksen/isimip,bruecksen/isimip,bruecksen/isimip,bruecksen/isimip | isi_mip/climatemodels/migrations/0085_auto_20180215_1105.py | isi_mip/climatemodels/migrations/0085_auto_20180215_1105.py | # -*- coding: utf-8 -*-
# Generated by Django 1.10.8 on 2018-02-15 10:05
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('climatemodels', '0084_inputdata_protocol_relation'),
]
... | mit | Python | |
32a7839072f073268f1a90b3521847e59b8ed522 | add logging03.py | devlights/try-python | trypython/stdlib/logging03.py | trypython/stdlib/logging03.py | """
logging モジュールのサンプルです。
最も基本的な使い方について (フォーマッタの指定)
"""
import logging
from trypython.common.commoncls import SampleBase
class Sample(SampleBase):
def exec(self):
"""サンプル処理を実行します。"""
# -----------------------------------------------------------------------------------
# logging モジュールは、pyt... | mit | Python | |
5fa3fc6ba78c3e6cf12a25bddb835e9d885bcbd3 | Create 0035_auto_20190712_2015.py | BirkbeckCTP/janeway,BirkbeckCTP/janeway,BirkbeckCTP/janeway,BirkbeckCTP/janeway | src/submission/migrations/0035_auto_20190712_2015.py | src/submission/migrations/0035_auto_20190712_2015.py | # -*- coding: utf-8 -*-
# Generated by Django 1.11.21 on 2019-07-12 19:15
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('submission', '0034_auto_20190416_1009'),
]
operations = [
migrations.Alter... | agpl-3.0 | Python | |
e0229179b01805ca7f7e23d3094737a4f366e162 | Add missing files for d8af78447f286ad07ad0736d4202e0becd0dd319 | devunt/hydrocarbon,devunt/hydrocarbon,devunt/hydrocarbon | board/migrations/0001_initial.py | board/migrations/0001_initial.py | # -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
from django.conf import settings
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
migrations.Create... | mit | Python | |
f8c79535d52384a4891ad56125033d69938d987d | Create get_url.py | a67878813/script,a67878813/script | get_url.py | get_url.py |
# coding: utf-8
# In[53]:
#huoqu Url
import requests
import re
import os
#下面三行是编码转换的功能
import sys
#hea是我们自己构造的一个字典,里面保存了user-agent。
#让目标网站误以为本程序是浏览器,并非爬虫。
#从网站的Requests Header中获取。【审查元素】
hea = {'User-Agent':'Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41... | apache-2.0 | Python | |
2a502236de5c28d4f4e6626317565c7bb60ebb13 | Create NumberofDigitOne_001.py | cc13ny/algo,Chasego/codi,cc13ny/Allin,Chasego/codirit,cc13ny/Allin,cc13ny/Allin,Chasego/cod,Chasego/codi,Chasego/cod,Chasego/codirit,Chasego/cod,Chasego/codirit,cc13ny/algo,Chasego/cod,cc13ny/Allin,cc13ny/algo,Chasego/codirit,Chasego/codirit,Chasego/codi,cc13ny/algo,Chasego/codi,Chasego/cod,Chasego/codi,cc13ny/Allin,cc... | leetcode/233-Number-of-Digit-One/NumberofDigitOne_001.py | leetcode/233-Number-of-Digit-One/NumberofDigitOne_001.py | class Solution:
# @param {integer} n
# @return {integer}
def countDigitOne(self, n):
res, d = 0, 10
while 10 * n >= d:
t = d / 10
r = n % d
res += n / d * t
if t - 1 < r < 2 * t - 1:
res += r - t + 1
elif 2 * t - 1 <... | mit | Python | |
052dbe05c0e1d3e2821857a035e469be2a1055ae | Add "what is my purpose in life" plugin | ratchetrobotics/espresso | plugins/pass_the_butter.py | plugins/pass_the_butter.py | from espresso.main import robot
@robot.respond(r"(?i)pass the butter")
def pass_the_butter(res):
res.reply(res.msg.user, "What is my purpose in life?")
@robot.respond(r"(?i)you pass butter")
def you_pass_butter(res):
res.send("Oh my god.")
| bsd-3-clause | Python | |
84a2e9db13b49d8afd1c1bcf5ec5ce9b92c14046 | Add a snippet. | jeremiedecock/snippets,jeremiedecock/snippets,jeremiedecock/snippets,jeremiedecock/snippets,jeremiedecock/snippets,jeremiedecock/snippets,jeremiedecock/snippets,jeremiedecock/snippets,jeremiedecock/snippets,jeremiedecock/snippets,jeremiedecock/snippets,jeremiedecock/snippets,jeremiedecock/snippets | python/pyside/pyside6/widget_QSqlTableModel_sqlite_from_file_with_sort_and_filter_plus_add_and_remove_rows.py | python/pyside/pyside6/widget_QSqlTableModel_sqlite_from_file_with_sort_and_filter_plus_add_and_remove_rows.py | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Ref: https://doc.qt.io/qtforpython/PySide6/QtSql/QSqlTableModel.html?highlight=qsqltablemodel
import sys
import sqlite3
from PySide6 import QtCore, QtWidgets
from PySide6.QtCore import Qt, QSortFilterProxyModel, QModelIndex
from PySide6.QtWidgets import QApplication, ... | mit | Python | |
5b57686868b595fb4e7b431822fe4c7bf2de6cfb | Add unittests for title handling methods | Commonists/MassUploadLibrary | test/test_uploadbot.py | test/test_uploadbot.py | #!/usr/bin/env python
# -*- coding: latin-1 -*-
"""Unit tests."""
import unittest
from uploadlibrary.UploadBot import _cut_title
class TestUploadBot(unittest.TestCase):
"""Testing UploadBot methods."""
def test_cut_title_witout_cutting(self):
"""Test _cut_title() without cutting"""
inputs ... | mit | Python | |
b15c7c044b0c514285bcb8c29b7bcfc8cf777c8b | Add tests for the signals | educreations/django-ormcache | ormcache/tests/test_signals.py | ormcache/tests/test_signals.py | from django.core.cache import cache
from django.test import SimpleTestCase
from ormcache.signals import cache_hit, cache_missed, cache_invalidated
from ormcache.tests.testapp.models import CachedDummyModel
class SignalsTestCase(SimpleTestCase):
def setUp(self):
self.signal_called = False
self.in... | mit | Python | |
f07cdf5bd22dd352122d679a6e8c4cc213aad013 | Create multiarm_selector.py | shauryashahi/final-year-project,shauryashahi/final-year-project | multiarm_selector.py | multiarm_selector.py | from __future__ import division
import random
class MultiarmSelector(object):
def __init__(self):
self.versions_served = []
self.clicks = 0
self.missed = 0
self.success_count = {
"A": 0,
"B": 0
}
self.total_count = {
"A": 0,
... | apache-2.0 | Python | |
bf2cc99162389c6b5c18051f01756e17d9d11ce6 | Add a test for rename. | stratis-storage/stratis-cli,stratis-storage/stratis-cli | tests/integration/test_rename.py | tests/integration/test_rename.py | """
Test 'rename'.
"""
import subprocess
import unittest
from ._constants import _CLI
from ._misc import Service
@unittest.skip("Wating for Rename")
class Rename1TestCase(unittest.TestCase):
"""
Test 'rename' when pool is non-existant.
"""
_MENU = ['rename']
_POOLNAME = 'deadpool'
_NEW_POOL... | apache-2.0 | Python | |
4d661b0fcb6f4b130370c010d16a2afec2449456 | Create mergesort.py | ueg1990/aids | aids/sorting_and_searching/mergesort.py | aids/sorting_and_searching/mergesort.py | '''
In this module, we implement merge sort
Time complexity: O(n * log n)
'''
def mergesort(arr):
'''
Sort array using mergesort
'''
pass
def _merge(arr):
pass
| mit | Python | |
d199510ab03975832b262cbc2160c3d6f3371e8d | Add solution in Python | julianespinel/training,julianespinel/training,julianespinel/training,julianespinel/trainning,julianespinel/trainning,julianespinel/training | codeforces/dominated_subarray.py | codeforces/dominated_subarray.py | def read_first_line():
return int(input())
def read_cases(number_of_cases):
cases = []
for i in range(number_of_cases):
line = input()
if i % 2 == 1:
case = [int(string) for string in line.strip().split(' ')]
cases.append(case)
return cases
def updateHistory(i... | mit | Python | |
6a8ff154b8468d61b18d390db9e710fc0b224ac7 | Add Left-Handed toons crawler | datagutten/comics,datagutten/comics,jodal/comics,klette/comics,jodal/comics,klette/comics,datagutten/comics,jodal/comics,datagutten/comics,klette/comics,jodal/comics | comics/comics/lefthandedtoons.py | comics/comics/lefthandedtoons.py |
from comics.aggregator.crawler import CrawlerBase, CrawlerResult
from comics.meta.base import MetaBase
class Meta(MetaBase):
name = 'Left-Handed Toons'
language = 'en'
url = 'http://www.lefthandedtoons.com/'
start_date = '2007-01-14'
rights = 'Justin & Drew'
class Crawler(CrawlerBase):
histor... | agpl-3.0 | Python | |
59e8fe848da5cfa3874c82776205082764efbe63 | Enable Jenkins Python3 monster for i19 | xia2/i19 | tests/test_python3_regression.py | tests/test_python3_regression.py | from __future__ import absolute_import, division, print_function
def test_no_new_python3_incompatible_code_is_introduced_into_this_module():
import i19
import pytest
import dials.test.python3_regression as py3test
result = py3test.find_new_python3_incompatible_code(i19)
if result is None:
pytest.skip('No... | bsd-3-clause | Python | |
0c3f3c444d863ec4acff704efee71a29ab8cdf34 | Add ip_reverse module | synthesio/infra-ovh-ansible-module | plugins/modules/ip_reverse.py | plugins/modules/ip_reverse.py | #!/usr/bin/python
from __future__ import (absolute_import, division, print_function)
from ansible.module_utils.basic import AnsibleModule
__metaclass__ = type
DOCUMENTATION = '''
---
module: ip_reverse
short_description: Modify reverse on IP
description:
- Modify reverse on IP
author: Synthesio SRE Team
requirem... | mit | Python | |
c208263dcc40078e48f78565b37be7b601f0d817 | Add Python wrappers for the bibtex program. | live-clones/pybtex | pybtex/tests/run_bibtex.py | pybtex/tests/run_bibtex.py | #!/usr/bin/env python
# Copyright (C) 2006, 2007, 2008, 2009 Andrey Golovizin
#
# This program 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 option) any late... | mit | Python | |
c5ac422ff1e4628ad8ea53e4f1442e6a70bf959f | add first command test | edouard-lopez/rangevoting,guillaumevincent/rangevoting,guillaumevincent/rangevoting,edouard-lopez/rangevoting,edouard-lopez/rangevoting,guillaumevincent/rangevoting | tests/test_commands.py | tests/test_commands.py | import unittest
class CreateRangeVotingCommand():
def __init__(self, question, choices):
self.question = question
self.choices = choices
class CreateRangeVotingCommandTestCase(unittest.TestCase):
def test_has_choices_and_question(self):
question = 'Question ?'
choices = ['a',... | mit | Python | |
391e145b6e82aaa87e2ab23cfea53cb7ae98bc2a | Add a work-in-progress parser for the ClientHello message. | Ayrx/tlsenum,Ayrx/tlsenum | tlsenum/parse_hello.py | tlsenum/parse_hello.py | import construct
from tlsenum import hello_constructs
class ClientHello(object):
@property
def protocol_version(self):
return self._protocol_version
@protocol_version.setter
def protocol_version(self, protocol_version):
assert protocol_version in ["3.0", "1.0", "1.1", "1.2"]
... | mit | Python | |
764bad33b598841333d4d1674bf5667957ada551 | Add a no-op measurement | ondra-novak/chromium.src,patrickm/chromium.src,hgl888/chromium-crosswalk-efl,chuan9/chromium-crosswalk,axinging/chromium-crosswalk,dushu1203/chromium.src,Pluto-tv/chromium-crosswalk,anirudhSK/chromium,chuan9/chromium-crosswalk,littlstar/chromium.src,hgl888/chromium-crosswalk-efl,ChromiumWebApps/chromium,mohamed--abdel-... | tools/perf/measurements/no_op.py | tools/perf/measurements/no_op.py | # Copyright 2013 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.
from telemetry.page import page_measurement
class NoOp(page_measurement.PageMeasurement):
def __init__(self):
super(NoOp, self).__init__('no_op')
d... | bsd-3-clause | Python | |
a704a1964659a45b007e696ed1547b563dcffa4f | create 2.py | wenpingzheng/new_test | 2.py | 2.py | # content
| mit | Python | |
a1db6c4379c787124d7ee825adbcc76d2069a3c6 | Add check to travis to make sure new boards are built, fix #1886 | adafruit/micropython,adafruit/circuitpython,adafruit/circuitpython,adafruit/circuitpython,adafruit/micropython,adafruit/micropython,adafruit/circuitpython,adafruit/circuitpython,adafruit/circuitpython,adafruit/micropython,adafruit/micropython | tools/travis_new_boards_check.py | tools/travis_new_boards_check.py | #! /usr/bin/env python3
import os
import re
import json
import build_board_info
# Get boards in json format
boards_info_json = build_board_info.get_board_mapping()
# print(boards_info_json)
# TODO (Carlos) Find all the boards on the json format
# We need to know the path of the .travis.yml file
base_path = os.path... | mit | Python | |
9a1c9e2cbe7f9b9decbe93d567458b6a6976e420 | complete 14 longest collatz sequence | dawran6/project-euler | 14-longest-collatz-sequence.py | 14-longest-collatz-sequence.py | from functools import lru_cache
def sequence(n):
'bad idea'
while n is not 1:
yield n
n = 3*n+1 if n%2 else n/2
yield n
def next_num(n):
if n % 2:
return 3 * n + 1
else:
return n / 2
@lru_cache(None)
def collatz_length(n):
if n == 1:
return 1
else:
... | mit | Python | |
aa301d8eaa3c3f89154103bce882501164756017 | Implement the ADMIN command | Heufneutje/txircd,ElementalAlchemist/txircd | txircd/modules/rfc/cmd_admin.py | txircd/modules/rfc/cmd_admin.py | from twisted.plugin import IPlugin
from twisted.words.protocols import irc
from txircd.module_interface import Command, ICommand, IModuleData, ModuleData
from zope.interface import implements
irc.RPL_ADMINLOC1 = "257"
irc.RPL_ADMINLOC2 = "258"
class AdminCommand(ModuleData):
implements(IPlugin, IModuleData)
... | bsd-3-clause | Python | |
3f5a752a7978c2432ce3106492d771c00a5f1279 | Create geo.py | voidabhi/python-scripts,voidabhi/python-scripts,voidabhi/python-scripts,voidabhi/python-scripts,voidabhi/python-scripts | geo.py | geo.py | import requests
def example():
# grab some lat/long coords from wherever. For this example,
# I just opened a javascript console in the browser and ran:
#
# navigator.geolocation.getCurrentPosition(function(p) {
# console.log(p);
# })
#
latitude = 35.1330343
longitude = -90.06250... | mit | Python | |
30debe34005280517f56795e1f0852dccf3cb7f2 | Add hip module computing hipster rank for a route | kynan/GetLost | hip.py | hip.py | import numpy as np
from numpy import sin, cos, sqrt
import pandas as pd
from sklearn.neighbors import KDTree
fs_df = pd.read_csv('fs.csv')
fs_df.lat = fs_df.lat.apply(float)
fs_df.lng = fs_df.lng.apply(float)
def get_nearby(start, end, dist_meters=50):
x0, y0 = start
x1, y1 = end
dx, dy = x1 - x0, y1 - y... | apache-2.0 | Python | |
1110311ef90a45497af4cdfb8558d1b05fc799d0 | add a script to run the server | DevMine/devmine-core | run.py | run.py | #!/usr/bin/env python
# coding: utf-8
import bottle
from logging import info
from devmine import Devmine
from devmine.config import (
environment,
settings
)
def main():
info('Devmine server started')
db_url = settings.db_url
server = settings.server
if not db_url:
db_url = environme... | bsd-3-clause | Python | |
e007695e38b2207c9229856c95f37a12e740cb91 | Add view demographics tests | renalreg/radar,renalreg/radar,renalreg/radar,renalreg/radar | radar/tests/permissions/test_can_user_view_demographics.py | radar/tests/permissions/test_can_user_view_demographics.py | from radar.permissions import can_user_view_demographics
from radar.roles import COHORT_RESEARCHER, COHORT_SENIOR_RESEARCHER, ORGANISATION_CLINICIAN
from helpers.permissions import make_cohorts, make_user, make_patient, make_organisations
def test_admin():
patient = make_patient()
user = make_user()
asse... | agpl-3.0 | Python | |
a46f2b8e42852b3c51d31c9402328c82d5d1f78c | Create new package. (#8144) | mfherbst/spack,mfherbst/spack,tmerrick1/spack,iulian787/spack,LLNL/spack,LLNL/spack,LLNL/spack,LLNL/spack,mfherbst/spack,mfherbst/spack,krafczyk/spack,matthiasdiener/spack,matthiasdiener/spack,iulian787/spack,iulian787/spack,tmerrick1/spack,matthiasdiener/spack,tmerrick1/spack,krafczyk/spack,krafczyk/spack,iulian787/sp... | var/spack/repos/builtin/packages/swap-assembler/package.py | var/spack/repos/builtin/packages/swap-assembler/package.py | ##############################################################################
# Copyright (c) 2013-2018, Lawrence Livermore National Security, LLC.
# Produced at the Lawrence Livermore National Laboratory.
#
# This file is part of Spack.
# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.
# LLNL-CODE-64... | lgpl-2.1 | Python | |
2904992eb431ac4a92442ccb1fcff5715ae8c7fa | add migrations for new policy parameters | OpenSourcePolicyCenter/webapp-public,OpenSourcePolicyCenter/webapp-public,OpenSourcePolicyCenter/webapp-public,OpenSourcePolicyCenter/PolicyBrain,OpenSourcePolicyCenter/PolicyBrain,OpenSourcePolicyCenter/webapp-public,OpenSourcePolicyCenter/PolicyBrain,OpenSourcePolicyCenter/PolicyBrain | webapp/apps/taxbrain/migrations/0035_auto_20161110_1624.py | webapp/apps/taxbrain/migrations/0035_auto_20161110_1624.py | # -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
import webapp.apps.taxbrain.models
class Migration(migrations.Migration):
dependencies = [
('taxbrain', '0034_auto_20161004_1953'),
]
operations = [
migrations.AddField(
... | mit | Python | |
b068e4f8c3e5e8d7a0f1c45d5f1b6ac424b44153 | Make validate recipients to ignore empty values | VinnieJohns/ggrc-core,kr41/ggrc-core,VinnieJohns/ggrc-core,josthkko/ggrc-core,edofic/ggrc-core,AleksNeStu/ggrc-core,selahssea/ggrc-core,NejcZupec/ggrc-core,selahssea/ggrc-core,edofic/ggrc-core,VinnieJohns/ggrc-core,edofic/ggrc-core,j0gurt/ggrc-core,selahssea/ggrc-core,AleksNeStu/ggrc-core,NejcZupec/ggrc-core,NejcZupec/... | src/ggrc/models/comment.py | src/ggrc/models/comment.py | # Copyright (C) 2015 Google Inc., authors, and contributors <see AUTHORS file>
# Licensed under http://www.apache.org/licenses/LICENSE-2.0 <see LICENSE file>
# Created By: andraz@reciprocitylabs.com
# Maintained By: andraz@reciprocitylabs.com
"""Module containing comment model and comment related mixins."""
from sqla... | # Copyright (C) 2015 Google Inc., authors, and contributors <see AUTHORS file>
# Licensed under http://www.apache.org/licenses/LICENSE-2.0 <see LICENSE file>
# Created By: andraz@reciprocitylabs.com
# Maintained By: andraz@reciprocitylabs.com
"""Module containing comment model and comment related mixins."""
from sqla... | apache-2.0 | Python |
8840340bbd8310cf03f12accbb51dd81921ccf86 | Fix use of `format` for unicode | kr41/ggrc-core,NejcZupec/ggrc-core,AleksNeStu/ggrc-core,vladan-m/ggrc-core,kr41/ggrc-core,prasannav7/ggrc-core,plamut/ggrc-core,jmakov/ggrc-core,j0gurt/ggrc-core,AleksNeStu/ggrc-core,VinnieJohns/ggrc-core,vladan-m/ggrc-core,jmakov/ggrc-core,vladan-m/ggrc-core,hasanalom/ggrc-core,vladan-m/ggrc-core,hasanalom/ggrc-core,h... | src/ggrc/models/request.py | src/ggrc/models/request.py | # Copyright (C) 2013 Google Inc., authors, and contributors <see AUTHORS file>
# Licensed under http://www.apache.org/licenses/LICENSE-2.0 <see LICENSE file>
# Created By: dan@reciprocitylabs.com
# Maintained By: vraj@reciprocitylabs.com
from ggrc import db
from .mixins import deferred, Base, Described
class Request(... | # Copyright (C) 2013 Google Inc., authors, and contributors <see AUTHORS file>
# Licensed under http://www.apache.org/licenses/LICENSE-2.0 <see LICENSE file>
# Created By: dan@reciprocitylabs.com
# Maintained By: vraj@reciprocitylabs.com
from ggrc import db
from .mixins import deferred, Base, Described
class Request(... | apache-2.0 | Python |
dbc761530b77c606038f62ed498c192b67321e8f | Test co2 load_data for Python 3. | nvoron23/statsmodels,wwf5067/statsmodels,wkfwkf/statsmodels,hainm/statsmodels,jstoxrocky/statsmodels,musically-ut/statsmodels,musically-ut/statsmodels,ChadFulton/statsmodels,ChadFulton/statsmodels,ChadFulton/statsmodels,bert9bert/statsmodels,cbmoore/statsmodels,alekz112/statsmodels,bsipocz/statsmodels,bashtage/statsmod... | statsmodels/datasets/tests/test_data.py | statsmodels/datasets/tests/test_data.py | from statsmodels.datasets import co2
def test_co2_python3():
# this failed in pd.to_datetime on Python 3 with pandas <= 0.12.0
dta = co2.load_pandas()
| bsd-3-clause | Python | |
299bb8bccf8485a12bc341cb45b2d2c82771f5dd | add pentagon import | xzrunner/easyeditor,xzrunner/easyeditor | pentagon_import/gen_pentagon.py | pentagon_import/gen_pentagon.py | import os
import math
SRC_POS = '46,562, 82,562, 82,526, 46,526'
FILE_NAME = '角色5围表.csv'
OUTPUT = 'pentagon.lua'
EDGE = 300
INDEX = 19
START_ID = 0
def rotate(src, rad, dst):
dst[0] = src[0] * math.cos(rad) - src[1] * math.sin(rad)
dst[1] = src[0] * math.sin(rad) + src[1] * math.cos(rad)
def gen_vertex(edge, da... | mit | Python | |
efc935b030750c26e24217d5f97dde1dc8a7ea66 | add script to clone mvn dependency to local from gradle | passos/scripts,passos/scripts,passos/scripts | python/mirror-mvn-dependency.py | python/mirror-mvn-dependency.py | #!/usr/bin/python
"""
This script is used to make a mirror maven repository from a gradle build
1. make sure your project can be build correctly
2. run this script in your project root directory
3. add following code to your gradle file
buildscript {
repositories {
maven { url "file://${rootProject.projectDir}/... | apache-2.0 | Python | |
1b2c67a0d4a237ce56dc40616b1a023b515aee0f | add setup.py | waliens/sldc | sldc/setup.py | sldc/setup.py | from distutils.core import setup
setup(name="sldc",
version="1.0",
description="Segment Locate Dispatch Classify workflow",
author="Romain Mormont",
author_email="romain.mormont@gmail.com",
)
| mit | Python | |
379d8b1fb828918f8d77b0acf0e270eb94e650e5 | Add example for `adapt_rgb` | paalge/scikit-image,keflavich/scikit-image,warmspringwinds/scikit-image,oew1v07/scikit-image,paalge/scikit-image,michaelaye/scikit-image,ajaybhat/scikit-image,GaZ3ll3/scikit-image,Hiyorimi/scikit-image,WarrenWeckesser/scikits-image,michaelpacer/scikit-image,youprofit/scikit-image,emon10005/scikit-image,Britefury/scikit... | doc/examples/plot_adapt_rgb.py | doc/examples/plot_adapt_rgb.py | """
=========================================
Adapting gray-scale filters to RGB images
=========================================
There are many filters that are designed work with gray-scale images but not
color images. To simplify the process of creating functions that can adapt to
RGB images, scikit-image provides ... | bsd-3-clause | Python | |
bb065a747215b6665eec78c5141b0a0d82296dac | Add migration to replace '<removed>' with '<removed>@{uuid}.com'.format(uuid=str(uuid4())) in contact_information.email to pass validation | alphagov/digitalmarketplace-api,alphagov/digitalmarketplace-api,alphagov/digitalmarketplace-api | migrations/versions/1400_repair_contact_information_emails_post_data_retention_removal.py | migrations/versions/1400_repair_contact_information_emails_post_data_retention_removal.py | """Replace '<removed>' with '<removed>@{uuid}.com'.format(uuid=str(uuid4())) in contact_information to pass validation.
Revision ID: 1400
Revises: 1390
Create Date: 2019-10-29 09:09:00.000000
"""
from uuid import uuid4
from alembic import op
import sqlalchemy as sa
from sqlalchemy.sql import table, column
# revisio... | mit | Python | |
434827540d4e11254615cd52b7efb36b746f9d0d | Create tf_simple_LR.py | maxlz/ML | tf_simple_LR.py | tf_simple_LR.py | # -*- coding: utf-8 -*-
"""
Created on Mon Aug 1 19:50:54 2016
@author: max
"""
import tensorflow as tf
import numpy as np
import matplotlib.pylab as m
x_data = np.linspace(0.0,1.0,num = 500,dtype='float32')
x_data = np.reshape(x_data,(500,))
y_data = np.linspace(0.0,1.0,num = 500,dtype='float32')
y_data = y_data ... | apache-2.0 | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.