commit
stringlengths
40
40
subject
stringlengths
1
1.49k
old_file
stringlengths
4
311
new_file
stringlengths
4
311
new_contents
stringlengths
1
29.8k
old_contents
stringlengths
0
9.9k
lang
stringclasses
3 values
proba
float64
0
1
0083a6fadad8bb0f202bab2af183a10f09e19459
Add simple demo of piglow - lighting arms
piglow/demo_piglow.py
piglow/demo_piglow.py
from piglow import PiGlow import time def brighten_arm( arm ): for i in range( 1, 10 ): piglow.arm( arm, i ) time.sleep( 0.11 ) time.sleep( 0.5 ) piglow.arm( arm, 0 ) piglow = PiGlow() piglow.all(0) brighten_arm( 1 ) brighten_arm( 2 ) brighten_arm( 3 )
Python
0
b3f8be5b6ab7e4e713004447a3cfbda743d80394
Add management command to update corpus logic hashes
rules/management/commands/CorpusLogicUpdate.py
rules/management/commands/CorpusLogicUpdate.py
import logging from django.core.management.base import BaseCommand, CommandError from plyara import YaraParser from rules.models import YaraRule # Configure Logging logging.basicConfig(level=logging.INFO) class Command(BaseCommand): help = 'Recalculate the logic hashes of the entire rule corpus' def handl...
Python
0
aefb6fbf38f8756458e487328139caf41afb6cee
Create MD5-DICT.py
MD5-DICT.py
MD5-DICT.py
from hashlib import md5 # by TheZakMan # Exemplo de md5: 21232f297a57a5a743894a0e4a801fc3 (admin) # dict: /usr/share/wordlists/rockyou.txt print "[Md5 Dict-Cracker]" print "| wordlist.txt |\n" crackme = raw_input("MD5:") #f = open('wordlist.txt', 'r') f = open('/usr/share/wordlists/rockyou.txt', 'r') words = [line...
Python
0
96e17fbac42354be33b90e23759220ccb81d3223
add sample + MM/DD/YY
sample.py
sample.py
# -*- coding: utf-8 -*- # # Copyright (C) 2013 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
Python
0.000123
14e32e60181083c8d0271fc974f3f1161ea81c74
Add first pass on create_tab script
tools/tab/create_tab.py
tools/tab/create_tab.py
#!/usr/bin/env python import datetime import io import os import sys import tarfile TAB_VERSION = 1 output_filename = sys.argv[1] name = sys.argv[2] inputs = sys.argv[3:] metadata = [] metadata.append('tab-version = {}'.format(TAB_VERSION)) metadata.append('name = "{}"'.format(name)) metadata.append('only-for-boa...
Python
0
916250bc9509986f1dfce3b09ddbc7a49aa79d42
Add admin for payments
payments/admin.py
payments/admin.py
# -*- coding: utf-8 -*- from django.contrib import admin from .models import Payment, Refund admin.site.register(Payment) admin.site.register(Refund)
Python
0
25f0615f4fb35779ce8688c5d29f92288ac2c30d
Add filesystem checks class
util/filesystem.py
util/filesystem.py
import os class FSCheck: def __init__(self, filepath, name: None): if name is None: name = filepath self.filepath = filepath self.name = name def exists(self, error: True): if not os.path.exists(self.filepath): if error: print('%s execu...
Python
0.000001
c0621b765234d33481318828dd3dc4bbc8481131
Add edges script, which generates a set of outline tiles for a double-height tileset
edges.py
edges.py
from PIL import Image, ImageDraw, ImageFont # compare a to b, b to c, c to d and d to a max_edge_difference = 2 output = [] for a in range(5): for b in range(5): for c in range(5): for d in range(5): if 0 in [a,b,c,d]: # Must be one vertex at 0 ...
Python
0.000009
cd7d80da95a3702a31fe0b8a62f4eadfeaa65b85
simplify user profile source
authentic2/attribute_aggregator/user_profile.py
authentic2/attribute_aggregator/user_profile.py
''' VERIDIC - Towards a centralized access control system Copyright (C) 2011 Mikael Ates This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the Licen...
''' VERIDIC - Towards a centralized access control system Copyright (C) 2011 Mikael Ates This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the Licen...
Python
0.000028
41d4448d277d24fc4a228920f7c4688472dc1170
add network location artifact figure
locate_network/make_network_artifact_figure.py
locate_network/make_network_artifact_figure.py
""" Uses the fast marching method to locate seismic events in 2d to explore effects of network geometry. Geometry is: [0, 1000] [0, 1000] """ import skfmm import pandas as pd import numpy as np import xarray as xr import matplotlib.pyplot as plt def unravel_index(velmod: xr.DataArray, index,) -> np.ndarray...
Python
0
edabec29ebb99e938fd3523951597e336ddd3adc
Add text vectorizers benchmarks (#9086)
benchmarks/bench_text_vectorizers.py
benchmarks/bench_text_vectorizers.py
""" To run this benchmark, you will need, * scikit-learn * pandas * memory_profiler * psutil (optional, but recommended) """ from __future__ import print_function import timeit import itertools import numpy as np import pandas as pd from memory_profiler import memory_usage from sklearn.datasets import fetch_...
Python
0
9bee248bce5edbf073f66e5d7a621f22bbba314f
Fix a failing test
zmq/devices/__init__.py
zmq/devices/__init__.py
"""0MQ Device classes for running in background threads or processes.""" # # Copyright (c) 2010 Brian E. Granger # # This file is part of pyzmq. # # pyzmq is free software; you can redistribute it and/or modify it under # the terms of the Lesser GNU General Public License as published by # the Free Soft...
"""0MQ Device classes for running in background threads or processes.""" # # Copyright (c) 2010 Brian E. Granger # # This file is part of pyzmq. # # pyzmq is free software; you can redistribute it and/or modify it under # the terms of the Lesser GNU General Public License as published by # the Free Soft...
Python
0.999524
8c168933c85f828ec85d6c069143e3c4174657b7
Create 10.CubeProperties.py
TechnologiesFundamentals/ProgrammingFundamentals/MethodsAndDebugging-Excercises/10.CubeProperties.py
TechnologiesFundamentals/ProgrammingFundamentals/MethodsAndDebugging-Excercises/10.CubeProperties.py
import math cubeSide = float(input()) parameter = input() if parameter == "face": face = math.sqrt(math.pow(cubeSide, 2) * 2) print("%.2f" % face) elif parameter == "space": space = math.sqrt(math.pow(cubeSide, 2) * 3) print("%.2f" % space) elif parameter == "volume": volume = math.pow(cubeSide,...
Python
0
9df4f11d878ee8d13dcbcee49745bdcc8ab3e507
Remove logging from test config
.travis/localsettings.py
.travis/localsettings.py
import os ####### Configuration for CommCareHQ Running on Travis-CI ##### ####### Database config. This assumes Postgres ####### DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', 'NAME': 'commcarehq', 'USER': 'postgres', 'PASSWORD': '', 'HOST':...
import os ####### Configuration for CommCareHQ Running on Travis-CI ##### ####### Database config. This assumes Postgres ####### DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', 'NAME': 'commcarehq', 'USER': 'postgres', 'PASSWORD': '', 'HOST':...
Python
0.000001
16f29bfc832a64accd6ef67c2140f70ea07f2f05
Add PyUnit for deep feature extraction of a LeNet model with mxnet.
h2o-py/tests/testdir_algos/deepwater/pyunit_lenet_deepwater_feature_extraction.py
h2o-py/tests/testdir_algos/deepwater/pyunit_lenet_deepwater_feature_extraction.py
from __future__ import print_function import sys, os sys.path.insert(1, os.path.join("..","..","..")) import h2o from tests import pyunit_utils from h2o.estimators.deepwater import H2ODeepWaterEstimator def deepwater_lenet(): if not H2ODeepWaterEstimator.available(): return frame = h2o.import_file(pyunit_utils.lo...
Python
0
9a1635dcdb21548fcb7b1f718624c991602588e6
Initialize P01_isPhoneNumber
books/AutomateTheBoringStuffWithPython/Chapter07/P01_isPhoneNumber.py
books/AutomateTheBoringStuffWithPython/Chapter07/P01_isPhoneNumber.py
# This program returns True if a string is a phone number and False if not # However, it's not very efficient def isPhoneNumber(text): if len(text) != 12: return False for i in range(0, 3): if not text[i].isdecimal(): return False if text[3] != '-': return False for...
Python
0.00737
3543c3566eb3da5c7e1cf91efcbc4ecc781b23aa
Add a South migration for the change tracking tables.
pubsubpull/south_migrations/0003_auto__add_request__add_field_updatelog_request__add_field_updatelog_ol.py
pubsubpull/south_migrations/0003_auto__add_request__add_field_updatelog_request__add_field_updatelog_ol.py
# -*- coding: utf-8 -*- from south.utils import datetime_utils as datetime from south.db import db from south.v2 import SchemaMigration from django.db import models class Migration(SchemaMigration): def forwards(self, orm): # Adding model 'Request' db.create_table('pubsubpull_request', ( ...
Python
0
c564c7361769c116a07ebb127c9453ec09b75699
Return true when iCloud finishes setting up
homeassistant/components/device_tracker/icloud.py
homeassistant/components/device_tracker/icloud.py
""" homeassistant.components.device_tracker.icloud ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Device tracker platform that supports scanning iCloud devices. For more details about this platform, please refer to the documentation at https://home-assistant.io/components/device_tracker.icloud/ """ import logging imp...
""" homeassistant.components.device_tracker.icloud ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Device tracker platform that supports scanning iCloud devices. For more details about this platform, please refer to the documentation at https://home-assistant.io/components/device_tracker.icloud/ """ import logging imp...
Python
0
af6272941a66967c3a64d735223fefc917056562
add example
examples/python/rgb-lcd.py
examples/python/rgb-lcd.py
# Author: Brendan Le Foll <brendan.le.foll@intel.com> # Copyright (c) 2014 Intel Corporation. # # 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 limita...
Python
0
771eede117c29af75c1d8d21f0da538bd280b5c1
Create search.py
search.py
search.py
# Requires Parallel to be installed # Use the below command to start with all available cores used # seq `nproc` | parallel -u python script.py __authors__ = ['Chick3nputer', 'Supersam654'] from itertools import islice, product import string import hashlib from random import shuffle from sys import argv chars = stri...
Python
0
5ee78767ebaa5c1bbceb7ce2c82fa6687169b0c2
Add exercice The Paranoid Android
codingame/medium/paranoid_android.py
codingame/medium/paranoid_android.py
class Elevator(object): def __init__(self, floor, pos): super(Elevator, self).__init__() self.floor = floor self.pos = pos self.direction = None def __str__(self): return 'Elevator on floor %i (pos %i) with dir %s' % (self.floor, self.pos, self.direction) class Game(ob...
Python
0.000567
f7132b86ca5f4dafeb88ca65b3d7fe71c6886cc5
Add packageinfo command
cerbero/commands/info.py
cerbero/commands/info.py
# cerbero - a multi-platform build system for Open Source software # Copyright (C) 2012 Andoni Morales Alastruey <ylatuya@gmail.com> # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; eit...
Python
0.000001
cb79c9bf74cb18f3ee86c7c3d5415ce1b088dde2
Add missing markdown file.
allmychanges/markdown.py
allmychanges/markdown.py
import CommonMark def render_markdown(text): parser = CommonMark.DocParser() renderer = CommonMark.HTMLRenderer() ast = parser.parse(text) return renderer.render(ast)
Python
0
114ea6c10658d2c199c68637d04bdd968fcc4452
Test case for task.info.json files
voyager_tasks/test/test_info_files.py
voyager_tasks/test/test_info_files.py
import os import sys import glob import json import unittest sys.path.append(os.path.dirname(os.path.dirname(__file__))) import voyager_tasks class TestInfoFiles(unittest.TestCase): """Test case for checking info files exist for each task and have a valid structure. """ @classmethod def setUpClass...
Python
0
24f536a72b0467ff3ee1615f515ecff9fbf36bb3
Add pair sum
ch07_04.py
ch07_04.py
number_of_data = int(input().strip()) ma = [0] * number_of_data numbers = [int(c) for c in input().strip().split()] for i in range(1, number_of_data - 1): ma[i] = (sum(numbers[i-1:i+2])/3) ma[0] = sum(numbers[0:2])/2 ma[-1] = sum(numbers[number_of_data - 2:])/2 ma = [str(d) for d in ma] print("\n".join(ma))
Python
0.999136
afa0efbdfc6bc4d19eaba919bc82c907fce37fa7
add base for API endpoint
datasets/api.py
datasets/api.py
import json from flask import request, Response, url_for from jsonschema import validate, ValidationError import models import decorators from datasets import app from database import session
Python
0.000001
cfad10dca1081c57f8cd84819e80546e485832ec
Add tempest test for heat resource OS::Nova::KeyPair
tempest/api/orchestration/stacks/test_nova_keypair_resources.py
tempest/api/orchestration/stacks/test_nova_keypair_resources.py
# Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # d...
Python
0.996961
ce9ac96a6f1e57ebbce162b7e097675c23f1f2f4
Implement simple gaussian process regression.
projects/jakub/gaussian_processes/gaussian_process_regression.py
projects/jakub/gaussian_processes/gaussian_process_regression.py
import csv import sys import matplotlib.pyplot as plt import numpy as np import sklearn import sklearn.gaussian_process.kernels kernel = (sklearn.gaussian_process.kernels.ConstantKernel() + sklearn.gaussian_process.kernels.Matern(length_scale=2, nu=3/2) + sklearn.gaussian_process.kernels.WhiteKer...
Python
0
c4aca4fe1bf02286f218ca855a41e380987818f7
Add test example
fcap/tests/test_example.py
fcap/tests/test_example.py
import unittest class BasicTestSuite(unittest.TestCase): """Basic test cases.""" def test_absolute_truth_and_meaning(self): assert True
Python
0.000002
fa27978c50364c903e2c343560f66db6ddc76bdb
add setup.py
play_tox/setup.py
play_tox/setup.py
from setuptools import setup setup(name="x")
Python
0.000001
6c4edaefe30905f62b885b931a1c5ca6d65cd220
Add tests for project model
server/tests/models/test_project.py
server/tests/models/test_project.py
from server.models import Project from server.tests.helpers import fixtures, FlaskTestCase class TestProject(FlaskTestCase): @fixtures('single_project.json') def test_get_single_owner(self): """Test getting single project owner """ with self.flaskapp.test_request_context(): ...
Python
0
ea7f32243c70de2737b1759db2c0e12337ecf840
add missing file
simphony/testing/abc_check_lattice.py
simphony/testing/abc_check_lattice.py
import abc from functools import partial import numpy from numpy.testing import assert_array_equal from simphony.testing.utils import ( create_data_container, compare_data_containers, compare_lattice_nodes) from simphony.cuds.lattice import LatticeNode from simphony.core.data_container import DataContainer clas...
Python
0.000003
ee62d6a972e5af72fc9a5e2e36d1a7822a1703af
Add sample on veh handle setup in remote process
samples/remote_veh_segv.py
samples/remote_veh_segv.py
import windows import windows.test from windows.generated_def.winstructs import * #c = windows.test.pop_calc_64() c = windows.test.pop_calc_64(dwCreationFlags=CREATE_SUSPENDED) python_code = """ import windows import ctypes import windows from windows.vectored_exception import VectoredException import windows.gen...
Python
0
0e5ba1d9ae7ca7d5439d886abe732f0fcebed49b
Create classes.py
classes.py
classes.py
class String(object):
Python
0.000001
e29bdc567c3d1f04f9e9ec17792052b0f66f918e
reorder users migration
apostello/migrations/0010_auto_20160421_1411.py
apostello/migrations/0010_auto_20160421_1411.py
# -*- coding: utf-8 -*- # Generated by Django 1.9.5 on 2016-04-21 13:11 from __future__ import unicode_literals from django.db import migrations class Migration(migrations.Migration): dependencies = [ ('apostello', '0009_userprofile_message_cost_limit'), ] operations = [ migrations.Alte...
Python
0.000002
c97509b510fb13fffdfbc490146b3940c62b3db9
too soon. sorry
src/pyechonest/decorators.py
src/pyechonest/decorators.py
# from http://wiki.python.org/moin/PythonDecoratorLibrary#Memoize class memoized(object): """Decorator that caches a function's return value each time it is called. If called later with the same arguments, the cached value is returned, and not re-evaluated. """ def __init__(self, func): self...
Python
0.998673
a519b7c91a8ea84549efcdf145aed56cf89b9d59
Create users.py
app/api_1_0/users.py
app/api_1_0/users.py
from flask import jsonify, request, current_app, url_for from . import api from ..models import User, Post @api.route('/users/<int:id>') def get_user(id): user = User.query.get_or_404(id) return jsonify(user.to_json()) @api.route('/users/<int:id>/posts/') def get_user_posts(id): user = User.query.get_or...
Python
0.000001
7445d91a68753052c837d5e0c919585d1f09d3d6
Add deterministic annealing demo
bayespy/demos/annealing.py
bayespy/demos/annealing.py
###################################################################### # Copyright (C) 2015 Jaakko Luttinen # # This file is licensed under Version 3.0 of the GNU General Public # License. See LICENSE for a text of the license. ###################################################################### ####################...
Python
0.000027
52a8a1cd093f8bdbaf0abfc85eff2d3682e24b12
Add Python script for questions linting
scripts/check-questions.py
scripts/check-questions.py
#!/usr/bin/env python3 import os import sys import json import collections import unicodedata TEXT_FIELD = "t" OPTIONS_FIELD = "o" KIND_FIELD = "k" CORRECT_FIELD = "c" MANDATORY_FIELDS = {TEXT_FIELD, OPTIONS_FIELD, CORRECT_FIELD} def norm(s): return unicodedata.normalize("NFD", s) def error(message, *, n): ...
Python
0.000001
3a662b5820ea90c0cd63116a610ede25558c5562
Add tests directory to sourceterm package and start test module.
sourceterm/tests/test_srcequations.py
sourceterm/tests/test_srcequations.py
''' Created on 25 Aug 2010 @author: ith ''' import unittest class Test(unittest.TestCase): def testName(self): pass if __name__ == "__main__": #import sys;sys.argv = ['', 'Test.testName'] unittest.main()
Python
0
3d11921f67c1928bb79869c3af1f8836360219fd
Add SIF assembler for Boolean network generation
indra/assemblers/sif_assembler.py
indra/assemblers/sif_assembler.py
import networkx as nx from indra.statements import * class SifAssembler(object): def __init__(self, stmts=None): if stmts is None: self.stmts = [] else: self.stmts = stmts self.graph = nx.DiGraph() self.nodes = {} def make_model(self): for st in ...
Python
0
732bee4960cb2448d829f5b30c114958a3ebbab2
Generate QR
genqr.py
genqr.py
#!/usr/bin/env python '''Generate QR code using Google Charts API''' import sys # Python 3/2 compatibility if sys.version_info[:2] < (3, 0): from urllib import urlopen, urlencode import httplib stdout = sys.stdout else: from urllib.request import urlopen from urllib.parse import urlencode impor...
Python
0.999999
1b10427e309861bb8afb00c45446f5a9cce5ba96
Create whenido-renamer.py
whenido-renamer.py
whenido-renamer.py
"""Renamer, Copyright 2014, Whenido, /u/tingmakpuk. Open source license available. This program was the first project of a complete novice, and the use of the program is at your own risk. Current version 3.0: More eligantly avoids renaming this program file. However, it can still rename other folders in the director...
Python
0.000002
f552979125531fade029bc8baa51e2d0bb9dd320
Simplify retrieving of config home in core init method
powerline/core.py
powerline/core.py
# -*- coding: utf-8 -*- import importlib import json import os import sys from colorscheme import Colorscheme from theme import Theme class Powerline(object): def __init__(self, ext): config_home = os.environ.get('XDG_CONFIG_HOME', os.path.expanduser('~/.config')) config_path = os.path.join(config_home, 'powe...
# -*- coding: utf-8 -*- import importlib import json import os import sys from colorscheme import Colorscheme from theme import Theme class Powerline(object): def __init__(self, ext): try: config_home = os.environ['XDG_CONFIG_HOME'] except KeyError: config_home = os.path.expanduser('~/.config') config...
Python
0.000001
5999d8b572d8f28fc4fee0826660a40ec108d15b
Create trimfile.py
bin/preprocess/trimfile.py
bin/preprocess/trimfile.py
#!/usr/bin/python def trimOne(): return 0
Python
0.000001
5bcc8e8fb427322e98bb8cd27f3b15270a6e75a7
Add script to automatically populate struct fields
scripts/populate_struct.py
scripts/populate_struct.py
# # scripts/populate_struct.py # Brandon Azad # # Populate a struct using data flow analysis. # def kernelcache_populate_struct(struct=None, address=None, register=None, delta=None): import idc import idautils import idaapi import ida_kernelcache as kc import ida_kernelcache.ida_utilities as idau ...
Python
0
d268c5870623b1c5f6da202264cb1b399f037ec8
Create rename.py
rename.py
rename.py
import sys import os if len ( sys.argv ) == 4: args = sys.argv [ 1: ] else: print 'Usage: python rename.py [path]' sys.exit ( 0 ) path = '.' filenames = os.listdir ( str ( path ) ) # Check some things text = open ( args [ 0 ], 'r' ).read ( ) original_names = text.split ( '\n' ) text = open ( args [ 1 ], 'r' ).re...
Python
0.000003
8e61c18d23812a70d65ec42d7c36c5f1b7ed829d
add script for 50bp window gff summary.
scripts/summarize_gff50.py
scripts/summarize_gff50.py
import sys import os.path as op sys.path.insert(0, "/home/brentp/src/methylcode/code/") from methyl import MethylGroup prefix = sys.argv[1] # something like: out1234n/thaliana_v9 acontext = sys.argv[2] # CHH or CHG or CG window = 50 mg = MethylGroup(prefix) fh = open(mg.dir + mg.prefix + ".test.%ibp.%s.gff" % (wind...
Python
0
3dc9204c80f2f7be5f82200c059a6a62f02bf6c1
Update blogroll and social links.
www/pelicanconf.py
www/pelicanconf.py
#!/usr/bin/env python # -*- coding: utf-8 -*- # from __future__ import unicode_literals AUTHOR = u'IPython development team and Enthought, Inc.' SITENAME = u'DistArray' SITEURL = '' PATH = 'content' TIMEZONE = 'America/Chicago' DEFAULT_LANG = u'en' # Feed generation is usually not desired when developing FEED_ALL_...
#!/usr/bin/env python # -*- coding: utf-8 -*- # from __future__ import unicode_literals AUTHOR = u'IPython development team and Enthought, Inc.' SITENAME = u'DistArray' SITEURL = '' PATH = 'content' TIMEZONE = 'America/Chicago' DEFAULT_LANG = u'en' # Feed generation is usually not desired when developing FEED_ALL_...
Python
0
b4b3d133c53db0f182949d1e31b27c87818d3a0c
Create quiz_corrected.py
quiz_corrected.py
quiz_corrected.py
#code for the project final quiz.code #I'll break it down into single pieces and work from there #0. Write three quizzes: easy, medium, hard and write blanks for each. # Easy quiz level and answers easy_level = '''The internet is basically a huge ___1___ of computers that can all communicate with each other. When a ...
Python
0.000011
e1e24a4fd232342dcca4151a0fa5aa3990ceb3b9
initial hello world
hello.py
hello.py
print "hello"
Python
0.999715
d80388591e3a55969688957b7c1bbd9bcda40296
Create social_feedback_counter.py compatible with hatebu, fb_like & tweet
social_feedback_counter.py
social_feedback_counter.py
# coding:utf-8 import urllib import json class SocialFeadbackCounter(object): def __init__(self, url): self.url = url def hatebu(self): api_url = 'http://b.hatena.ne.jp/entry/json/' + self.url hb_json = json.loads(urllib.urlopen(api_url).read(), encoding='utf-8') if hb_json ...
Python
0
1866bb1ad5f5c4338c2173327d620e92c2ba5043
Create basic PodSixNet server
server.py
server.py
from PodSixNet.Channel import Channel from PodSixNet.Server import Server from time import sleep #Create the channel to deal with our incoming requests from the client #A new channel is created every time a client connects class ClientChannel(Channel): #Create a function that will respond to every request from t...
Python
0
0cc0b16a6f29d31c3c2b3e2ad4eb313b010f7806
test addBuilds() method
errata_tool/tests/test_add_builds.py
errata_tool/tests/test_add_builds.py
import requests class TestAddBuilds(object): def test_add_builds_url(self, monkeypatch, mock_post, advisory): monkeypatch.setattr(requests, 'post', mock_post) advisory.addBuilds(['ceph-10.2.3-17.el7cp'], release='RHEL-7-CEPH-2') assert mock_post.response.url == 'https://errata.devel.redha...
Python
0.000001
fbbd6526612bbb450c5c4c1ecffd21e32f4c98c6
Add simple server
server.py
server.py
import SimpleHTTPServer import SocketServer PORT = 8000 Handler = SimpleHTTPServer.SimpleHTTPRequestHandler httpd = SocketServer.TCPServer(('', PORT), Handler) print "serving at port", PORT httpd.serve_forever()
Python
0.000001
5cfcd8fe88fc56bd5738c97152d37be1478560a9
Add server.py
server.py
server.py
from twisted.web.proxy import Proxy, ProxyRequest from twisted.internet.protocol import Protocol, ClientFactory import urlparse from twisted.python import log class ConnectProxyRequest(ProxyRequest): """HTTP ProxyRequest handler (factory) that supports CONNECT""" connectedProtocol = None def process(sel...
Python
0.000001
9e6bae8aa92ed0332efd689b6f43063b0569ef0a
add 16.py
16.py
16.py
"""Python challenge #16: http://www.pythonchallenge.com/pc/return/mozart.html""" import urllib2 from PIL import Image url = 'http://www.pythonchallenge.com/pc/return/mozart.gif' un = 'huge' pw = 'file' pink = (255, 0, 255) def main(): setup_auth_handler() img = urllib2.urlopen(url) im = Image.open(img) ...
Python
0.998462
af320490aaa59d69faed9357d9690d945272bec5
add empty file to test Slack integration
A2.py
A2.py
#!/usr/bin/env python3
Python
0
944102f3d19b4086e7f7cb9c30e95a3d4b043601
Add python prototype
ho.py
ho.py
class Position(object): COLORS = { 'black': '@', 'white': 'O', 'empty': '+', } class PositionError(Exception): pass def __init__(self, color): if color not in self.COLORS: raise self.PositionError('Color must be one of the following: {0}'.format(self...
Python
0.000419
31a74f1b9b50036a9b1de603f3437516eaef7807
Create pb.py
pb.py
pb.py
print "ParseBasic interpreter v0.1" print "Copyright 2015 NETponents" print "Licensed under MIT license" print "Commercial use of this build is prohibited"
Python
0.000715
c4015ed868b65ce5c7ed660c84e252a950294642
Add basic functionality to query the (horrible) website.
r1.py
r1.py
from datetime import date import bs4 import itertools as it import re import requests def grouper(iterable, n, fillvalue=None): args = [iter(iterable)] * n return it.izip_longest(fillvalue=fillvalue, *args) def extract_name(bsitem): return bsitem.find('span').text def extract_price(bsitem): reg = ...
Python
0
b49571316595b97ba602ac737f9c47ce682ac7b0
Solving 53
53.py
53.py
class Solution: # @param s : A string # @return : A string def reverseWords(self, s): # write your code here
Python
0.999999
7dede788648d5569587214722a2a128f419a7b8a
Create v1.py
v1.py
v1.py
print "This is Pizza Pi R Squared. What's it do? It lets you determine whether buying a small pizza or a large pizza is a better value in terms of cost per bite of pizza." diameter_one = int(raw_input("What's the first pizza's diameter (in inches)?")) cost_one = int(raw_input("How much does the first pizza cost? (i...
Python
0
1ae8bde8ec4c872734245d2a761bdfe9b5e276d5
add database actions
db.py
db.py
import mysql.connector from twisted.protocols.ftp import CNX_CLOSED_TXFR_ABORTED class Dmdb: """ DB operation of drinking running server""" #class variables USER = "root" PASSWORD = "123456" DATABASE = "db_drinking_man" ADD_DRINK = ''' INSERT INTO `db_drinking_man`.`drinks` ( `id_stri...
Python
0.000001
a998bd2686ab924035325d7288131a7141a457bb
Apply orphaned migration
project/apps/api/migrations/0010_remove_chart_song.py
project/apps/api/migrations/0010_remove_chart_song.py
# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import models, migrations class Migration(migrations.Migration): dependencies = [ ('api', '0009_auto_20150722_1041'), ] operations = [ migrations.RemoveField( model_name='chart', name=...
Python
0
fe668b882d3c27f8f7bf7f8cf6d338bf3216310e
add testing script in temp location
aki.py
aki.py
#!/usr/bin/env python # XXX this is a helpful script, but probably belongs in scriptworker/test/data from __future__ import print_function import aiohttp import asyncio from copy import deepcopy import json import logging import pprint import sys from scriptworker.constants import DEFAULT_CONFIG from scriptworker.cont...
Python
0
59b01485c70d42e32acb4c80efbe0e393ca8c437
Add aes.py
aes.py
aes.py
# -*- coding: utf-8 -*- import base64 from Crypto import Random from Crypto.Cipher import AES class AESCipher: def __init__(self, key): self.bs = 32 if len(key) >= 32: self.key = key[:32] else: self.key = self._pad(key) def encrypt(self, raw): raw = se...
Python
0.001639
68b8ad567545c7ec07f13089f2b3e4ecd4cc835e
Create api.py
api.py
api.py
from flask import Flask from flask.ext.restful import reqparse, abort, Api, Resource from profile import Profile app = Flask(__name__) api = Api(app) def abort_if_user_doesnt_exist(user): if not isValid(user): abort(404, message="User {} doesn't exist".format(user)) # Argument validation parser = reqpa...
Python
0
beca6dad76746f5e6cce76749efda391d5c49a6e
Number 5 is done
ex5.py
ex5.py
#!/usr/bin/env python #feel free to sub your own details.. like I have from the original of Mr Shaw's my_name = "Davii" my_age = 34 #not a lie! my_height = 186 #CM my_weight = 90 #kg .. I need to diet. my_eyes = "blue" my_teeth = "white" #maybe a little coffee staining my_hair = "Dark Brown" print("Let's talk about %...
Python
0.998276
265bedb193f8615f99daa63c921b572408921605
Add tests for quick sort
test_quick_sort.py
test_quick_sort.py
# -*- coding: utf-8 -*- from quick_sort import quick_sort def test_sorted(): my_list = list(range(100)) quick_sort(my_list) assert my_list == list(range(100)) def test_reverse(): my_list = list(range(100))[::-1] quick_sort(my_list) assert my_list == list(range(100)) def test_empty(): m...
Python
0
017fa0b360c23696d3176f48e2c53accac8bcfc5
Add version module
redcap/version.py
redcap/version.py
VERSION = '0.5.2'
Python
0.000001
426ef95ba1b2f3ac42c16a3594d186c4c9226a6e
add admin
referral/admin.py
referral/admin.py
from django.contrib import admin from models import Campaign, Referrer class ReferrerInine(admin.TabularInline): model = Referrer extra = 0 class CampaignAdmin(admin.ModelAdmin): inlines = (ReferrerInine, ) class ReferrerAdmin(admin.ModelAdmin): list_display = ('name', 'campaign', 'creation_date') ...
Python
0
e826c3e95b1a035484a5fa3ab05d5bc5e5a023bb
Add db_fsck.py which checks for some problems with the server and image store.
db_fsck.py
db_fsck.py
#!/usr/bin/env python # -*- coding: iso-8859-1 -*- from hashlib import md5 import Image from os.path import exists from os import stat, walk import re def usage(argv): print "Usage:", argv[0], "-opts" print "Where opts can be:" print "\t-t Check thumb existance" print "\t-T Check thumb integrity (decodeability an...
Python
0
747800528b3709759738081ee580e380bf164c02
add skeletons of new unit tests to be added
pymatgen/analysis/defects/tests/test_compatibility.py
pymatgen/analysis/defects/tests/test_compatibility.py
# coding: utf-8 # Copyright (c) Pymatgen Development Team. # Distributed under the terms of the MIT License. from __future__ import unicode_literals import unittest from pymatgen.util.testing import PymatgenTest class DefectCompatibilityTest(PymatgenTest): def test_process_entry(self): pass def t...
Python
0
b68db14e5ecd2e8ccaaa0412798a8669232fb8e5
Add constraint variables in solver
solver.py
solver.py
from collections import namedtuple from past import autotranslate # python-constraint is python2, so we'll use python-future's autotranslate function autotranslate(['constraint']) import constraint # periods is an int for how many periods per week are required for this subject subject = namedtuple("subject", ['name',...
Python
0.000002
92f2b8c5b44fd6f306e32275b24daddb35fa3e53
function to calculate_effective_permittivity
gdsfactory/simulation/effective_permittivity.py
gdsfactory/simulation/effective_permittivity.py
"""Calculate the effective refractive index for a 1D mode.""" from typing import Literal import numpy as np from scipy.optimize import fsolve def calculate_effective_permittivity( epsilon_film: float, epsilon_substrate: float, epsilon_cladding: float, thickness: float, wavelength: float, pol...
Python
0.998539
a14d696cad5b3249997257298150977fa53f9cc8
Add lc151_reverse_words_in_a_string.py
lc151_reverse_words_in_a_string.py
lc151_reverse_words_in_a_string.py
"""Leetcode 151. Reverse Words in a String Medium Given an input string, reverse the string word by word. Example 1: Input: "the sky is blue" Output: "blue is sky the" Example 2: Input: " hello world! " Output: "world! hello" Explanation: Your reversed string should not contain leading or trailing spaces. Exampl...
Python
0.998758
b80d7927225f172653922317ef5c96e90876588d
Create SemiSupervisedTSNE.py
sstsne/SemiSupervisedTSNE.py
sstsne/SemiSupervisedTSNE.py
Python
0
2fbcd2c5c47b4066e74619196dc333fa88a015d1
isolate pipe operator overload code
tests/pipe_test.py
tests/pipe_test.py
# -*- coding: utf-8 -*- import asyncio import pytest import paco from paco.pipe import overload def test_pipe_operator_overload(): @asyncio.coroutine def filterer(x): return x < 8 @asyncio.coroutine def mapper(x): return x * 2 @asyncio.coroutine def drop(x): return x ...
Python
0.000001
fd6eea38f389a440f2c7d69e0de29677a64dbd2c
Add manual wifi table migration script.
ichnaea/scripts/migrate.py
ichnaea/scripts/migrate.py
""" Manual migration script to move networks from old single wifi table to new sharded wifi table structure. """ from collections import defaultdict import sys import time from ichnaea.config import read_config from ichnaea.db import ( configure_db, db_worker_session, ) from ichnaea.models.wifi import ( Wi...
Python
0
d4c7869d62635eca3108d743c2bc12c9f394d68a
Add archive.File class, which allows downloading from archive.org
tests/test_item.py
tests/test_item.py
import os, sys inc_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) sys.path.insert(0, inc_path) import archive def test_item(): item = archive.Item('stairs') assert item.metadata['metadata']['identifier'] == 'stairs' def test_file(): item = archive.Item('stairs') filename = 'glogo...
Python
0
fa4b4de37b38f0ff800bbd2ac007ab6521720258
Add test for box migration script
scripts/tests/test_box_migrate_to_external_account.py
scripts/tests/test_box_migrate_to_external_account.py
from nose.tools import * from scripts.box.migrate_to_external_account import do_migration, get_targets from framework.auth import Auth from tests.base import OsfTestCase from tests.factories import ProjectFactory, UserFactory from website.addons.box.model import BoxUserSettings from website.addons.box.tests.factori...
Python
0
7056f00934c0956bfe1a6aed7558cb3b9fd1de57
add ability to retrieve sorted profiler statistics
tornado_profile.py
tornado_profile.py
"""Profile a Tornado application via REST.""" from operator import itemgetter import tornado.web import yappi __author__ = "Megan Kearl Patten <megkearl@gmail.com>" def start_profiling(): """Start profiler.""" # POST /profiler yappi.start(builtins=False, profile_threads=False) def is_profiler_running(...
"""Profile a Tornado application via REST.""" import tornado.web import yappi __author__ = "Megan Kearl Patten <megkearl@gmail.com>" def start_profiling(): """Start profiler.""" # POST /profiler yappi.start(builtins=False, profile_threads=False) def is_profiler_running(): """Return True if the prof...
Python
0
08e04060b57d16417e2a109242174ee8620d8f93
Add missing cyaml.py
bentoo/yaml/cyaml.py
bentoo/yaml/cyaml.py
# coding: utf-8 from __future__ import absolute_import from _bentoo.yaml import CParser, CEmitter # type: ignore from bentoo.yaml.constructor import Constructor, BaseConstructor, SafeConstructor from bentoo.yaml.representer import Representer, SafeRepresenter, BaseRepresenter from bentoo.yaml.resolver import Resolv...
Python
0.999991
97d62cd3cb08c8d43a804eb7989b03df3626f0ab
Create music.py
music.py
music.py
from microbit import * import music import random while True: music.play(music.NYAN, loop=True, wait=False) if getValidDab(): music.play(music.POWER_UP) else: music.play(music.POWER_DOWN)
Python
0.000003
9c26b042c38963bf95cc6456b0f9082c1c0827f3
Add ttype API tests
tests/test_api_ttype.py
tests/test_api_ttype.py
from urllib import urlencode import json from .base import MyTestCase from privacyidea.lib.user import (User) from privacyidea.lib.tokens.totptoken import HotpTokenClass from privacyidea.models import (Token) from privacyidea.lib.config import (set_privacyidea_config, get_token_types, ...
Python
0
86cae13f7dde04f7031ae111e596f2d8c03d5420
Add tests of CSVFile and StdOut recorders
tests/test_recorders.py
tests/test_recorders.py
import pytest from plumbium.processresult import record, pipeline, call from plumbium.recorders import CSVFile, StdOut from collections import OrderedDict @pytest.fixture def simple_pipeline(): @record() def recorded_function(): call(['echo', '6.35']) def a_pipeline(): recorded_function()...
Python
0
2ccc6127c817c8c9b88d11a405ee96e8c33e8e4b
print the pre-cleaned and validated params to console to see the objects we've retrieved, call the .items() method on headers to get more direct access to the WebOb request object's header vals.
server.py
server.py
from pprint import pprint import webapp2 from paste import httpserver __author__ = "Brian Tomlinson <darthlukan@gmail.com>" class Processor(object): """ Performs some basic validation of data and cleanup as needed before passing off to the "heavy lifter" NOTE: Dummy logic for now as placeholders. ...
import webapp2 from paste import httpserver __author__ = "Brian Tomlinson <darthlukan@gmail.com>" class Processor(object): """ Performs some basic validation of data and cleanup as needed before passing off to the "heavy lifter" NOTE: Dummy logic for now as placeholders. """ def __init__(sel...
Python
0
c850cb4832e6273c8239eeb7d457d8e16bb472d6
Add graph factory
graph_generation/graph_template.py
graph_generation/graph_template.py
""" This module implements factory for creating a graph. Current version supports proto and networkx graphs. """ from proto_graph import ProtoGraph from nx_graph import NxGraph class GraphTemplate: """ A class to get instance of a selected class for graph generation. ... Methods: get_proto_grap...
Python
0
4bd9e4db4af430ae34ed87f695d72ae99ba5bb70
Set up first test level, started to create constraints
solver.py
solver.py
from constraint import * # Empty space is 0 # Brick is a 1 # Block is a 2 # West facing player - 3 # East facing player - 4 # Door - 5 level = [[1,1,1,1,1,1,1,1,1,1], [1,0,0,0,0,0,0,0,0,1], [1,0,0,0,0,0,0,0,0,1], [1,0,0,0,0,0,0,0,0,1], [1,0,0,0,0,0,0,0,0,1], [1,0,0,0,0,0,0,...
Python
0.000001
c92e0350527e7715b6b625c33a79c993aeae66fd
Add gui.py
gui.py
gui.py
#!/usr/bin/python import sys from PyQt5.QtWidgets import QMainWindow, QDesktopWidget, QApplication class MainWindow(QMainWindow): def __init__(self): super(MainWindow, self).__init__() self.init_UI() def init_UI(self): WINDOW_WIDTH = 800 WINDOW_HEIGHT = 800 self.resiz...
Python
0.000002
2fb5557aed14d047d1ae120f0ff91c0e355d779f
Add simple perf measuring tool
ref.py
ref.py
#!/usr/bin/env python2 import sys import subprocess """ Usage: ./ref.py ./main -B 1000000 -t 3 -T 31 """ system = subprocess.check_output githash = system("git rev-parse HEAD", shell=True).strip() date = system("date -Ihours", shell=True).strip() filename = "reference.%s.%s" % (githash, date) benchargs = sys....
Python
0.000001
3bb3a1f1babab9e6516f635290baa4d4e9762b8d
add pressure box device
mecode/devices/efd_pressure_box.py
mecode/devices/efd_pressure_box.py
import serial STX = '\x02' #Packet Start ETX = '\x03' #Packet End ACK = '\x06' #Acknowledge NAK = '\x15' #Not Acknowledge ENQ = '\x05' #Enquiry EOT = '\x04' #End Of Transmission class EFDPressureBox(object): def __init__(self, comport='COM4'): self.comport = comport self.connect() ...
Python
0
7927fd0c13f14b348faa63c08683c6f80bdc7a0f
Create 5.3_nextsmallbig.py
5.3_nextsmallbig.py
5.3_nextsmallbig.py
""" given a positive integer, return the next smallest and largest number with the same number of 1s in the binary represenation """
Python
0.010827
c9e111804974f21dbe297855ab217e964526baa2
Add search_hints option.
tensorflow/tools/docs/generate2.py
tensorflow/tools/docs/generate2.py
# Copyright 2018 The TensorFlow Authors. 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 required by applica...
# Copyright 2018 The TensorFlow Authors. 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 required by applica...
Python
0.999137
1e82d6110bee6953b78ee357ed5e0b94710b1357
fix urls
heroku/urls.py
heroku/urls.py
from django.conf.urls import include, url urlpatterns = [ url(r'^fafl', include('fafl.urls')), url(r'^', include('aristotle_cloud.urls')), url(r'^publish/', include('aristotle_mdr.contrib.self_publish.urls', app_name="aristotle_self_publish", namespace="aristotle_self_publish")), url(r'^', include('ari...
Python
0.005145
6f9ced48a8c423e505e21cfa9a0b0d05b4c86f5c
Add lava context processor.
lava_server/context_processors.py
lava_server/context_processors.py
# Copyright (C) 2010, 2011 Linaro Limited # # Author: Zygmunt Krynicki <zygmunt.krynicki@linaro.org> # # This file is part of LAVA Server. # # LAVA Server is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License version 3 # as published by the Free Software F...
Python
0.000001
54f6b9e5d8769ba608fe0d3f14eda2746319d6d2
Add class DepthSerializerMixin
mixins.py
mixins.py
class DepthSerializerMixin(object): """Custom method 'get_serializer_class', set attribute 'depth' based on query parameter in the url""" def get_serializer_class(self): serializer_class = self.serializer_class query_params = self.request.QUERY_PARAMS depth = query_params.get('__depth', None) serializer_cla...
Python
0
935375fdc785adbbf74c8f943d319988ef4240f5
Create execute.py
execute.py
execute.py
import extractor as ex from sklearn.svm import LinearSVC from sklearn import linear_model from sklearn.naive_bayes import MultinomialNB from sklearn.naive_bayes import GaussianNB from sklearn.linear_model import LogisticRegression from sklearn.tree import DecisionTreeClassifier from sklearn.neighbors import KNeighborsC...
Python
0.000003
8b00084dbdb93518f66b95bd484570b65aee6f4c
add Fabric config file
fabfile.py
fabfile.py
"""Management utilities.""" from fabric.contrib.console import confirm from fabric.api import abort, env, local, settings, task, sudo, cd, lcd, put from fabric.contrib.files import exists ########## CONFIG local_app_dir = '.' local_config_dir = './config' remote_app_home_dir = '/home/www' remote_git_dir = '/home/...
Python
0