Skip to content

Instantly share code, notes, and snippets.

View ianjosephwilson's full-sized avatar

Ian Wilson ianjosephwilson

View GitHub Profile
from itertools import islice
def p_strs(items):
""" Generate strings that represent all the partitions of the given items.
Examples:
items = [1, 2, 3, 4]
assert len(items) == 4
[0,0,0,0] -- [[1,2,3,4]]

Keybase proof

I hereby claim:

  • I am ianjosephwilson on github.
  • I am ianjosephwilson (https://keybase.io/ianjosephwilson) on keybase.
  • I have a public key ASBfYmsRZsAxCQF09dG8pb9nupyVl8WQFbuje2U2eY3cwwo

To claim this, I am signing this object:

import sys
def main(argv):
print (argv)
if __name__ == '__main__':
# The first argument is how we were called.
called_as = sys.argv[0]
# Pass actual arguments to our main function.
main(sys.argv[1:])
@ianjosephwilson
ianjosephwilson / runlint.py
Created August 2, 2016 21:15
Testing out the mini racer v8 interface with Douglas Crockford's jslint.js from http://www.jslint.com/.
"""
Testing out the py mini racer v8 interface with Douglas Crockford's jslint.js from http://www.jslint.com/.
"""
import sys
from py_mini_racer import py_mini_racer
HTML_PAGE_FORMAT = """<!DOCTYPE html>
<head>
<meta charset="utf-8">
@ianjosephwilson
ianjosephwilson / page1.html
Last active August 29, 2017 23:48
polymer2 MPA -- 99% of this code is copied from the polymer webpack loader demo
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Page 1</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<h1>Page 1</h1>
import logging
from collections import namedtuple
#tryton_jsonrpc is a softlink to tryton.jsonrpc.
from tryton_jsonrpc import ServerProxy, Fault
from pyramid.httpexceptions import HTTPUnauthorized
log = logging.getLogger(__name__)
storage_location_ids = server.model.stock.location.search([
('type', '=', 'storage'),
('parent', 'child_of', location_ids)])
@ianjosephwilson
ianjosephwilson / gist:8330653
Last active January 2, 2016 16:29
broken form helpers
{% macro form_error(key, errors) -%}{%- endmacro %}
{% macro form_input(key, values, errors=None, label=None, type='text') %}
<div class="form-group{{' error' if errors and key in errors else ''}}">
<label class="form-label">{{ label or key.replace('_', ' ').title() }}</label>
<input type="{{ type }}" name="{{ key }}"
value="{{ values.get(key, '') }}"
class="form-control">
{% form_error(key, errors) %}
</div>
@ianjosephwilson
ianjosephwilson / gist:8263540
Created January 5, 2014 02:30
gentoo blocking
sudo emerge --oneshot portage
* IMPORTANT: 6 news items need reading for repository 'gentoo'.
* Use eselect news to read news items.
Calculating dependencies... done!
[ebuild NS ] dev-lang/python-3.3.2-r2 [2.7.3-r2, 3.2.3] USE="gdbm ipv6 ncurses readline sqlite ssl threads xml -build -doc -examples -hardened -tk -wininst"
[ebuild U ] sys-apps/portage-2.2.7 [2.1.11.62] PYTHON_TARGETS="python3_3* -python3_2*"
[blocks B ] <sys-apps/sandbox-2.6-r1 ("<sys-apps/sandbox-2.6-r1" is hard blocking dev-lang/python-3.3.2-r2)
<div class="control-group">
<span class="control-label">Field</span>
<div class="controls">
<span class="help-inline">Value</span>
</div>
</div>