This file contains hidden or 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
| implicit class Factorial(val n: Int) extends AnyVal{ | |
| def `!`: BigInt = n match { | |
| case _ if n < 0 => throw new IllegalArgumentException() | |
| case 0 => 1L | |
| case _ => (1 to n).foldLeft(1L)(_*_) | |
| } | |
| } | |
| defined class Factorial | |
| @ 5! |
This file contains hidden or 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
| # Retrieves the home page of a project in PyPI, and opens that homepage in your default browser. | |
| # This makes use of the PyPI JSON API: https://wiki.python.org/moin/PyPIJSON | |
| function pypi_homepage() { curl -sL http://pypi.python.org/pypi/$1/json | \ | |
| python -c "from __future__ import print_function;import json;import fileinput;\ | |
| blob=json.loads(' '.join([x for x in fileinput.input()]));print(blob['info']['home_page'])"| xargs open ;} |
This file contains hidden or 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 click | |
| @click.group() | |
| def main(): | |
| """Do things.""" | |
| def delegate_command(group, command_name, function, args=None, kwargs=None): | |
| """ | |
| Takes a function that has been decorated with ``click.group`` and delegates a command to it | |
| """ |
This file contains hidden or 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
| export VIRTUAL_ENV_DISABLE_PROMPT=1 | |
| pyenv_python_version(){ | |
| result="" | |
| if pyenv 2>/dev/null; then | |
| pyenv_version="$(pyenv version-name)"; | |
| if [ -n "$pyenv_version" ]; then | |
| result="$pyenv_version"; | |
| fi | |
| fi |
This file contains hidden or 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
| Process: MacDown [17345] | |
| Path: /Applications/MacDown.app/Contents/MacOS/MacDown | |
| Identifier: com.uranusjr.macdown | |
| Version: 0.4.5.1 (647) | |
| Code Type: X86-64 (Native) | |
| Parent Process: launchd [445] | |
| Responsible: MacDown [17345] | |
| User ID: 502 | |
| Date/Time: 2015-08-06 15:22:12.317 -0500 |
This file contains hidden or 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
| pyenv_python_version(){ | |
| result="" | |
| pyenv_version="$(pyenv version-name)"; | |
| if [ -n "$pyenv_version" ]; then | |
| result="$pyenv_version"; | |
| fi | |
| [[ -n "$result" ]] && echo "($result) " | |
| } | |
| export PS1="\$(pyenv_python_version)\[\033[36m\]\u\[\033[m\]@\[\033[32m\]\h\[\033[33;1m\]\w\[\033[m\]$ " |
This file contains hidden or 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
| # Daily Programming Challenge: | |
| # http://www.reddit.com/r/dailyprogrammer/comments/2xoxum/20150302_challenge_204_easy_remembering_your_lines/ | |
| import requests | |
| import re | |
| import sys | |
| macbeth = requests.get( | |
| "https://gist.githubusercontent.com/Quackmatic/f8deb2b64dd07ea0985d/raw/macbeth.txt").text | |
| # act_number: {scene: {description: (desc_of_scene), dialogues: [{speaker: | |
| # S, text: T}]}} |
This file contains hidden or 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
| # Adapted from https://github.com/python/cpython/blob/2.7/Lib/distutils/command/sdist.py#L386 | |
| from distutils.text_file import TextFile | |
| from distutils.filelist import FileList | |
| template = TextFile("MANIFEST.in", strip_comments=1, skip_blanks=1, join_lines=1, lstrip_ws=1, rstrip_ws=1, collapse_join=1) | |
| filelist = FileList() | |
| try: | |
| while True: |
This file contains hidden or 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 time import time | |
| class RateLimitedGeocodingQueue(object): | |
| def __init__(self, geocoder, addresses, per_sec_rate_limit=5): | |
| self.geocoder = geocoder | |
| self.addresses = [x for x in addresses] # Cloning list of addresses so we can pop with impunity | |
| self.per_sec_rate_limit = per_sec_rate_limit | |
This file contains hidden or 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
| 2014-12-30 18:36:20 -0600 | |
| ./configure | |
| --disable-dependency-tracking | |
| --prefix=/usr/local/Cellar/harfbuzz/0.9.37 | |
| --with-icu | |
| checking for a BSD-compatible install... /usr/bin/install -c | |
| checking whether build environment is sane... yes | |
| checking for a thread-safe mkdir -p... ./install-sh -c -d |
NewerOlder