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 |
|---|---|---|---|---|---|---|---|---|
198dc11cadc1a20f95dccd5bb4897fa2947ff810 | Add Affichage.py | SUPINFOLaboDev/TheSnake | Affichage.py | Affichage.py | class Affichage:
def affichage_jeux(self):
return 0
| mit | Python | |
abe6ead4f93f98406fe197b6884e51015c200ca1 | Add a test for query_result_to_dict | jeffweeksio/sir | test/test_searchentities.py | test/test_searchentities.py | import unittest
from . import models
from sir.schema.searchentities import SearchEntity as E, SearchField as F
class QueryResultToDictTest(unittest.TestCase):
def setUp(self):
self.entity = E(models.B, [
F("id", "id"),
F("c_bar", "c.bar"),
F("c_bar_trans", "c.bar", tra... | mit | Python | |
c1bbbd7ac51a25919512722d633f0d8c2d1009e2 | Create unit tests directory | open2c/cooltools | tests/test_lazy_toeplitz.py | tests/test_lazy_toeplitz.py | from scipy.linalg import toeplitz
import numpy as np
from cooltools.snipping import LazyToeplitz
n = 100
m = 150
c = np.arange(1, n+1)
r = np.r_[1,np.arange(-2, -m, -1)]
L = LazyToeplitz(c, r)
T = toeplitz(c, r)
def test_symmetric():
for si in [
slice(10, 20),
slice(0, 150),
... | mit | Python | |
c3026f4c6e5edff30347f544746781c7214c2c2e | Add root test file. | levilucio/SyVOLT,levilucio/SyVOLT | test_SM2SM.py | test_SM2SM.py | '''
Created on 2015-01-20
@author: levi
'''
'''
Created on 2015-01-19
@author: levi
'''
import unittest
from patterns.HSM2SM_matchLHS import HSM2SM_matchLHS
from patterns.HSM2SM_rewriter import HSM2SM_rewriter
from PyRamify import PyRamify
from t_core.messages import Packet
from t_core.iterator import Iterator
fro... | mit | Python | |
3c7c81fa65206ea70cbff8394efe35749dc9dddd | add bitquant.py driver | joequant/bitquant,joequant/bitquant,linkmax91/bitquant,joequant/bitquant,linkmax91/bitquant,linkmax91/bitquant,linkmax91/bitquant,linkmax91/bitquant,joequant/bitquant,linkmax91/bitquant,joequant/bitquant | web/bitquant.py | web/bitquant.py | from flask import Flask, request
app = Flask(__name__, static_url_path='', static_folder='bitquant')
@app.route("/")
def root():
return app.send_static_file('index.html')
if __name__ == "__main__":
app.run()
| bsd-2-clause | Python | |
58d3df14b1b60da772f59933345a2dfdf2cadec2 | Add python solution for day 17 | Mark-Simulacrum/advent-of-code-2015,Mark-Simulacrum/advent-of-code-2015,Mark-Simulacrum/advent-of-code-2015,Mark-Simulacrum/advent-of-code-2015 | day17/solution.py | day17/solution.py | import itertools
data = open("data", "r").read()
containers = map(int, data.split("\n"))
part1 = []
minLength = None
for length in range(len(containers)):
combinations = itertools.combinations(containers, length)
combinations = filter(lambda containers: sum(containers) == 150, combinations)
part1 += combinations... | mit | Python | |
88cfd7529c6c08e24b20576c1e40f41f3156a47e | add tandem sam scores script | BenLangmead/qtip-experiments,BenLangmead/qtip-experiments | bin/tandem_sam_scores.py | bin/tandem_sam_scores.py | """
tandem_sam_scores.py
For each alignment, compare the "target" simulated alignment score to the
actual score obtained by the aligner. When the read is simulated, we borrow
the target score and the pattern of mismatches and gaps from an input
alignment. But because the new read's sequence and point of origin are
d... | mit | Python | |
b4c21650cfd92d722a0ac20ea51d90f15adca44e | add permissions classes for Group API | amschaal/bioshare,amschaal/bioshare,amschaal/bioshare,amschaal/bioshare,amschaal/bioshare | bioshareX/permissions.py | bioshareX/permissions.py | from django.http.response import Http404
from rest_framework.permissions import DjangoModelPermissions, SAFE_METHODS
from django.contrib.auth.models import Group
class ViewObjectPermissions(DjangoModelPermissions):
def has_object_permission(self, request, view, obj):
if hasattr(view, 'get_queryset'):
... | mit | Python | |
43fe12c4dc2778e6c7a4b65dae587004a0ec0155 | rename plugin -> calico_rkt | alexhersh/calico-rkt-intial | calico_rkt/calico_rkt.py | calico_rkt/calico_rkt.py | #!/usr/bin/env python
from __future__ import print_function
import socket
from netaddr import IPAddress
from pycalico import datastore, netns
import functools
import json
import os
import sys
from subprocess import check_output, CalledProcessError
from pycalico.datastore_datatypes import Rules
from pycalico.netns impo... | apache-2.0 | Python | |
9557fc7696b182dd25f15bee85d522c22910bd90 | Add test for siingle camera. | microy/PyStereoVisionToolkit,microy/VisionToolkit,microy/VisionToolkit,microy/PyStereoVisionToolkit,microy/StereoVision,microy/StereoVision | camera-capture-1.py | camera-capture-1.py | #! /usr/bin/env python
# -*- coding:utf-8 -*-
#
# Application to capture images from two AVT Manta cameras with the Vimba SDK
#
#
# External dependencies
#
import ctypes
import os
import cv2
import numpy
import time
#
# Vimba frame structure
#
class VmbFrame( ctypes.Structure ) :
# VmbFrame structure fields
... | mit | Python | |
6e1d1da7983da2ca43a1185adc2ddb2e2e1b7333 | Add basic cycles exercices | MindCookin/python-exercises | chapter02/cicles.py | chapter02/cicles.py | #!/usr/bin/env python
print "Escribir un ciclo definido para imprimir por pantalla todos los numeros entre 10 y 20."
print [x for x in range(10, 20)]
print "Escribir un ciclo definido que salude por pantalla a sus cinco mejores amigos/as."
print [amigo for amigo in ['Lola', 'Dolores', 'Quique', 'Manuel', 'Manolo']]
... | apache-2.0 | Python | |
08c189a643f0b76ad28f9c0e0bc376a0ae202343 | Create nesting.py | py-in-the-sky/challenges,py-in-the-sky/challenges,py-in-the-sky/challenges | codility/nesting.py | codility/nesting.py | """
https://codility.com/programmers/task/nesting/
"""
def solution(S):
balance = 0
for char in S:
balance += (1 if char == '(' else -1)
if balance < 0:
return 0
return int(balance == 0)
| mit | Python | |
7055485e8c29c1002a0b3d9cb45cffef1bb5dc46 | Add script | sulir/simsycam | SimSyCam.py | SimSyCam.py | # SimSyCam - Simple Symbian Camera
import appuifw
appuifw.app.orientation='landscape' # must be called before importing camera
appuifw.app.screen='full'
from key_codes import *
import e32, time, camera, globalui, graphics
# variables used for mode change messages
info = u""
start_time = 0
# supportet modes
flash_m... | mit | Python | |
02b5ba55c854e5157ef5f65d3faa9bce960eced2 | Add pygments support. | rescrv/firmant | firmant/pygments.py | firmant/pygments.py | # Copyright (c) 2011, Robert Escriva
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of condition... | bsd-3-clause | Python | |
631aa503d1457f823cacd0642a1554ce8f31c1f9 | add jm server | Zex/juicemachine,Zex/juicemachine,Zex/juicemachine | python/jm_server.py | python/jm_server.py | #!/usr/bin/python
#
# jm_server.py
#
# Author: Zex <top_zlynch@yahoo.com>
#
import dbus
import dbus.service
from basic import *
class JuiceMachine(dbus.service.FallbackObject):
"""
JuiceMachine server
"""
def __init__(self):
connection = dbus.SessionBus()
connection_name = dbus.serv... | mit | Python | |
59a108840f0fb07f60f20bc9ff59a0d194cb0ee3 | enable import as module | sao-eht/lmtscripts,sao-eht/lmtscripts,sao-eht/lmtscripts,sao-eht/lmtscripts | __init__.py | __init__.py | """
.. module:: lmtscripts
:platform: Unix
:synopsis: useful scripts for EHT observations at LMT
.. moduleauthor:: Lindy Blackburn <lindylam@gmail.com>
.. moduleauthor:: Katie Bouman <klbouman@gmail.com>
"""
| mit | Python | |
88b6549b74dd767733cd823de410e00067a79756 | add test auto updater | yurydelendik/binaryen,yurydelendik/binaryen,WebAssembly/binaryen,ddcc/binaryen,WebAssembly/binaryen,WebAssembly/binaryen,yurydelendik/binaryen,ddcc/binaryen,ddcc/binaryen,yurydelendik/binaryen,WebAssembly/binaryen,WebAssembly/binaryen,ddcc/binaryen,yurydelendik/binaryen,ddcc/binaryen | auto_update_tests.py | auto_update_tests.py | #!/usr/bin/env python
import os, sys, subprocess, difflib
print '[ processing and updating testcases... ]\n'
for asm in sorted(os.listdir('test')):
if asm.endswith('.asm.js'):
print '..', asm
wasm = asm.replace('.asm.js', '.wast')
actual, err = subprocess.Popen([os.path.join('bin', 'asm2wasm'), os.path... | apache-2.0 | Python | |
322dd59f362a1862c739c5c63cd180bce8655a6d | Test to add data | elixirhub/events-portal-scraping-scripts | AddDataTest.py | AddDataTest.py | __author__ = 'chuqiao'
import script
script.addDataToSolrFromUrl("http://www.elixir-europe.org:8080/events", "http://www.elixir-europe.org:8080/events");
script.addDataToSolrFromUrl("http://localhost/ep/events?state=published&field_type_tid=All", "http://localhost/ep/events");
| mit | Python | |
be9cf41600b2a00494ca34e3b828e7a43d8ae457 | Create testing.py | a378ec99/bcn | bcn/utils/testing.py | bcn/utils/testing.py | """Utility functions for unittests.
Notes
-----
Defines a function that compares the hash of outputs with the expected output, given a particular seed.
"""
from __future__ import division, absolute_import
import hashlib
def assert_consistency(X, true_md5):
'''
Asserts the consistency between two function out... | mit | Python | |
41904abd0778719a1586b404c1ca56eb3205f998 | Include undg/myip to this repo bin. | und3rdg/zsh,und3rdg/zsh | bin/myip.py | bin/myip.py | #!/usr/bin/python3
def extIp(site): # GETING PUBLIC IP
import urllib.request
from re import findall
ipMask = '\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}'
if site == 'dyndns':
url = 'http://checkip.dyndns.org'
regexp = '<body>Current IP Address: ('+ipMask+')</body>'
if site == 'google':
... | mit | Python | |
c5a7e6dc9a98f056a31552e7ace4d150b13b998f | Create markdown.py | Vengeanceplays/CsGo,Vengeanceplays/CsGo | markdown.py | markdown.py | import os
import sys
import markdown
from cactus.utils import fileList
template = """
%s
{%% extends "%s" %%}
{%% block %s %%}
%s
{%% endblock %%}
"""
title_template = """
{%% block title %%}%s{%% endblock %%}
"""
CLEANUP = []
def preBuild(site):
for path in fileList(site.paths['pages']):
if not path.endsw... | mit | Python | |
5492e1b318ff0af3f1e2b1ed0217ed2744b50b68 | Add first structure for issue 107 (automatic configuration doc generation) | weblabdeusto/weblabdeusto,morelab/weblabdeusto,weblabdeusto/weblabdeusto,zstars/weblabdeusto,weblabdeusto/weblabdeusto,morelab/weblabdeusto,weblabdeusto/weblabdeusto,morelab/weblabdeusto,morelab/weblabdeusto,zstars/weblabdeusto,porduna/weblabdeusto,zstars/weblabdeusto,morelab/weblabdeusto,morelab/weblabdeusto,zstars/we... | server/src/configuration_doc.py | server/src/configuration_doc.py | from collections import namedtuple
NO_DEFAULT = object()
ANY_TYPE = object()
_Argument = namedtuple('Argument', 'category type default message')
_sorted_variables = []
######################################
#
# CORE
#
CORE = 'core'
WEBLAB_CORE_SERVER_SESSION_TYPE = 'core_session_type'
WEBLAB_CORE_SERVER_S... | bsd-2-clause | Python | |
411f855daa9f06868aa597f84c0b739429d705f4 | Create bot_read.py | shantnu/RedditBot,shantnu/RedditBot | bot_read.py | bot_read.py | #!/usr/bin/python
import praw
user_agent = ("PyFor Eng bot 0.1")
r = praw.Reddit(user_agent=user_agent)
subreddit = r.get_subreddit('python')
for submission in subreddit.get_hot(limit=5):
print submission.title
print submission.selftext
print submission.score
subreddit = r.get_subreddit('learnpython')
... | mit | Python | |
608120909f05096b51f43d99da4ea3bb86d02472 | add slim vgg19 model | kozistr/Awesome-GANs | SRGAN/vgg19.py | SRGAN/vgg19.py | from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import tensorflow as tf
import tensorflow.contrib.slim as slim
from collections import OrderedDict
tf.set_random_seed(777) # reproducibility
def get_tensor_aliases(tensor):
"""Get a list with the alias... | mit | Python | |
b62b37db1141221ae735b531bdb46264aadbe2e7 | add make_requests client in python | pauldardeau/python-concurrent-disk-io,pauldardeau/python-concurrent-disk-io,pauldardeau/python-concurrent-disk-io,pauldardeau/python-concurrent-disk-io,pauldardeau/python-concurrent-disk-io,pauldardeau/python-concurrent-disk-io,pauldardeau/python-concurrent-disk-io | make_requests.py | make_requests.py | import os
import sys
import time
def main(timeout_secs, server_port, iteration_count, file_name):
for i in range(iteration_count):
start_time_secs = time.time()
cmd = 'nc localhost %d < file_list_with_time.txt' % server_port
rc = os.system(cmd)
if rc != 0:
sys.exit(1)
... | bsd-3-clause | Python | |
5794a2d8d2b59a6a37b5af4e8c1adba276c325c4 | Create TagAnalysis.py | Nik0l/UTemPro,Nik0l/UTemPro | TagAnalysis.py | TagAnalysis.py | # Analysis of question tags
| mit | Python | |
a6a9bb5a365aef9798091335c81b1b793578ed1f | Initialize car classifier | shawpan/vehicle-detector | car_classifier.py | car_classifier.py | class CarClassifier(object):
""" Classifier for car object
Attributes:
car_img_dir: path to car images
not_car_img_dir: path to not car images
sample_size: number of images to be used to train classifier
"""
def __init__(self, car_img_dir, not_car_img_dir, sample_size):
"... | mit | Python | |
1732fe53dc228da64f3536ce2c76b420d8b100dc | Create the animation.py module. | aclogreco/InventGamesWP | ch17/animation.py | ch17/animation.py | # animation.py
# Animation
"""
This is an example of animation using pygame.
An example from Chapter 17 of
'Invent Your Own Games With Python' by Al Sweigart
A.C. LoGreco
"""
| bsd-2-clause | Python | |
248a756cd6ff44eca6e08b3e976bc2ae027accd4 | Add memory ok check | cloudnull/rpc-openstack,andymcc/rpc-openstack,prometheanfire/rpc-openstack,rcbops/rpc-openstack,darrenchan/rpc-openstack,stevelle/rpc-openstack,stevelle/rpc-openstack,hughsaunders/rpc-openstack,galstrom21/rpc-openstack,briancurtin/rpc-maas,sigmavirus24/rpc-openstack,mattt416/rpc-openstack,busterswt/rpc-openstack,cloudn... | chassis_memory.py | chassis_memory.py | import re
import subprocess
from maas_common import status_err, status_ok, metric_bool
OKAY = re.compile('(?:Health|Status)\s+:\s+(\w+)')
def chassis_memory_report():
"""Return the report as a string."""
return subprocess.check_output(['omreport', 'chassis', 'memory'])
def memory_okay(report):
"""Dete... | apache-2.0 | Python | |
260e2b6d4820ce008d751bc21289ece997247d05 | add source | rishubil/sqlalchemy-fulltext-search | sqlalchemy_fulltext/__init__.py | sqlalchemy_fulltext/__init__.py | # -*- coding: utf-8 -*-s
import re
from sqlalchemy import event
from sqlalchemy.schema import DDL
from sqlalchemy.orm.mapper import Mapper
from sqlalchemy.ext.compiler import compiles
from sqlalchemy.ext.declarative import declared_attr
from sqlalchemy.sql.expression import ClauseElement
MYSQL = "mysql"
MYSQL_BUILD_I... | mit | Python | |
257a328745b9622713afa218940d2cd820987e93 | Add a super simple color correction client example | PimentNoir/fadecandy,fragmede/fadecandy,fragmede/fadecandy,Jorgen-VikingGod/fadecandy,PimentNoir/fadecandy,poe/fadecandy,pixelmatix/fadecandy,pixelmatix/fadecandy,adam-back/fadecandy,jsestrich/fadecandy,Protoneer/fadecandy,Protoneer/fadecandy,hakan42/fadecandy,adam-back/fadecandy,Protoneer/fadecandy,piers7/fadecandy,pi... | examples/color-correction-ui.py | examples/color-correction-ui.py | #!/usr/bin/env python
#
# Simple example color correction UI.
# Talks to an fcserver running on localhost.
#
# Micah Elizabeth Scott
# This example code is released into the public domain.
#
import Tkinter as tk
import socket
import json
import struct
s = socket.socket()
s.connect(('localhost', 7890))
print "Connecte... | mit | Python | |
2359d7f6140b7b8292c3d9043064a9ee195ecebb | add module for storing repeated constants | Salman-H/mars-search-robot | code/constants.py | code/constants.py | """Module for constants and conversion factors."""
__author__ = 'Salman Hashmi, Ryan Keenan'
__license__ = 'BSD License'
TO_DEG = 180./np.pi
TO_RAD = np.pi/180.
| bsd-2-clause | Python | |
e2744bef45b62b6af2882aa881c494b9367a7d2a | Add 2D hybridization demo with file-write | thomasgibson/tabula-rasa | experiments/hybridization_2D.py | experiments/hybridization_2D.py | """Solve a mixed Helmholtz problem
sigma + grad(u) = 0,
u + div(sigma) = f,
using hybridisation with SLATE performing the forward elimination and
backwards reconstructions. The corresponding finite element variational
problem is:
dot(sigma, tau)*dx - u*div(tau)*dx + lambdar*dot(tau, n)*dS = 0
div(sigma)*v*dx + u*v*d... | mit | Python | |
07da1b8a2d0a8c8e28db3c9bed9de1d9f9a7ad6f | Add base solver class | Cosiek/KombiVojager | base_solver.py | base_solver.py | #!/usr/bin/env python
# encoding: utf-8
from datetime import datetime
class BaseSolver(object):
task = None
best_solution = None
best_distance = float('inf')
search_time = None
def __init__(self, task):
self.task = task
def run(self):
start_time = datetime.now()
self... | mit | Python | |
ff76d47f210e97f3ac4ba58a2c3eecb045b28cde | Create RateLimit.py | Mercurial/CorpBot.py,Mercurial/CorpBot.py | Cogs/RateLimit.py | Cogs/RateLimit.py | import asyncio
import discord
import os
from datetime import datetime
from discord.ext import commands
# This is the RateLimit module. It keeps users from being able to spam commands
class RateLimit:
# Init with the bot reference, and a reference to the settings var
def __init__(self, bot, settings):
self.bo... | mit | Python | |
d2b7f191519835a3a8f0e8a32fb52c7b354b0e33 | Add Slurp command | Heufneutje/PyMoronBot,MatthewCox/PyMoronBot,DesertBot/DesertBot | Commands/Slurp.py | Commands/Slurp.py | # -*- coding: utf-8 -*-
"""
Created on Aug 31, 2015
@author: Tyranic-Moron
"""
from IRCMessage import IRCMessage
from IRCResponse import IRCResponse, ResponseType
from CommandInterface import CommandInterface
from Utils import WebUtils
from bs4 import BeautifulSoup
class Slurp(CommandInterface):
triggers = ['... | mit | Python | |
8b6020384e20305411d2bbb587a2504ef302a17c | Create calculatepi.py | eliwoloshin/Calculate-Pi,anoushkaalavilli/Calculate-Pi,CriticalD20/Calculate-Pi,glenpassow/Calculate-Pi,RDanilek/Calculate-Pi,tesssny/Calculate-Pi,ChubbyPotato/Calculate-Pi,sarahdunbar/Calculate-Pi,Jamin2345/Calculate-Pi,glenpassow/Calculate-Pi,haydenhatfield/Calculate-Pi,sawyerhanlon/Calculate-Pi,davidwilson826/Calcul... | calculatepi.py | calculatepi.py | """
calculatepi.py
Author: <your name here>
Credit: <list sources used, if any>
Assignment:
| mit | Python | |
d3a320bf9387a0a36419c5166a4052e87d6c059e | Check Tabular Widths script added | kateliev/TypeDrawers | K11.07-CheckTabularWidths.py | K11.07-CheckTabularWidths.py | #FLM: Check Tabular Widths 1.2
# ------------------------
# (C) Vassil Kateliev, 2017 (http://www.kateliev.com)
# * Based on TypeDrawers Thread
# http://typedrawers.com/discussion/1918/simple-script-test-in-batch-if-all-tabular-and-fixed-width-values-are-correct
# No warranties. By using this you agree
# t... | mit | Python | |
0bc5b307d5121a3cacac159fa27ab42f97e208aa | Add database module | jcollado/rabbithole | rabbithole/db.py | rabbithole/db.py | # -*- coding: utf-8 -*-
import logging
from sqlalchemy import (
create_engine,
text,
)
logger = logging.getLogger(__name__)
class Database(object):
"""Database writer.
:param url: Database connection string
:type url: str
"""
def __init__(self, url, insert_query):
"""Connect ... | mit | Python | |
b62ed7a60349536457b03a407e99bae3e3ff56e8 | install issue | gsnbng/erpnext,gsnbng/erpnext,njmube/erpnext,indictranstech/erpnext,njmube/erpnext,njmube/erpnext,geekroot/erpnext,geekroot/erpnext,indictranstech/erpnext,njmube/erpnext,indictranstech/erpnext,gsnbng/erpnext,gsnbng/erpnext,indictranstech/erpnext,geekroot/erpnext,geekroot/erpnext,Aptitudetech/ERPNext | erpnext/setup/install.py | erpnext/setup/install.py | # Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
from frappe import _
default_mail_footer = """<div style="padding: 7px; text-align: right; color: #888"><small>Sent via
<a style="color... | # Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
from frappe import _
default_mail_footer = """<div style="padding: 7px; text-align: right; color: #888"><small>Sent via
<a style="color... | agpl-3.0 | Python |
43e823ad9ea7c44b49c883e8633dc488dff0d2ca | Add end_time for indexing. | City-of-Helsinki/linkedevents,kooditiimi/linkedevents,kooditiimi/linkedevents,aapris/linkedevents,aapris/linkedevents,kooditiimi/linkedevents,aapris/linkedevents,tuomas777/linkedevents,City-of-Helsinki/linkedevents,tuomas777/linkedevents,kooditiimi/linkedevents,tuomas777/linkedevents,City-of-Helsinki/linkedevents | events/search_indexes.py | events/search_indexes.py | from haystack import indexes
from .models import Event
from django.utils.translation import get_language
from django.utils.html import strip_tags
class EventIndex(indexes.SearchIndex, indexes.Indexable):
text = indexes.CharField(document=True, use_template=True)
autosuggest = indexes.EdgeNgramField(model_attr=... | from haystack import indexes
from .models import Event
from django.utils.translation import get_language
from django.utils.html import strip_tags
class EventIndex(indexes.SearchIndex, indexes.Indexable):
text = indexes.CharField(document=True, use_template=True)
autosuggest = indexes.EdgeNgramField(model_attr=... | mit | Python |
a85e444e9411f9f768db7c3e1b589b737c01b0a0 | add mnist examples | deercoder/PhD,DeercoderResearch/PhD,DeercoderResearch/PhD,deercoder/PhD,DeercoderResearch/PhD,deercoder/PhD,DeercoderResearch/PhD,deercoder/PhD,DeercoderResearch/PhD,deercoder/PhD,deercoder/0-PhD,deercoder/0-PhD,deercoder/0-PhD,deercoder/PhD,deercoder/PhD,DeercoderResearch/PhD,deercoder/0-PhD,deercoder/0-PhD,deercoder/... | TensorFlow/ex3/test_mnist.py | TensorFlow/ex3/test_mnist.py | #!/usr/bin/env python
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import gzip
import os
import tempfile
import numpy
from six.moves import urllib
from six.moves import xrange # pylint: disable=redefined-builtin
import tensorflow as tf
from tensorflow.e... | mit | Python | |
523ef51278c964718da68bb789e78e6c8f5f8766 | Add the init method to the notification model. | yiyangyi/cc98-tornado | model/notification.py | model/notification.py | def NotificationModel(Query):
def __init__(self, db):
self.db = db
self.table_name = "notification"
super(NotificationModel, self).__init__() | mit | Python | |
c68c5bf488cb7224d675bec333c6b7a4992574ed | Add a simple APL exception class | NewForester/apl-py,NewForester/apl-py | apl_exception.py | apl_exception.py | """
A simple APL exception class
"""
class APL_Exception (BaseException):
"""
APL Exception Class
"""
def __init__ (self,message,line=None):
self.message = message
self.line = line
# EOF
| apache-2.0 | Python | |
e68590e9e05ab54b91ad3d03e372fbf8b341c3b9 | Use a logger thread to prevent stdout races. | ehlemur/gtest-parallel,bbannier/gtest-parallel,kwiberg/gtest-parallel,pbos/gtest-parallel,greggomann/gtest-parallel,google/gtest-parallel | gtest-parallel.py | gtest-parallel.py | #!/usr/bin/env python2
import Queue
import optparse
import subprocess
import sys
import threading
parser = optparse.OptionParser(
usage = 'usage: %prog [options] executable [executable ...]')
parser.add_option('-w', '--workers', type='int', default=16,
help='number of workers to spawn')
parser.a... | #!/usr/bin/env python2
import Queue
import optparse
import subprocess
import sys
import threading
parser = optparse.OptionParser(
usage = 'usage: %prog [options] executable [executable ...]')
parser.add_option('-w', '--workers', type='int', default=16,
help='number of workers to spawn')
parser.a... | apache-2.0 | Python |
e093ce0730fa3071484fed251535fea62e0430d6 | add logger view | RoboCupULaval/UI-Debug | View/LoggerView.py | View/LoggerView.py | # Under MIT License, see LICENSE.txt
from PyQt4.QtGui import QWidget
from PyQt4.QtCore import QTimer
from PyQt4.QtGui import QListWidget
from PyQt4.QtGui import QHBoxLayout
from PyQt4.QtGui import QVBoxLayout
from PyQt4.QtGui import QPushButton
from Model.DataInModel import DataInModel
__author__ = 'RoboCupULaval'
... | mit | Python | |
b2f07c815c66be310ee1c126ba743bb786d79a08 | Create problem2.py | Amapolita/MITx--6.00.1x- | W2/PS2/problem2.py | W2/PS2/problem2.py | '''
PROBLEM 2: PAYING DEBT OFF IN A YEAR (15.0/15.0 points)
Now write a program that calculates the minimum fixed monthly payment needed in order pay off a credit card balance within 12 months. By a fixed monthly payment, we mean a single number which does not change each month, but instead is a constant amount that w... | unlicense | Python | |
61b7ee073efcd698329bec69a9eb682a1bc032d3 | Add py_trace_event to DEPS. | catapult-project/catapult,catapult-project/catapult-csm,sahiljain/catapult,sahiljain/catapult,benschmaus/catapult,catapult-project/catapult,catapult-project/catapult,catapult-project/catapult-csm,SummerLW/Perf-Insight-Report,catapult-project/catapult,sahiljain/catapult,benschmaus/catapult,catapult-project/catapult-csm,... | telemetry/telemetry/util/trace.py | telemetry/telemetry/util/trace.py | # Copyright 2014 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.core import util
util.AddDirToPythonPath(util.GetChromiumSrcDir(),
'third_party', 'py_trace_event', 'src')
from trac... | bsd-3-clause | Python | |
c3789b5f8a8c90902693194cf257b6c9e4ac7783 | Add solution to 119. | bsamseth/project-euler,bsamseth/project-euler | 119/119.py | 119/119.py | """
The number 512 is interesting because it is equal to the sum of its digits
raised to some power: 5 + 1 + 2 = 8, and 83 = 512. Another example of a number
with this property is 614656 = 284.
We shall define an to be the nth term of this sequence and insist that a number
must contain at least two digits to have a su... | mit | Python | |
2c155d4fe286f685bca696c60730bd2fca2151f1 | Add new package: sysbench (#18310) | iulian787/spack,LLNL/spack,LLNL/spack,LLNL/spack,iulian787/spack,iulian787/spack,LLNL/spack,iulian787/spack,LLNL/spack,iulian787/spack | var/spack/repos/builtin/packages/sysbench/package.py | var/spack/repos/builtin/packages/sysbench/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 Sysbench(AutotoolsPackage):
"""Scriptable database and system performance benchmark."""
... | lgpl-2.1 | Python | |
34a9969495f1b1c9452bff54cb03148e68fde303 | Create Insertion_sort_with_binary_search.py | gzc/CLRS,gzc/CLRS,gzc/CLRS | C02-Getting-Started/exercise_code/Insertion_sort_with_binary_search.py | C02-Getting-Started/exercise_code/Insertion_sort_with_binary_search.py | # Exercise 2.3-6 in book
# Standalone Python version 2.7 code
import os
import re
import math
import time
from random import randint
def insertion_sort(array):
for j, v in enumerate(array):
key = v
i = j - 1
while i > -1 and array[i] > key:
array[i+1] = array[i]
i = i - 1
array[i+1] = key
def inserti... | mit | Python | |
274e7a93bac93461f07dd43f3f84f1f00e229ffd | Add migration script hr_family -> hr_employee_relative | OCA/hr,OCA/hr,OCA/hr | hr_employee_relative/migrations/12.0.1.0.0/post-migration.py | hr_employee_relative/migrations/12.0.1.0.0/post-migration.py | # Copyright 2019 Creu Blanca
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from openupgradelib import openupgrade
@openupgrade.migrate()
def migrate(env, version):
cr = env.cr
columns = 'fam_spouse, fam_spouse_employer, fam_spouse_tel, fam_father,' \
' fam_father_date_of_... | agpl-3.0 | Python | |
5f9bb1a027664a0107a213b5dfa82c22d75c1196 | handle relative paths | ahihi/pls-files | pls-files.py | pls-files.py | #!/usr/bin/env python
from ConfigParser import SafeConfigParser
from contextlib import closing
from os.path import basename, dirname, join, normpath, realpath
import sys
from urllib2 import urlopen
def generic_open(arg):
try:
return urlopen(arg), None
except ValueError:
arg = normpath(realpath(... | #!/usr/bin/env python
from ConfigParser import SafeConfigParser
from contextlib import closing
from os.path import basename, dirname, join
import sys
from urllib2 import urlopen
def generic_open(arg):
try:
return urlopen(arg), None
except ValueError:
return open(arg, "r"), dirname(arg)
def pla... | cc0-1.0 | Python |
061ba14918eb6598031c9ad8a1c3f8e9c0f0a34b | Create LeetCode-LowestCommonAncestor2.py | lingcheng99/Algorithm | LeetCode-LowestCommonAncestor2.py | LeetCode-LowestCommonAncestor2.py | """
Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree.
Notice it is binary tree, not BST
"""
class TreeNode(object):
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution(object):
def lowestCommonAncest... | mit | Python | |
63208828762d01122054d122c8d305fa8930f9bd | Make service postage nullable | alphagov/notifications-api,alphagov/notifications-api | migrations/versions/0258_service_postage_nullable.py | migrations/versions/0258_service_postage_nullable.py | """
Revision ID: 0258_service_postage_nullable
Revises: 0257_letter_branding_migration
Create Date: 2019-02-12 11:52:53.139383
"""
from alembic import op
import sqlalchemy as sa
revision = '0258_service_postage_nullable'
down_revision = '0257_letter_branding_migration'
def upgrade():
# ### commands auto gener... | mit | Python | |
bc1fe15c77b8eedb40993e5ea24fa4d7340ff646 | Fix bug 17 (#4254) | PaddlePaddle/models,PaddlePaddle/models,PaddlePaddle/models | PaddleRec/multi-task/MMoE/args.py | PaddleRec/multi-task/MMoE/args.py | # Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserve.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appl... | apache-2.0 | Python | |
0179d4d84987da76c517de4e01100f0e1d2049ea | Add unit tests for pacman list packages | saltstack/salt,saltstack/salt,saltstack/salt,saltstack/salt,saltstack/salt | tests/unit/modules/pacman_test.py | tests/unit/modules/pacman_test.py | # -*- coding: utf-8 -*-
'''
:codeauthor: :email:`Eric Vz <eric@base10.org>`
'''
# Import Python Libs
from __future__ import absolute_import
# Import Salt Testing Libs
from salttesting import TestCase, skipIf
from salttesting.mock import (
MagicMock,
patch,
NO_MOCK,
NO_MOCK_REASON
)
from salttesti... | apache-2.0 | Python | |
f2d4ddba7c594ec93f0ede0be1fc515b0c7c2d7b | Remove HInput and Isolate joystick related code because son path isues with pygame | hikaruAi/HPanda | HJoystick.py | HJoystick.py | #from direct.showbase import DirectObject
import pygame #pygame must be in the Main.py directory
#THIS FILE MUST BE IN THE MAIN.PY DIRECTORY BECAUSE SON PATH ISSUES
class HJoystickSensor():
def __init__(self,joystickId=0):
#print os.getcwd()
pygame.init()
pygame.joystick.init()
c=p... | bsd-2-clause | Python | |
fe63d6e1e822f7cb60d1c0bdaa08eb53d3849783 | Add script to extract artist names from MusicBrainz database | xhochy/libfuzzymatch,xhochy/libfuzzymatch | benchmark/datasets/musicbrainz/extract-from-dbdump.py | benchmark/datasets/musicbrainz/extract-from-dbdump.py | #!/usr/bin/env python
"""
Script to extract the artist names from a MusicBrainz database dump.
Usage:
./extract-from-dbdump.py <dump_dir>/artist <outfile>
"""
import pandas as pd
import sys
__author__ = "Uwe L. Korn"
__license__ = "MIT"
input_file = sys.argv[1]
output_file = sys.argv[2]
df = pd.read_csv(input... | mit | Python | |
842092122b14343c9b1c2e2a4e0dd67dd8bdf767 | build SlideEvaluation objects from existing data | crs4/ProMort,lucalianas/ProMort,crs4/ProMort,lucalianas/ProMort,lucalianas/ProMort,crs4/ProMort | promort/slides_manager/migrations/0014_auto_20171201_1119.py | promort/slides_manager/migrations/0014_auto_20171201_1119.py | # -*- coding: utf-8 -*-
# Generated by Django 1.11.5 on 2017-12-01 11:19
from __future__ import unicode_literals
from django.db import migrations
def populate_slide_evaluations(apps, schema_editor):
SlideEvaluation = apps.get_model('slides_manager', 'SlideEvaluation')
SlideQualityControl = apps.get_model('sl... | mit | Python | |
116f41481062e6d9f15c7a81c2e5268aa1b706c7 | add sources script | TobyRoseman/PS4M,TobyRoseman/PS4M,TobyRoseman/PS4M | admin/scripts/addListOfSources.py | admin/scripts/addListOfSources.py | from collections import defaultdict
import re
import sys
import time
sys.path.append('../..')
from crawler.crawler import crawl, itemFactory
from engine.data.database.databaseConnection import commit, rollback
from engine.data.database.sourceTable import addSource, sourceExists, urlToLookupId
from engine.data.database... | mit | Python | |
76ff934621268a52bf4502449ea6a3843036c849 | add missing test | nathanbjenx/cairis,failys/CAIRIS,failys/CAIRIS,nathanbjenx/cairis,failys/CAIRIS,nathanbjenx/cairis,nathanbjenx/cairis | cairis/cairis/test/test_Persona.py | cairis/cairis/test/test_Persona.py | # Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may... | apache-2.0 | Python | |
3a235e25ac3f5d76eb4030e01afbe7b716ec6d91 | Add py solution for 331. Verify Preorder Serialization of a Binary Tree | ckclark/leetcode,ckclark/leetcode,ckclark/leetcode,ckclark/leetcode,ckclark/leetcode,ckclark/leetcode | py/verify-preorder-serialization-of-a-binary-tree.py | py/verify-preorder-serialization-of-a-binary-tree.py | class Solution(object):
def isValidSerialization(self, preorder):
"""
:type preorder: str
:rtype: bool
"""
def get_tree(nodes, offset):
if nodes[offset] == '#':
return offset + 1
else:
left = get_tree(nodes, offset + 1)
... | apache-2.0 | Python | |
f6dce9177421f61c7a773e1bbe53588eb54defc9 | Create score.py | Azure/azure-stream-analytics | Samples/AzureML/score.py | Samples/AzureML/score.py | #example: scikit-learn and Swagger
import json
import numpy as np
import pandas as pd
import azureml.train.automl
from sklearn.externals import joblib
from sklearn.linear_model import Ridge
from azureml.core.model import Model
from inference_schema.schema_decorators import input_schema, output_schema
from inference_sc... | mit | Python | |
f1599a7b3f342a86cf7eb7201593b8515d5f13ad | Add views for handling 400 & 500 errors | wylee/django-arcutils,wylee/django-arcutils,PSU-OIT-ARC/django-arcutils,PSU-OIT-ARC/django-arcutils | arcutils/views.py | arcutils/views.py | import logging
from django.http import HttpResponseBadRequest, HttpResponseServerError
from django.template import loader
from django.views.decorators.csrf import requires_csrf_token
log = logging.getLogger(__name__)
@requires_csrf_token
def bad_request(request, exception=None, template_name='400.html'):
"""Ov... | mit | Python | |
7aee25badd2085d63012c83f6be8082d93427754 | Add files via upload | Vikramank/Deep-Learning-,Vikramank/Deep-Learning- | polyregreesion.py | polyregreesion.py | # -*- coding: utf-8 -*-
"""
Created on Sun Jul 31 10:03:15 2016
@author:Viky
Code for polynomial regression
"""
#importing necessary packages
import numpy as np
import tensorflow as tf
import matplotlib.pyplot as plt
#input data:
x_input=np.linspace(0,3,1000)
x1=x_input/np.max(x_input)
x2=np.power(x_input,2)/np.ma... | mit | Python | |
6f4d5917abdbae1fe731e7a1786d8589d2b31ac0 | Fix #160 -- Add missing migration | ellmetha/django-machina,ellmetha/django-machina,ellmetha/django-machina | machina/apps/forum/migrations/0011_auto_20190627_2132.py | machina/apps/forum/migrations/0011_auto_20190627_2132.py | # Generated by Django 2.2.2 on 2019-06-28 02:32
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('forum', '0010_auto_20181103_1401'),
]
operations = [
migrations.AlterField(
model_name='forum',
name='level',
... | bsd-3-clause | Python | |
4c601ce9b91a0bef7082e3d8a5c1b95dc512d829 | add csl_util | lifei96/Medium_Crawler,lifei96/Medium-crawler-with-data-analyzer,lifei96/Medium-crawler-with-data-analyzer,lifei96/Medium-crawler-with-data-analyzer,lifei96/Medium-crawler-with-data-analyzer,lifei96/Medium_Crawler | User_Crawler/util_csl.py | User_Crawler/util_csl.py | # -*- coding: utf-8 -*-
from types import *
import pandas as pd
USER_ATTR_LIST = ['./data/cross-site-linking/user_type.csv',
'./data/graph/CC.csv',
'./data/graph/degree.csv',
'./data/graph/pagerank.csv'
]
def dict_merge(dict_1, dict_2):
res... | mit | Python | |
27b10f95e12c1fc1492be61643a057a9934ad535 | Add SSA. | divergentdave/inspectors-general,lukerosiak/inspectors-general | inspectors/ssa.py | inspectors/ssa.py | #!/usr/bin/env python
import datetime
import logging
import os
from urllib.parse import urljoin
from bs4 import BeautifulSoup
from utils import utils, inspector
# http://oig.ssa.gov/
# Oldest report: 1996
# options:
# standard since/year options for a year range to fetch from.
#
# Notes for IG's web team:
#
AUDI... | cc0-1.0 | Python | |
bcee6173027c48bfb25a65d3e97660f2e2a0852b | Add a python script to generate test methods | y-uti/php-bsxfun,y-uti/php-bsxfun | gentest.py | gentest.py | from itertools import product
import json
import numpy
cube = numpy.array(range(1, 9)).reshape(2, 2, 2)
pcube = [
cube[0 ,0 ,0 ],
cube[0 ,0 ,0:2],
cube[0 ,0:2,0:1],
cube[0 ,0:2,0:2],
cube[0:2,0:1,0:1],
cube[0:2,0:1,0:2],
cube[0:2,0:2,0:1],
cube[0:2,0:2,0:2],
]
for (i, (a, b)) i... | mit | Python | |
052392da7980c4f4e2e86cd8eb65da5b91d3547b | Solve Code Fights different symbols naive problem | HKuz/Test_Code | CodeFights/differentSymbolsNaive.py | CodeFights/differentSymbolsNaive.py | #!/usr/local/bin/python
# Code Fights Different Symbols Naive Problem
from collections import Counter
def differentSymbolsNaive(s):
return len(Counter(s))
def main():
tests = [
["cabca", 3],
["aba", 2]
]
for t in tests:
res = differentSymbolsNaive(t[0])
ans = t[1]
... | mit | Python | |
226f9430f81c4833a7541c2093dca07ef3645744 | Add build script | headupinclouds/polly,headupinclouds/polly,headupinclouds/polly,ruslo/polly,ruslo/polly,idscan/polly,idscan/polly | bin/build.py | bin/build.py | #!/usr/bin/env python3
# Copyright (c) 2014, Ruslan Baratov
# All rights reserved.
import argparse
import os
import re
import shutil
import subprocess
import sys
parser = argparse.ArgumentParser(description="Script for building")
parser.add_argument(
'--toolchain',
choices=[
'libcxx',
'xcode'... | bsd-2-clause | Python | |
f625f46e89c8e95677492cfb03ee113a3f6c7bb3 | Add utils.py | OParl/validator,OParl/validator | src/utils.py | src/utils.py | """
The MIT License (MIT)
Copyright (c) 2017 Stefan Graupner
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, mer... | mit | Python | |
f156cde55596ab7d954d41454f951227a719f6d5 | Create keys repository script | AlexanderRyzhko/0install-TUF,AlexanderRyzhko/0install-TUF,AlexanderRyzhko/0install-TUF | metadata_repo/scripts/create_keys_repo.py | metadata_repo/scripts/create_keys_repo.py | '''
Script for creating the RSA keys and creating a new repository
'''
from tuf.libtuf import *
# Generate and write the first of two root keys for the TUF repository.
# The following function creates an RSA key pair, where the private key is saved to
# "path/to/root_key" and the public key to "path/to/root_key.pub"... | lgpl-2.1 | Python | |
05c588866cc66bff33cb77fe35434f850ddd07f0 | Handle values larger than 2**63-1 in numeric crash address conversion (#119) | cihatix/FuzzManager,MozillaSecurity/FuzzManager,MozillaSecurity/FuzzManager,MozillaSecurity/FuzzManager,cihatix/FuzzManager,MozillaSecurity/FuzzManager,cihatix/FuzzManager,cihatix/FuzzManager | server/crashmanager/migrations/0009_copy_crashaddress.py | server/crashmanager/migrations/0009_copy_crashaddress.py | # -*- coding: utf-8 -*-
from __future__ import unicode_literals, print_function
import sys
from django.db import models, migrations
from django.conf import settings
def create_migration_tool(apps, schema_editor):
CrashEntry = apps.get_model("crashmanager", "CrashEntry")
for entry in CrashEntry.objects.f... | # -*- coding: utf-8 -*-
from __future__ import unicode_literals, print_function
import sys
from django.db import models, migrations
from django.conf import settings
def create_migration_tool(apps, schema_editor):
CrashEntry = apps.get_model("crashmanager", "CrashEntry")
for entry in CrashEntry.objects.f... | mpl-2.0 | Python |
4c381da905d81bde6ed28407f8e4cd3bcbd6d8be | Add cart forms | samitnuk/online_shop,samitnuk/online_shop,samitnuk/online_shop | apps/cart/forms.py | apps/cart/forms.py | from django import forms
PRODUCT_QUANTITY_CHOICES = [(i, str(i)) for i in range(1, 21)]
class CartAddProductForm(forms.Form):
quantity = forms.TypedChoiceField(choices=PRODUCT_QUANTITY_CHOICES,
coerce=int)
update = forms.BooleanField(required=False, initial=False,
... | mit | Python | |
46f25a4e0a43ea1ea8e1aaddbcdf18f6f20badba | Add package for open source Shiny Server (#3688) | EmreAtes/spack,matthiasdiener/spack,skosukhin/spack,tmerrick1/spack,LLNL/spack,tmerrick1/spack,LLNL/spack,mfherbst/spack,EmreAtes/spack,tmerrick1/spack,krafczyk/spack,tmerrick1/spack,LLNL/spack,skosukhin/spack,tmerrick1/spack,krafczyk/spack,krafczyk/spack,TheTimmy/spack,lgarren/spack,iulian787/spack,EmreAtes/spack,iuli... | var/spack/repos/builtin/packages/shiny-server/package.py | var/spack/repos/builtin/packages/shiny-server/package.py | ##############################################################################
# Copyright (c) 2013-2016, 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 | |
1bb2a9213dad8bde8a05da63438dbcdd0d8d09c6 | add example for asynchronous execution, little simpler than multiprocessing, uses a decorator to simplify it further | isidroamv/netmiko,nitzmahone/netmiko,jinesh-patel/netmiko,fooelisa/netmiko,fooelisa/netmiko,mileswdavis/netmiko,rdezavalia/netmiko,brutus333/netmiko,enzzzy/netmiko,isidroamv/netmiko,enzzzy/netmiko,jumpojoy/netmiko,mzbenami/netmiko,ivandgreat/netmiko,rdezavalia/netmiko,shamanu4/netmiko,ktbyers/netmiko,MikeOfNoTrades/net... | examples/async.py | examples/async.py | #!/usr/bin/env python2.7
"""Example of asynchronously running "show version".
async(): decorator to make further functions asynchronous
command_runner(): creates a connection and runs an arbitrary command
main(): entry point, runs the command_runner
"""
import netmiko
from inspect import getmodule
from multiprocessing... | mit | Python | |
d159b32d51339915ef633f3c6d33ce5eeafa78d6 | Add py solution for 396. Rotate Function | ckclark/leetcode,ckclark/leetcode,ckclark/leetcode,ckclark/leetcode,ckclark/leetcode,ckclark/leetcode | py/rotate-function.py | py/rotate-function.py | class Solution(object):
def maxRotateFunction(self, A):
"""
:type A: List[int]
:rtype: int
"""
lA = len(A)
if not lA:
return 0
subsum = 0
F = 0
for i in xrange(1, lA):
subsum += A[-i]
F += subsum
subs... | apache-2.0 | Python | |
70ff0faa7da6066bb75ddb871f67aa749f5bdc4e | Add custom field rendering tests | jmagnusson/django-admin-bootstrapped,andrewyager/django-admin-bootstrapped,kevingu1003/django-admin-bootstrapped,kevingu1003/django-admin-bootstrapped,Corner1024/django-admin-bootstrapped,askinteractive/mezzanine-advanced-admin,mynksngh/django-admin-bootstrapped,avara1986/django-admin-bootstrapped,sn0wolf/django-admin-... | django_admin_bootstrapped/tests.py | django_admin_bootstrapped/tests.py | from __future__ import absolute_import
from django.test import TestCase
from django.contrib.admin.widgets import AdminDateWidget
from django.template import Template, Context
from django import forms
try:
from bootstrap3 import renderers
except ImportError:
# nothing to test if we don't have django-bootstrap3... | apache-2.0 | Python | |
84e14782f353ef1d0dec20ed1da31cfb1da413a4 | Add diary example. | johndlong/walrus,coleifer/walrus | examples/diary.py | examples/diary.py | #!/usr/bin/env python
from collections import OrderedDict
import datetime
import sys
from walrus import *
database = Database(host='localhost', port=6379, db=0)
class Entry(Model):
database = database
namespace = 'diary'
content = TextField(fts=True)
timestamp = DateTimeField(default=datetime.datet... | mit | Python | |
eca8accb984c252f36289cd7bbab8ab23c198317 | Create problem3.py | Amapolita/MITx--6.00.1x- | W2/L4/problem3.py | W2/L4/problem3.py | #L4 PROBLEM 3
def square(x):
'''
x: int or float.
'''
return x ** 2
| unlicense | Python | |
3332370d70ad30856c9517e51eedc454500f8bf8 | Add forwarding script for build-bisect.py. | yitian134/chromium,ropik/chromium,Crystalnix/house-of-life-chromium,yitian134/chromium,gavinp/chromium,yitian134/chromium,Crystalnix/house-of-life-chromium,gavinp/chromium,adobe/chromium,ropik/chromium,adobe/chromium,Crystalnix/house-of-life-chromium,adobe/chromium,ropik/chromium,adobe/chromium,ropik/chromium,adobe/chr... | build/build-bisect.py | build/build-bisect.py | #!/usr/bin/python
# Copyright (c) 2010 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.
import sys
print "This script has been moved to tools/bisect-builds.py."
print "Please update any docs you're working from!"
sys.exit... | bsd-3-clause | Python | |
35e720cf7b9cbae4e077d0699dd321f741180787 | Create cached_test.py | Coal0/Utilities | cached/cached_test.py | cached/cached_test.py | from cached import cached
class Double:
def __init__(self, x):
self._x = x
@cached("_double_x")
def value(self):
return self._x * 2
| mit | Python | |
ee7c257b62bff832b899f54fd7bf39ae47db05b7 | Add tool to get new url | makyo/polycul.es,makyo/polycul.es,makyo/polycul.es | get_new_url.py | get_new_url.py | import sys
import polycules
if len(sys.argv) != 2:
print('Expected ID, got too little or too much')
old_id = sys.argv[1]
db = polycules.connect_db()
result = db.execute('select hash from polycules where id = ?', [
old_id,
]).fetchone()
if result is None:
print("Couldn't find the polycule with that ID"... | mit | Python | |
a994df7e8961e0d82a37ed268dba55c021c7ccd1 | Move order - here till i get the order_desc stuff working. | thousandparsec/libtpproto-py,thousandparsec/libtpproto-py | objects/OrderExtra/Move.py | objects/OrderExtra/Move.py |
from xstruct import pack
from objects import Order
class Move(Order):
"""\
Move to a place in space.
"""
subtype = 1
substruct = "qqq"
def __init__(self, sequence, \
id, type, slot, turns, resources, \
x, y, z):
Order.__init__(self, sequence, \
id, type, slot, turns, resources,
x, y, z)
... | lgpl-2.1 | Python | |
b8764629331caeeb37a4845480ed884841719525 | scale phage counts to percent so match bacteria counts | linsalrob/PhageHosts,linsalrob/PhageHosts,linsalrob/PhageHosts | code/percent_phage_counts.py | code/percent_phage_counts.py | """
The phage counts per metagenome are normalized based on the number of
reads that hit. I want to scale that to a percent, so that it matches
the bacterial data. If there was a single phage present it would get
100% of the reads
"""
import os
import sys
try:
inf = sys.argv[1]
ouf = sys.argv[2]
except:
... | mit | Python | |
d2a84fb3a8165c9526aa5c96f308dda3b92a2c2c | add new decision module | Salman-H/mars-search-robot | code/decision.py | code/decision.py | """
Module for rover decision-handling.
Used to build a decision tree for determining throttle, brake and
steer commands based on the output of the perception_step() function
in the perception module.
"""
__author__ = 'Salman Hashmi'
__license__ = 'BSD License'
import time
import numpy as np
import states
import... | bsd-2-clause | Python | |
3896ddcf660e168afaa80a0be9d7b40b6dd15967 | Add script to clean source code of compiled files. | lewisodriscoll/sasview,SasView/sasview,SasView/sasview,SasView/sasview,lewisodriscoll/sasview,SasView/sasview,SasView/sasview,SasView/sasview,lewisodriscoll/sasview,lewisodriscoll/sasview,lewisodriscoll/sasview | sansview/clean.py | sansview/clean.py | """
Remove all compiled code.
"""
import os
filedirs = ['.', 'perspectives', 'perspectives/fitting']
for d in filedirs:
files = os.listdir(d)
for f in files:
if f.find('.pyc')>0:
print "Removed", f
os.remove(os.path.join(d,f)) | bsd-3-clause | Python | |
ec736876e11a5aa4f52c63a91b05fc342e298051 | Add config.sample.py. | huxuan/CAPUHome-API,CAPU-ENG/CAPUHome-API | config.sample.py | config.sample.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
File: config.sample.py
Author: huxuan <i@huxuan.org>
Description: Configuration file for app.
"""
# Debug or not
DEBUG = True
# Make jsonfiy encode in utf-8.
JSON_AS_ASCII = False
# Secret key.
SECRET_KEY = 'CAPUHOME_Secret_Key'
# Database & sqlalchemy.
DB_USERNAME ... | mit | Python | |
ec9d97f7017939651fc78605fc81a2f030f88b5f | Add exceptions file | chrisgilmerproj/brewday,chrisgilmerproj/brewday | brew/exceptions.py | brew/exceptions.py | # -*- coding: utf-8 -*-
__all__ = [
u'BrewdayException',
u'DataLoaderException',
u'GrainException',
u'HopException',
u'StyleException',
u'YeastException',
]
class BrewdayException(Exception):
pass
class DataLoaderException(BrewdayException):
pass
class GrainException(BrewdayExcept... | mit | Python | |
2dd55385c3c8209217bde19c5a8d30ad929ce084 | Create employee.py | Chippers255/scheduler | scheduler/employee.py | scheduler/employee.py | # -*- coding: utf-8 -*-
# employee.py
#
# Created by Thomas Nelson <tn90ca@gmail.com>
#
# Created..........2015-03-12
# Modified.........2015-03-12
class Employee (object):
"""This class will represent an employee and there available time slots
for each work day that the provided store is open.
"""
def __init... | mit | Python | |
70116d7181f48c16d614063df4de54dff172e8c6 | Add internal note | conda/conda-env,isaac-kit/conda-env,mikecroucher/conda-env,phobson/conda-env,dan-blanchard/conda-env,asmeurer/conda-env,phobson/conda-env,nicoddemus/conda-env,ESSS/conda-env,nicoddemus/conda-env,mikecroucher/conda-env,asmeurer/conda-env,ESSS/conda-env,dan-blanchard/conda-env,isaac-kit/conda-env,conda/conda-env | conda_env/cli/main_export.py | conda_env/cli/main_export.py | from argparse import RawDescriptionHelpFormatter
from copy import copy
import os
import sys
import textwrap
import yaml
from conda.cli import common
from conda.cli import main_list
from conda import config
from conda import install
description = """
Export a given environment
"""
example = """
examples:
conda e... | from argparse import RawDescriptionHelpFormatter
from copy import copy
import os
import sys
import textwrap
import yaml
from conda.cli import common
from conda.cli import main_list
from conda import config
from conda import install
description = """
Export a given environment
"""
example = """
examples:
conda e... | bsd-3-clause | Python |
1a23860bfcc4fc5259bdcb0f208e38909e7055cc | add peak-merging script | brentp/combined-pvalues,brentp/combined-pvalues | cpv/peaks.py | cpv/peaks.py | """
find peaks or troughs in bed files
for a bedgraph file with pvalues in the 4th column. usage would be:
$ python peaks.py --dist 100 --seed 0.01 some.bed > some.regions.bed
where regions.bed contains the start and end of the region and (currently) the
lowest p-value in that region.
"""
from itertools import g... | mit | Python | |
f66038d1599843913dbe88eb02fa80b79e0d6e57 | add script for bitwise operation | haozai309/hello_python | codecademy/bitwise.py | codecademy/bitwise.py |
print 5 >> 4 # Right Shift
print 5 << 1 # Left Shift
print 8 & 5 # Bitwise AND
print 9 | 4 # Bitwise OR
print 12 ^ 42 # Bitwise XOR
print ~88 # Bitwise NOT
print "the base 2 number system"
print 0b1, #1
print 0b10, #2
print 0b11, #3
print 0b100, #4
print 0b101, #5
print 0b110, #6
print 0b111 #7
... | apache-2.0 | Python | |
059ab529b05d0640e7099e307878db58d6f2ffc9 | update board test | duguyue100/minesweeper | scripts/test-board.py | scripts/test-board.py | """Test script for the game board.
Author: Yuhuang Hu
Email : duguyue100@gmail.com
"""
from __future__ import print_function
from minesweeper.msgame import MSGame
game = MSGame(10, 10, 20)
game.print_board()
try:
input = raw_input
except NameError:
pass
while game.game_status == 2:
# play move
mo... | mit | Python | |
65d2202bc686019ebdaf292693c79ace326ef798 | Create MyoThalmic.py | MyRobotLab/pyrobotlab,sstocker46/pyrobotlab,MyRobotLab/pyrobotlab,MyRobotLab/pyrobotlab,MyRobotLab/pyrobotlab,MyRobotLab/pyrobotlab,sstocker46/pyrobotlab,sstocker46/pyrobotlab | service/MyoThalmic.py | service/MyoThalmic.py |
from com.thalmic.myo import Pose
myo = Runtime.start("python", "Python")
myo = Runtime.start("myo", "MyoThalmic")
myo.connect()
myo.addPoseListener(python)
onPose(pose):
print(pose.getType())
| apache-2.0 | Python | |
045f711f59c89559746ffddafecd92302c0a9ec6 | add fct_collapse and fct_lump funcs | machow/siuba | siuba/dply/forcats.py | siuba/dply/forcats.py | import pandas as pd
import numpy as np
from ..siu import create_sym_call, Symbolic
from functools import singledispatch
# TODO: move into siu
def register_symbolic(f):
@f.register(Symbolic)
def _dispatch_symbol(__data, *args, **kwargs):
return create_sym_call(f, __data.source, *args, **kwargs)
ret... | mit | Python | |
c1b27a617c9050799bb11f4c161f925f153da5bc | add test_gst_rtsp_server.py | tamaggo/gstreamer-examples | test_gst_rtsp_server.py | test_gst_rtsp_server.py | #!/usr/bin/env python
# -*- coding:utf-8 vi:ts=4:noexpandtab
# Simple RTSP server. Run as-is or with a command-line to replace the default pipeline
import sys
import gi
gi.require_version('Gst', '1.0')
from gi.repository import Gst, GstRtspServer, GObject
loop = GObject.MainLoop()
GObject.threads_init()
Gst.init(Non... | mit | Python | |
20b3616c810e5f1c4891c5b877b924925c8b28a8 | Add basic tests for redirect/callback/auth flow | adamcik/oauthclientbridge | tests/authorize_test.py | tests/authorize_test.py | import json
import urlparse
import pytest
from oauthclientbridge import app, crypto, db
@pytest.fixture
def client():
app.config.update({
'TESTING': True,
'SECRET_KEY': 's3cret',
'OAUTH_DATABASE': ':memory:',
'OAUTH_CLIENT_ID': 'client',
'OAUTH_CLIENT_SECRET': 's3cret',
... | apache-2.0 | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.