Skip to content

Instantly share code, notes, and snippets.

View rch's full-sized avatar

Ryan C. Hill rch

View GitHub Profile
@rch
rch / spaced.py
Created January 27, 2012 18:15
Count runs of extra spaces?
from functools import partial, wraps
def coroutine(func):
# Based on http://www.dabeaz.com/coroutines/coroutine.py
@wraps(func)
def start(*args,**kwargs):
cr = func(*args,**kwargs)
cr.next()
return cr
@rch
rch / count_runs.py
Created May 2, 2012 19:13
count char runs in a string
#
# Which would be easier to extend and generalize for top N instead of max, and infinite s1?
#
s1 = 'aabbbbcbbaab'
nmax = 0
nwrd = 0
cmax = ''
prev = ''
@rch
rch / error.json
Created November 29, 2012 00:39
Calling doc().score() in a native script causes a NullPointerException
{
"error" : "SearchPhaseExecutionException[Failed to execute phase [query_fetch], total failure; shardFailures {NullPointerException[null]}]",
"status" : 500
}
@rch
rch / grid.js
Last active December 31, 2015 04:28
Ext.define('MyApp.view.MyGridPanel', {
extend: 'Ext.grid.Panel',
alias: 'widget.mygridpanel',
requires: [
'Ext.grid.plugin.RowEditing'
],
border: '2 2 2 2',
id: '',
# page reload
{
'action': 'GridProvider',
'type': 'rpc',
'tid': 1,
'data': [{
'start': 0,
'limit': 25,
'page': 1
}],
@rch
rch / example.py
Created February 3, 2014 20:37
Lepl Example
>>> value = Token(UnsignedReal())
>>> symbol = Token('[^0-9a-zA-Z \t\r\n]')
>>> number = Optional(symbol('-')) + value >> float
>>> add = number & ~symbol('+') & number > sum
>>> add.parse('12+30')
[42.0]
>>> add.parse('12 + -30')
[-18.0]
#!/usr/bin/env python
import re
from collections import OrderedDict
class Name(object):
def __init__(self, raw):
if raw is None:
self._first = ''
@rch
rch / app.js
Last active August 29, 2015 14:15
metadata reconfigure example
Ext.require([
'Ext.data.*',
'Ext.tree.*',
'Ext.grid.*',
'Ext.container.*',
]);
Ext.application({
name : 'Main',

Keybase proof

I hereby claim:

  • I am rch on github.
  • I am rch (https://keybase.io/rch) on keybase.
  • I have a public key whose fingerprint is A3B0 E05E E2D0 0714 B2A4 B31B B8CD 8934 7577 F749

To claim this, I am signing this object:

@rch
rch / mesos-chronos-linux.md
Created January 2, 2017 22:09 — forked from diegopacheco/mesos-chronos-linux.md
How to Install Mesos / Chronos on Ubuntu Linux 16.04 LTS?
#
# Install Java 8
#
wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u45-b14/jdk-8u45-linux-x64.tar.gz"
tar -xzvf jdk-8u45-linux-x64.tar.gz
rm -rf jdk-8u45-linux-x64.tar.gz

#
# Install Maven 3