This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
c:\local\dev>python ghget.py -h | |
usage: ghget.py [-h] -u USER -r REPO [-b BRANCH] [-s SUB] [-p PATH] [-v] | |
GitHub repository downloader. | |
optional arguments: | |
-h, --help show this help message and exit | |
-u USER, --user USER github user (required) | |
-r REPO, --repo REPO github repository (required) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pyechonest import config | |
from pyechonest.song import Song | |
# Loading Bangarang by Skrillex... | |
song = Song('id:rdio-US:track:t14313937') | |
song = Song('id:spotify-WW:track:6VRhkROS2SZHGlp0pxndbJ') | |
song = Song('TRVOJIZ13A9CFBB670') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
def mceil(n, m): | |
''' | |
returns ceil(n) the multiple m. | |
example: mceil(21, 10) -> 30.0 which is the next multiple of 10. | |
:param n: value to ceil. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import re | |
from subprocess import PIPE, Popen | |
import click | |
def which(executable): | |
for path in os.environ['PATH'].split(os.pathsep): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
def which(executable): | |
for path in os.environ['PATH'].split(os.pathsep): | |
path = path.strip('"') | |
fpath = os.path.join(path, executable) | |
if os.path.isfile(fpath) and os.access(fpath, os.X_OK): | |
return fpath |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
def test1(stop=100): | |
for i in range(stop): | |
pass | |
def test2(stop=100): | |
for i in xrange(stop): | |
pass | |
compare = Compare('Testing the use of range and xrange.') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
Extended Euclidean Algorithm extended_gcd(a, b) methods found online. | |
''' | |
from functools import wraps | |
from time import time | |
def benchmark(iterations=10000): | |
def wrapper(function): | |
@wraps(function) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def float_spec(fill, align, sign, width, separator, precision): | |
if len(fill) > 1: | |
raise ValueError('The fill character can only contain 1 character.') | |
if align not in ['left', 'right', 'center', 'padded']: | |
raise ValueError('{} is not an allowed alignment.'.format(align)) | |
if sign not in ['+', '-', ' ']: | |
raise ValueError('{} is not a valid sign.'.format(sign)) |
NewerOlder