Skip to content

Instantly share code, notes, and snippets.

@yareally
yareally / SignalStrength.java
Created September 14, 2013 08:01
ugly decompiled signalstrength class from a hwu8185 that keeps crashing my signal app. Damn cheap ass devices ignore the proper way to do toString() for the API.
package android.telephony;
import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.Parcelable.Creator;
public class SignalStrength
implements Parcelable
{
#!/bin/sh
# venv_switch.sh
# switch between different virtual environments
# verify a virtualenv is passed in
if [ $# -ne 1 ]
then
echo 'Usage: venv_switch venv-label'
exit -1
fi
source ~/.bashrc
source ~/python-projects/virtualenv/activate
from tornado.wsgi import WSGIContainer
from tornado.httpserver import HTTPServer
from tornado.ioloop import IOLoop
from yourapplication import app
http_server = HTTPServer(WSGIContainer(app))
http_server.listen(5000)
IOLoop.instance().start()
@yareally
yareally / gist:6668832
Created September 23, 2013 10:38
Setting up Redis + Flask + Tornado and some other packages to do comet/async related stuff Will be adding as I go
# note that some commands may require root (sudo) in front of them
# -- installing python, tornado, flask and related packages --
# install aptitude for better package management (it's just an apt-get wrapper)
apt-get install aptitude
# install pip to deal with python package installs/updates
aptitude install python-pip
/**
* Test converting a Java Interface to a Scala Lambda
* via implicits.
*
* @author Wes Lanning
* @version 2013-10-12
*/
class ConvertInterfaceTest extends Activity
{
// converts Java Runnable implmentation to Scala automagically
@yareally
yareally / cyclone.py
Created October 14, 2013 02:54
Run tornado web server simultaneously with a Flask app
from flask import Flask
from tornado.web import RequestHandler, Application, FallbackHandler
from tornado.wsgi import WSGIContainer
from tornado.ioloop import IOLoop
from flask_main import app
class MainHandler(RequestHandler):
"""
import os
from redis import StrictRedis
from models.user import User
import scrypt
class UserHelper(object):
"""
Handles user queries to redis
@param redis_connection:
import os
from redis import StrictRedis
from models.user import User
import scrypt
class UserHelper(object):
"""
Handles user queries to redis
@yareally
yareally / rediswrapper.py
Created November 17, 2013 23:30
API wrapper to interact with flask
# coding=utf-8
import math
import os
from redis import StrictRedis, WatchError
import time
import uuid
from models.user import User
from models.message import Message
import scrypt