I hereby claim:
- I am andyhd on github.
- I am andyhd (https://keybase.io/andyhd) on keybase.
- I have a public key whose fingerprint is C289 A2BE B069 56A2 0222 BCA1 C142 9457 4A0A F3C6
To claim this, I am signing this object:
function truncate_html(html, words_left, depth) { | |
if (typeof html == 'string') { | |
html = html.replace(/</g, ' <').replace(/>/g, '> ').trim().split(/\s+/); | |
} | |
if (!depth) { depth = 0; } | |
var opening_tag = /^<\s*\w+[^>]*>/; | |
var closing_tag = /^<\/\s*\w+[^>]*>/; | |
var void_tag = /^<\s*(area|base|br|col|command|embed|hr|img|input|keygen|link|meta|param|source|track|wbr)[^>]*>/; | |
var word = html[0]; | |
if (!word) { return []; } |
<?php | |
/** | |
* A Maybe Monad class, encapsulates null checking | |
*/ | |
class Maybe { | |
private $value; | |
public function __construct($value=null) { | |
$this->value = $value; |
from __future__ import with_statement | |
from alembic import context | |
from sqlalchemy import engine_from_config, pool | |
from logging.config import fileConfig | |
# this is the Alembic Config object, which provides | |
# access to the values within the .ini file in use. | |
config = context.config | |
# Interpret the config file for Python logging. |
@contextlib.contextmanager | |
def google_search_results(terms, page=1, custom_search_id=''): | |
params = { | |
'q': terms, | |
'cx': custom_search_id or app.config.get('GOOGLE_CUSTOM_SEARCH_ID', ''), | |
'start': ((page - 1) * 10) + 1, | |
'num': 10 | |
} | |
yield custom_search_service.list(**params).execute() |
I hereby claim:
To claim this, I am signing this object:
import random | |
def build_lookup(corpus, key_size=2): | |
lookup = {} | |
for i, _ in enumerate(corpus): | |
if i + key_size < len(corpus): | |
words = lookup.setdefault(tuple(corpus[i:i + key_size]), []) | |
words.append(corpus[i + key_size]) | |
return lookup |
Picking the right architecture = Picking the right battles + Managing trade-offs
package main | |
import ( | |
"fmt" | |
"github.com/aws/aws-sdk-go/aws" | |
"github.com/aws/aws-sdk-go/aws/session" | |
"github.com/aws/aws-sdk-go/service/ec2" | |
"github.com/aws/aws-sdk-go/service/sts" | |
"log" | |
"os" |
# autoswitch virtualenv | |
function cd() { | |
venv="venv" | |
if [[ -f .venv ]]; then | |
if [[ -d "$HOME/.virtualenvs/$(cat .venv)" ]]; then | |
venv="$HOME/.virtualenvs/$(cat .venv)" | |
fi | |
fi |