View gist:cfb535f161b30b325fdebfbb3170a426
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! |
View pypi_homepage.sh
# 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 ;} |
View click_command_delegation.py
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 | |
""" |
View pyenv_virtualenv_ps1.sh
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 |
View gist:4c5360255d5f43391567
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 |
View gist:ba9efbdf5e07160c0247
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\]$ " |
View macbeth.py
# 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}]}} |
View parse_manifest.py
# 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: |
View gist:4a98cfdfef61e1d5a097
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 | |
View 01.configure
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