Skip to content

Instantly share code, notes, and snippets.

@newbyca
newbyca / hashtagTweeterWithMostSocialProof.py
Created January 4, 2012 04:08
find most followed user to send tweet with a given hashtag
#****************************************************
#a simple script that searchs all tweets with a given hashtag
#and finds which of the users sending those tweets has the most followers
#
#how is this useful? it probably isn't ...
#
#****************************************************
#required python packages:
#http://pypi.python.org/pypi/setuptools
#http://cheeseshop.python.org/pypi/simplejson
@newbyca
newbyca / AnimationLooper.java
Created March 11, 2012 23:31
workaround class for Android animation set repeatCount problem.
import android.view.View;
import android.view.ViewTreeObserver.OnGlobalLayoutListener;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.view.animation.Animation.AnimationListener;
public class AnimationLooper{
public static void start(final View v, final int animationResId){
v.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
@newbyca
newbyca / Typefaces.java
Created March 12, 2012 00:05
workaround class for Android Typeface.createFromAsset memory leak
public class Typefaces{
private static final Hashtable cache = new Hashtable();
public static Typeface get(Context c, String name){
synchronized(cache){
if(!cache.containsKey(name)){
Typeface t = Typeface.createFromAsset(
c.getAssets(),
String.format("fonts/%s.ttf", name)
@newbyca
newbyca / ListenableAsyncTask.java
Created May 9, 2012 00:00
Android ListenableAsyncTask: AsyncTask extension that lets you set an onPostExecute listener from a task's client
public abstract class ListenableAsyncTask<Params, Progress, Result> extends AsyncTask<Params, Progress, Result>{
@Override
protected final void onPostExecute(Result result) {
notifyListenerOnPostExecute(result);
}
private AsyncTaskListener<Result> mListener;
public interface AsyncTaskListener<Result>{
public void onPostExecute(Result result);
@newbyca
newbyca / tickersetup.js
Created May 31, 2012 02:56
setup script for google finance ticker
$(document).ready(function () {
$('div#ticker').googlefinanceticker({ tickers: 'goog,aapl,msft,csco,intc,ibm,att,bidu' });
});
@newbyca
newbyca / password.coffee
Created June 17, 2012 03:20
a password class i'm using in my nodejs project. i decided this abstraction was appropriate given a desire to create password hashs asyncly.
bcrypt = require 'bcrypt'
class password
text = null
salt = null
hash = null
@saltAndHash = (text, done) ->
bcrypt.genSalt (err, salt) ->
@newbyca
newbyca / jquery.validity.chosen.js
Created July 17, 2012 22:45
custom Validity outputMode that handles Chosen <select> controls
(function($) {
function getIdentifier($obj) {
return $obj.attr('id').length ?
$obj.attr('id') :
$obj.attr('name');
}
$.validity.outputs.labellocal = {
cssClass:"error",
<link rel="import" href="../components/polymer/polymer.html">
<polymer-element name="my-element">
<template>
<style>
:host {
position: absolute;
width: 100%;
height: 100%;
Verifying that +newbyca is my Bitcoin username. You can send me #bitcoin here: https://onename.io/newbyca
import os
import fnmatch
import unittest
import webapp2
import importlib
from time import clock
class RunUnitTests(webapp2.RequestHandler):
def get(self):