Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Stewart Henderson bowlofstew

🎯
Focusing
View GitHub Profile
View build.gradle
/*
* The plugins used for this build.
*/
/*
* Provides the compile, test, jar, etc tasks
*/
apply plugin: 'java'
/*
* Generates the Eclipse project files.
@bowlofstew
bowlofstew / gist:011fb2283ebe4a622b3c
Last active Aug 29, 2015
General environment setup for Java7/8, SBT, Kafka, Akka, and Scala
View gist:011fb2283ebe4a622b3c
sudo apt-get update
sudo apt-get install python-software-properties
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
#This is fine for Zookeeper or Kafka
sudo apt-get install oracle-java7-installer
#We require this on our other servers
#sudo apt-get install oracle-java8-installer
View redis_setup
#Mount EBS volume
#Check drives
lsblk
sudo mkdir /data
sudo mount {device_name} /data
# Install Redis
apt-get update
apt-get upgrade
apt-get install redis-server
@bowlofstew
bowlofstew / amazon_api_install
Created Jun 13, 2014
Installation information for Python Amazon API information.
View amazon_api_install
sudo apt-get install python-pip
sudo apt-get install git
sudo apt-get install python-lxml
sudo pip install python-dateutil
sudo pip install redis
sudo pip install git+https://github.com/yoavaviram/python-amazon-simple-product-api.git
View pyconindia_dsl.py
from pyparsing import *
# By default, PyParsing treats \n as whitespace and ignores it
# In our grammer, \n is significant, so tell PyParsing not to ignore it
ParserElement.setDefaultWhitespaceChars(" \t")
def parse(input_string):
def convert_prop_to_dict(tokens):
"""Convert a list of field property tokens to a dict"""
prop_dict = {}
View keybase.md

Keybase proof

I hereby claim:

  • I am bowlofstew on github.
  • I am stewart (https://keybase.io/stewart) on keybase.
  • I have a public key whose fingerprint is 156C 390E C672 CEF9 FDFE 3C71 843E 4EE7 7C5A EE67

To claim this, I am signing this object:

View state_monad.cpp
#include <utility>
#include <iostream>
struct void_
{
template<typename Stream>
friend Stream &operator<<(Stream &s, void_)
{
return s << "()";
}
View Rationale.md

If you don't care about the explanation, scroll down to find the code, it's 50 some odd lines and written by someone who doesn't know any better. You have been warned.

What it does

This is a very simple proof of concept jitting RPN calculator implemented in python. Basically, it takes the source code, tokenizes it via whitespace, and asks itself one simple question: am I looking at a number or not?

First, let's talk about the underlying program flow. Pretend that you are a shoe connoisseur with a tiny desk. You may only have two individual shoes on that desk at any one time, but should you ever purchase a new one or get harassed by an unruly shoe salesman without realizing that you have the power to say no (or even maybe?), you can always sweep aside one of the two shoes on the desk (the one on the right, because you're a lefty and you feel that the left side is always superior) onto the messy floor, put the other shoe on the right hand side, and then place your newly acquired shoe in

View echo.cxx
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <stdlib.h>
#include <ev++.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <resolv.h>
#include <errno.h>
#include <list>
View sort vs sort
// c++ -std=c++11 -O3 sort.cpp ; ./a.out
// qsort: 674 ms
// std::sort: 1104 ms
#include <string.h>
#include <stdio.h>
#include <chrono>
#include <string>
#include <vector>
#include <iostream>