src stringlengths 721 1.04M |
|---|
import copy
import datetime
import json
import uuid
from django.core.exceptions import NON_FIELD_ERRORS
from django.core.files.uploadedfile import SimpleUploadedFile
from django.core.validators import MaxValueValidator, RegexValidator
from django.forms import (
BooleanField, CharField, CheckboxSelectMultiple, Choi... |
#!/usr/bin/python
#-*- encoding: utf-8 -*-
# This file is part of the Pameng,
# Pameng website: http://www.cnpameng.com/,
# Sina weibo: http://weibo.com/cnpameng.
# This file is part of WeiboMsgBackup.
# Copyright (C) 2013 Pameng.
# Pameng <pameng.cn@gmail.com>, 2013.
# WeiboMsgBackup is free software; you can red... |
import glob
import cPickle
import os
import argparse
import numpy as np
import pynet.datasets.preprocessor as procs
def generate_specs(ext, spec_dir, specnames, datafiles, dtype, feature_size,
output_dir, preprocessor, output_dtype, model):
assert dtype in ['f4', 'f8']
print 'opening model... |
# Another code written by Jagger Kyne
# Copyright 2006 - 2013 Jagger Kyne <jagger.kyne@gmail.com>
__author__ = 'Jagger Kyne'
from tkinter import *
import random
import time
class Game:
def __init__(self):
self.tk = Tk()
self.tk.title("Mr. Stick Man Race for the Exit")
self.tk.resizable(0,... |
#!/usr/bin/python -u
# 2004/10/15
#v1.0.0
# webcounter.py
# A very simple webcounter.
# Copyright Michael Foord
# You are free to modify, use and relicense this code.
# No warranty express or implied for the accuracy, fitness to purpose or otherwise for this code....
# Use at your own risk !!!
# For information abo... |
# Copyright 2012 IBM Corp.
#
# 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 agree... |
__author__ = 'matthewpang'
import serial
import time
import pickle
import struct
serStepper = serial.Serial('/dev/cu.usbmodem14231', 230400)
time.sleep(3)
def output_encoder(value):
"""
Takes a 16 bit integer value, packs it little endian, then encapsulates it in the defined format
[0xAA,LSByte,MSByte,Ox... |
import os
import re
import datetime
import subprocess
vendorid = 85838187 # David Foster
# Find all reports in the current directory
reports = [] # list of (vendorid, YYYYMMDD), both strings
for filename in os.listdir('.'):
# NOTE: Download filename format changed on... |
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# Thinkopen Brasil
# Copyright (C) Thinkopen Solutions Brasil (<http://www.tkobr.com>).
#
# This ... |
"""
sentry.interfaces
~~~~~~~~~~~~~~~~~
Interfaces provide an abstraction for how structured data should be
validated and rendered.
:copyright: (c) 2010-2013 by the Sentry Team, see AUTHORS for more details.
:license: BSD, see LICENSE for more details.
"""
import itertools
import urlparse
import warnings
from pygme... |
###############################################################################
#
# Copyright (C) 2001-2014 Micronaet SRL (<http://www.micronaet.it>).
#
# 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 ... |
#!/usr/bin/env python
from __future__ import print_function
import os
import json
from .files_and_paths import Dirs, Urls
from .utils import Utils
from .exp_file_metadata import ExpFileMetadata
class ExpFile(ExpFileMetadata):
def __init__(self, expID=None, fileID=None):
ExpFileMetadata.__init__(self)
... |
#!/usr/bin/env python3
# found some where on internet and added my own stuff to it.
import logging
import socket
import select
import subprocess
HOSTNAME = 'localhost'
PORT = '4000'
MAXIMUM_QUEUED_CONNECTIONS = 5
RECEIVING_BUFFER_SIZE = 4096
logger = logging.getLogger(__name__)
def start_server(hostname, port):
... |
# -*- coding: utf-8 -*-
"""
A minimalist klout API interface. Use of this API
requires klout *developer key*. You can get registered and
get a key at
<http://klout.com/s/developers/v2>
Supports Python >= 2.5 and Python 3
====================
Quickstart
====================
Install the PyPi package::
... |
# $Id: selftest.py 1758 2004-03-28 17:36:59Z fredrik $
# -*- coding: iso-8859-1 -*-
# elementtidy selftest program (in progress)
from elementtree import ElementTree
def sanity():
"""
Make sure everything can be imported.
>>> import _elementtidy
>>> from elementtidy.TidyHTMLTreeBuilder impo... |
import random
import itertools
rand = 'rand'
roundr = 'roundr'
leastc = 'leastc'
weightr = 'weightr'
weightlc = 'weightlc'
sticky = 'sticky'
def schedulerFactory(lbType, tracker):
"""
A dispatch function for a service's scheduler.
"""
if lbType == rand:
return RandomScheduler(tracker)
el... |
import abc
from typing import Union, Optional, Callable, Type
import h11
from h11._readers import ChunkedReader, ContentLengthReader, Http10Reader
from h11._receivebuffer import ReceiveBuffer
from mitmproxy import exceptions, http
from mitmproxy.net import http as net_http
from mitmproxy.net.http import http1, status... |
import mock
import unittest
import tempfile
from .helper import _ResourceMixin
class DisputeTest(_ResourceMixin, unittest.TestCase):
def _getTargetClass(self):
from .. import Dispute
return Dispute
def _getCollectionClass(self):
from .. import Collection
return Collection
... |
from __future__ import division
from phenix.command_line import superpose_pdbs
from iotbx import pdb
from iotbx.pdb import fetch
from libtbx import easy_run
from libtbx.utils import Sorry
import shutil
import tempfile
import os,sys
def run(fn):
''' '''
# Test if FAB
# Devide to
pdb_hierarchy_var_H,pdb_hierarc... |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# author igor
# Created by iFantastic on 16-6-14
'''
Computing User Profiles with Spark
data:
/data/tracks.csv
/data/cust.csv
'''
import os
import csv
# os.environ["PYSPARK_PYTHON"] = "/home/igor/anaconda3/bin/ipython"
# os.environ["PYSPARK_DRIVER_PYTHON"] = "pytho... |
from __future__ import unicode_literals
import sys
import functools
import json
try:
import jsonschema
except ImportError:
jsonschema = None
try:
import requests
except ImportError:
requests = None
__version__ = '1.0.0.dev1'
__all__ = ['ensure', 'JsonProbe']
# --------------
# Py2 compat
# -------... |
import re
from ez_setup import use_setuptools
use_setuptools()
from setuptools import setup
VERSION_REGEX = re.compile(b'''
^
release
\s*
=
\s*
['"]
(?P<version>
[^'"]+
)
['"]
\s*
$
''', re.VERBOSE)
def get_version():
with open('docs/conf.py', 'rb') as f:
... |
"""
Plugin to scrape prometheus endpoint
"""
# This file uses 'print' as a function rather than a statement, a la Python3
from __future__ import print_function
import math
import requests
# import prometheus client dependency dynamically
from monasca_agent.common import util
from requests import RequestException
tr... |
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
#
# Unit test for the HardwareSwitch module.
#
# Copyright (c) 2015 carlosperate https://github.com/carlosperate/
#
# Licensed under The MIT License (MIT), a copy can be found in the LICENSE file
#
# These test require the Wemo Switch to be on the network at the defined IP... |
import os
import json
from django.shortcuts import render
from django.http import HttpResponse, JsonResponse
from django.contrib.auth.decorators import login_required
from django.views.decorators.csrf import csrf_exempt
#from mhacks.equities import Field
EQUITY_MAP = {
'AAPL': 'AAPL US EQUITY'
}
def home_page(reque... |
# Copyright 2014 Diamond Light Source Ltd.
#
# 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 t... |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
**ui_constants.py**
**Platform:**
Windows, Linux, Mac Os X.
**Description:**
Defines **Umbra** package ui constants through the :class:`UiConstants` class.
**Others:**
"""
from __future__ import unicode_literals
__author__ = "Thomas Mansencal"
__copyright... |
# Copyright 2015 Hewlett-Packard Development Company, L.P.
#
# Author: Endre Karlson <endre.karlson@hpe.com>
#
# 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/lic... |
"""
STDM Import/Export module
"""
__author__ = 'John Gitau'
__license__ = 'GNU Lesser General Public License (LGPL)'
__url__ = 'http://www.unhabitat.org'
from stdm.settings import QGISRegistryConfig
from .exceptions import TranslatorException
from .reader import OGRReader
from .writer import OGRWriter
from ... |
import webracer
import nose.plugins.attrib
from . import utils
from .apps import form_app
utils.app_runner_setup(__name__, form_app.app, 8059)
@nose.plugins.attrib.attr('client')
@webracer.config(host='localhost', port=8059)
class RequestViaFormTest(webracer.WebTestCase):
def test_get_form_as_url(self):
s... |
import csv
import nltk
from nltk.tokenize import word_tokenize
import string
from nltk import pos_tag
from gensim.models.word2vec import Word2Vec
from gensim import matutils
from numpy import array, float32 as REAL
from sklearn.cluster import MiniBatchKMeans, KMeans
from multiprocessing import Pool
from collections imp... |
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2012 OpenStack LLC
# Copyright 2010 United States Government as represented by the
# Administrator of the National Aeronautics and Space Administration.
# Copyright 2010 OpenStack LLC.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (... |
# -*- coding: utf-8 -*-
#
# Copyright © 2007-2014 Red Hat, Inc.
#
# This copyrighted material is made available to anyone wishing to use, modify,
# copy, or redistribute it subject to the terms and conditions of the GNU
# General Public License v.2. This program is distributed in the hope that it
# will be useful, bu... |
"""
UhbdSingleFunctions.py
Functions for running single-site calculations using UHBD. Replaces the
prepares and doinps binaries.
"""
import os
TITRATABLE = {"HISA":"NE2","HISB":"ND1","HISN":"ND1","HISC":"ND1",
"LYS":"NZ","LYSN":"NZ","LYSC":"NZ",
"ARG":"CZ","ARGN":"CZ","ARGC":"CZ",
... |
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('actuators', '0007_auto_20150812_1520'),
]
operations = [
migrations.AlterField(
model_name='actuatoreffect',
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.