Skip to content

Instantly share code, notes, and snippets.

View imsickofmaps's full-sized avatar

Mike Jones imsickofmaps

View GitHub Profile
@imsickofmaps
imsickofmaps / gist:3437580
Created August 23, 2012 15:10
all in list test
allin = True
present = ["harry", "bob", "nancy"]
required = ["bob","harry","fred"]
for x in required:
if x not in present:
allin = False
@imsickofmaps
imsickofmaps / mr.py
Created October 9, 2012 16:01
riak mapreduce problems
query = riakclient.add('products')
query.map("""
function(v, arg) {
var data = JSON.parse(v.values[0].data);
if(data.category == arg.category) {
return [[v.key, arg.category]];
} else {
return [];
}
}""", {"category":"food"})
@imsickofmaps
imsickofmaps / bucket_data
Created November 22, 2012 15:08
MapReduce Challenge - sort by non-key value
{
"5af5c2c8144a11e28f9f001c14010046": {
"category": "clothing",
"available": 20,
"pricefrom": 180.0,
"title": "2-Pack Heart Top",
"created": 1350032036,
"lastUpdated": 1351691717
}
},
@imsickofmaps
imsickofmaps / gist:4612905
Last active December 11, 2015 14:18
HOW-TO: Set-up, configure and use Riak Search on existing buckets with Python

HOW-TO: Set-up, configure and use Riak Search on existing buckets with Python

1. Enable search on nodes

From Riak docs:

Riak Search is enabled in the app.config file. Simply change the setting to “true” in Riak Search Config section (shown below).

%% Riak Search Config 
@imsickofmaps
imsickofmaps / wcl-vumi-go.rb
Created March 12, 2013 17:22
Chef script to get Ubuntu Precise 64bit ready for vumi-go pip install...
#
# Cookbook Name:: wcl-vumi-go
# Recipe:: default
#
# Copyright 2013, Western Cape Labs
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
@imsickofmaps
imsickofmaps / app.config
Created March 12, 2013 17:39
Riak config for vumi-go in /etc/riak/
DEFAULT:
{storage_backend, riak_kv_bitcask_backend},
CHANGE TO:
{storage_backend, riak_kv_eleveldb_backend},
DEFAULT:
%% Riak Search Config
{riak_search, [
%% To enable Search functionality set this 'true'.
@imsickofmaps
imsickofmaps / Vagrantfile
Created March 13, 2013 10:35
Example Vagrantfile for vumi-go
Vagrant::Config.run do |config|
config.vm.box = "precise64"
# Port forwarding
## Nginx
#config.vm.forward_port 8080, 8080
## shares
# change ../code/vumi-go to whereever your clone of vumi-go is locatated
@imsickofmaps
imsickofmaps / GETTING_STARTED.md
Last active December 14, 2015 21:28
Vumi-go getting started notes

Getting started with vumi-go

Author: Mike Jones
All bad practices and advice is entirely the fault of the author

These notes are in addition to these

Source

Github repo

@imsickofmaps
imsickofmaps / scaleconf.py
Created April 20, 2013 12:18
New and improved version of smitter - twitter-clone over SMS. Build on top of ScaleConf workshop instructions http://vumi.readthedocs.org/en/latest/intro/scaleconf03.html
from twisted.internet.defer import inlineCallbacks, returnValue
from vumi.application import ApplicationWorker
from vumi.persist.txredis_manager import TxRedisManager
from vumi.config import ConfigDict
class SmitterApplicationConfig(ApplicationWorker.CONFIG_CLASS):
redis_manager = ConfigDict(
"Redis client configuration.", default={}, static=True)
choices = ["totes", "cool", "NSFW", "awesome"]
count = 0
for choice in choices:
count +=1
if count == 1:
print "I'm the first"
elif count == len(choices):
print "I'm the last"
else:
print "I'm in the middle somewhere"