Skip to content

Instantly share code, notes, and snippets.

@jackmaney
jackmaney / pypi_homepage.sh
Last active August 27, 2015 06:02
A simple function to open the homepage of any project on PyPI (with a listed homepage)
# 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 ;}
@jackmaney
jackmaney / gist:cfb535f161b30b325fdebfbb3170a426
Created March 22, 2018 21:39
Scala's sexy, sexy implicits...
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!