Skip to content

Instantly share code, notes, and snippets.

View tylertreat's full-sized avatar

Tyler Treat tylertreat

View GitHub Profile
@tylertreat
tylertreat / gist:4464869
Last active December 10, 2015 16:59
Method used to extract classes.dex from an APK and copy it to a cache directory for processing.
private void extractDex(String apk) {
try {
JarFile file = new JarFile(apk);
Enumeration<JarEntry> entries = file.entries();
while (entries.hasMoreElements()) {
JarEntry entry = entries.nextElement();
if (entry.getName().equals("classes.dex")) {
File cache = getDir("dex_cache", Context.MODE_PRIVATE);
if (!cache.exists())
cache.mkdirs();
@tylertreat
tylertreat / to_dict.py
Last active December 28, 2015 04:18
ndb/db to dict
import datetime
import time
from google.appengine.ext import db
from google.appengine.ext import ndb
def to_dict(model):
"""Convert a db or ndb entity to a json-serializable dict."""
output = {}
@tylertreat
tylertreat / Dockerfile
Created February 6, 2014 05:47
Docker container for a Python WSGI application.
# Container for a Python WSGI application.
FROM ubuntu:12.04
MAINTAINER Tyler Treat <tyler.treat@webfilings.com>
RUN apt-get update
# Install Python tools
RUN apt-get install -y python python-dev python-distribute python-pip
@tylertreat
tylertreat / cache.py
Created April 29, 2014 21:05
Python Redis Cache
import cPickle
import logging
import redis
TIMEOUT = 60 * 60
_redis = None
package main
import (
"fmt"
"sync"
"time"
)
const maxThread = 16
package main
import (
"fmt"
"strconv"
"time"
"github.com/gdamore/mangos"
"github.com/gdamore/mangos/protocol/pub"
"github.com/gdamore/mangos/protocol/sub"
package main
import (
"fmt"
"log"
"os"
"github.com/Shopify/sarama"
)
package nsq
import (
"github.com/bitly/go-nsq"
"github.com/tylertreat/Flotilla/flotilla-server/daemon/broker"
)
const topic = "test"
type NSQPeer struct {
func start(host string) {
pub := NewNSQPeer(host)
for i := 0; i < 1000; i++ {
message := getMessage()
pub.Send(message)
}
pub.Teardown()
}
$ iptables -A INPUT -m statistic --mode random --probability 0.1 -j DROP
$ iptables -A OUTPUT -m statistic --mode random --probability 0.1 -j DROP