Skip to content

Instantly share code, notes, and snippets.

View mikelikespie's full-sized avatar

Mike Lewis mikelikespie

View GitHub Profile
@mikelikespie
mikelikespie / hbase_clone_table.rb
Created December 8, 2010 21:03
clones a table in hbase. Optionally takes an array of strings that are the keys to create the splits on
def clone_table(old_table_name, new_table_name, split_keys=nil)
admin = HBaseAdmin.new(HBaseConfiguration.new())
td = admin.getTableDescriptor(old_table_name.to_java_bytes)
td.setName(new_table_name.to_java_bytes)
if split_keys.nil?
admin.createTable(td)
else
new_keys = Java::byte[][split_keys.size].new
split_keys.each_index {|i| new_keys[i] = split_keys[i].to_java_bytes}
@mikelikespie
mikelikespie / NSArray+enumerableStuff.h
Created January 15, 2011 21:50
Some fun stuff for enumerating
@interface NSArray (EnumerableStuff)
/**
* similar to a map
*/
- (NSArray *) objectsTransformedByBlock:(id (^)(id, NSUInteger, BOOL *))block;
/**
* filter the array
*/
@interface NSArray (EnumerableExtras)
/**
* similar to a map
*/
- (NSArray *) objectsTransformedByBlock:(id (^)(id obj, NSUInteger idx, BOOL *stop))block;
/**
* filter the array
*/
@mikelikespie
mikelikespie / NSIndexPath+Hax.m
Created February 10, 2011 18:29
UITableView performance hax
#import "NSIndexPath+RowSectinCache.h"
@interface PairIndexPath : NSObject {
@private
NSUInteger indexes[2];
}
- (NSUInteger)length;
@mikelikespie
mikelikespie / pipes-client.py
Created April 19, 2011 08:18
Lazy Pipeline Wrapper for redis-py
import redis
from cStringIO import StringIO
import weakref
import contextlib
from collections import deque
def main():
c = PipesClient('localhost')
@mikelikespie
mikelikespie / CCBlockTableViewDataSource.h
Created May 4, 2011 18:55 — forked from omnivector/CCBlockTableViewDataSource.h
Block based data source / delegate
//
// CCBlockTableViewDataSource.h
//
// Created by Tristan O'Tierney on 1/24/11.
//
#import <UIKit/UIKit.h>
@interface CCBlockTableViewDataSource : NSObject <UITableViewDataSource, UITableViewDelegate> {
@mikelikespie
mikelikespie / parseobjcsig.py
Created August 18, 2011 20:23
Parsing and formatting Objective C signatures
# -*- coding: utf-8 -*-
"""
sphinx.domains.objc
~~~~~~~~~~~~~~~~~~~
The Objective C domain.
"""
import re
@mikelikespie
mikelikespie / PGGeometry.hh
Created September 25, 2011 20:28
Wrappers to overload operations with CGPoint, CGSize, and CGRect.
//
// PGGeometry.hh
// PonyGrid
//
// Created by Mike Lewis on 9/23/11.
// Copyright (c) 2011 Square, Inc. All rights reserved.
//
#ifndef PonyGrid_PGGeometry_hh
#define PonyGrid_PGGeometry_hh
@mikelikespie
mikelikespie / gram.go
Created January 30, 2012 08:45
Gram.y converted to go without types & functions implemented yet... trying to see if I can get Postgres's parser running in go.
//line simplegram.y:2
package main
//line simplegram.y:6
type yySymType struct {
yys int
core_yystype core_YYSTYPE
/* these fields must match core_YYSTYPE: */
ival int
str string
@mikelikespie
mikelikespie / versions.sql
Created February 14, 2012 21:01
Versioned items with rules
drop schema if exists foo cascade;
create schema foo;
CREATE TABLE foo.object (
id uuid primary key,
version int4 not null
);
CREATE TABLE foo.items_base (