Skip to content

Instantly share code, notes, and snippets.

View jonjensen's full-sized avatar

Jon Jensen jonjensen

View GitHub Profile
#!/usr/bin/perl
# Gmail notes converter
# by Jon Jensen <jon@endpoint.com>
# 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
#!/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;
--- 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/local/bin/perl
use strict;
use warnings;
use Encode;
use IsUTF8 'isUTF8';
binmode(STDIN);
binmode(STDOUT);
binmode(STDERR);
@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;
@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 / 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 / data-tag-cache.patch
Created February 3, 2012 21:38
Interchange data tag cache
From pbg@web55.eppg.com Tue Apr 2 12:02:15 2002
Date: Fri, 22 Mar 2002 17:05:37 -0600
From: pbg <pbg@web55.eppg.com>
To: jon@redhat.com
Subject: diff
--- X Fri Mar 22 17:03:55 2002
+++ lib/Vend/Data.pm Fri Mar 22 17:03:00 2002
@@ -191,7 +191,9 @@
return '' unless defined $db->test_column($field_name);
@jonjensen
jonjensen / rhel6-ipv6-network
Created February 27, 2012 20:03
RHEL 6 IPv6 default source address
# Linux's default source address selection for multiple IPv6 addresses on the
# same interface leaves a lot to be desired. See:
# http://www.akkadia.org/drepper/linux-rfc3484.html
#
# The RFC 3484 method described there and used in gai.conf feels like the
# wrong way to me, so I used the approach documented here:
# http://www.davidc.net/networking/ipv6-source-address-selection-linux
# and mark all but the main IPv6 source address as "deprecated" so they
# won't be used as default source addresses (but otherwise function fine).
#
@jonjensen
jonjensen / kill-large-processes.pl
Created August 30, 2012 20:52
Script to automatically kill large processes
#!/usr/local/bin/perl
use strict;
use warnings;
use Proc::ProcessTable;
my $table = Proc::ProcessTable->new;
for my $process (@{$table->table}) {
# skip root processes