Skip to content

Instantly share code, notes, and snippets.

View jonjensen's full-sized avatar

Jon Jensen jonjensen

View GitHub Profile
@jonjensen
jonjensen / MediaPlayer-excerpt.java
Created March 2, 2011 07:27
simplified example of Android sound player
/**
* Convenience method to create a MediaPlayer for a given resource id.
* On success, {@link #prepare()} will already have been called and must not be called again.
* <p>When done with the MediaPlayer, you should call {@link #release()},
* to free the resources. If not released, too many MediaPlayer instances will
* result in an exception.</p>
*
* @param context the Context to use
* @param resid the raw resource id (<var>R.raw.&lt;something></var>) for
* the resource to use as the datasource
@jonjensen
jonjensen / jsonpp.pl
Created February 2, 2011 04:04
JSON pretty-printer
#!/usr/bin/env perl
use JSON;
my $json = JSON->new;
undef $/;
while (<>) {
print $json->pretty->encode($json->decode($_));
}
@jonjensen
jonjensen / watch-entropy_avail.pl
Created July 22, 2010 05:10
Script to watch Linux kernel entropy level
#!/usr/bin/perl
use strict;
use warnings;
use Time::HiRes 'usleep';
while (1) {
open my $in, '<', '/proc/sys/kernel/random/entropy_avail' or die;
print <$in>;
close $in;
#!/usr/local/bin/perl
use strict;
use warnings;
use Encode;
use IsUTF8 'isUTF8';
binmode(STDIN);
binmode(STDOUT);
binmode(STDERR);
--- edit-server.orig 2010-01-04 20:13:01.000000000 -0700
+++ edit-server 2010-01-04 20:12:34.000000000 -0700
@@ -73,7 +73,7 @@
}
my $len = $header{'content-length'};
- unless ($len) {
+ unless (length $len) {
http_header($fh, 500, 'Invalid request -- no content-length.');
close $fh;
#!/usr/bin/perl
# A simple web server that just listens for textarea filter requests
# and runs an editor to manipulate the text. Is intended to be
# used with the TextAid extention for Chrome.
use strict;
use warnings;
use threads;
use threads::shared;
use Socket;
#!/usr/bin/perl
# Gmail notes converter
# by Jon Jensen <[email protected]>
# 2009-07-20
# Copyright 2009 Jon Jensen. Distributed under the GPLv3 license.
# For details see http://www.gnu.org/licenses/gpl-3.0.html
# When importing e.g. Nokia phone contacts into Gmail, most fields are