Skip to content

Instantly share code, notes, and snippets.

View dokkaebi's full-sized avatar

Austin Lally dokkaebi

  • WxH, Inc.
  • Waynesboro, PA
View GitHub Profile
@dokkaebi
dokkaebi / gist:25dfed8d30bdecf8db8eb0269dd2705c
Created April 11, 2018 19:05
Scala - arbitrary length chained futures where each depends on the result of the previous
def pieceOfWork(i: Int): Int = new Random().nextInt(10) + i
def eventualWork(i: Int): Future[Int] = Future {
println(s"eventualWork $i")
Thread.sleep(500)
val r = pieceOfWork(i)
println(s"returning $r")
r
}
def findMoreThan(total: Int): Future[Int] = {
val promise = Promise[Int]()
@dokkaebi
dokkaebi / sql_printing_middleware.py
Created September 9, 2015 18:38
Django middleware to print nicely colored list of sql queries at the end of each request
class SQLPrintingMiddleware(object):
"""
Middleware which prints out a list of all SQL queries done
for each view that is processed. This is only useful for debugging.
https://gist.github.com/vstoykov/1390853
Modified locally to depend on settings.DEBUG_SQL, as I don't think this is something we generally want on a dev box.
Also added some more coloring, and a line to hide the (usually long) list of fields in the select clause.
"""
@dokkaebi
dokkaebi / gist:4173446
Created November 30, 2012 02:39
Android: Set listview item heights to fill available listview height.
public class MyAdapter extends SimpleCursorAdapter {
// constructor, etc...
@Override
public void bindView(View view, Context context, Cursor cursor) {
super.bindView(view, context, cursor);
// Stretch list item height if there are too few to fill the content area.
ListView listView = getListView();
@dokkaebi
dokkaebi / gist:2980960
Created June 24, 2012 01:42
fast failing Django test case
class FastFailingTest(TestCase):
"""
A TestCase that stops execution of the suite if it fails.
"""
def run(self, result=None):
if result is None:
result = self.defaultTestResult()
failfast = result.failfast
result.failfast = True
@dokkaebi
dokkaebi / gist:2606921
Created May 6, 2012 01:38
ICS WebView local HTML5 video crash
D/AwesomePlayer( 112): Failed to open file, all profile flags have to set through setprop method.
I/MPEG4Extractor( 112): NON-QT MODE DECIDED
D/NvOsDebugPrintf( 112): NvxLiteH264DecoderInit : Opening TVMR H264 block
I/OMXCodec( 112): [OMX.Nvidia.h264.decode] AVC profile = 66 (Baseline), level = 30
I/OMXCodec( 112): [OMX.Nvidia.h264.decode] video dimensions are 320 x 240
I/OMXCodec( 112): [OMX.Nvidia.h264.decode] Crop rect is 320 x 240 @ (0, 0)
D/NvOsDebugPrintf( 112): NvMMLiteOpen : Block : BlockType = 261
D/NvOsDebugPrintf( 112): ++++++ NvAvpOpen +++++++
D/NvOsDebugPrintf( 112): ++++++++++++ TVMRFrameDelivery +++++++++++++++
D/NvOsDebugPrintf( 112): NvMMLiteBlockCreate : Block : BlockType = 261