Skip to content

Instantly share code, notes, and snippets.

View jyotty's full-sized avatar

Joshua Yotty jyotty

View GitHub Profile
#!/usr/bin/perl
# simple unicode lookup CGI script
use Modern::Perl;
use Encode qw(decode_utf8);
use CGI::Simple;
use DBI;
# let me out of this Issue Two
# Hmmm… mqueue keeps piling up with hundreds of thousands of messages. But let's not diagnose anything.
#!/usr/bin/perl
@listofqueue = `ls -1 /var/spool/mqueue`;
foreach $queuedmsg(@listofqueue){
chomp $queuedmsg;
# And to think, it only took two minutes of searching to express the perl one-liner in awk.
# I'm totally going to learn awk now, it will save so many tenths of a second.
$ time perl -lane '$sum += $F[-1];' -e 'END {print $sum;}' access_log*
1920844557
real 0m0.134s
user 0m0.134s
sys 0m0.005s
$ time awk '{sum += $NF} END { print sum }' access_log*
# this causes a 'null PMC access' in rakudo
# which is an obvious improvement.
use v6;
grammar Apache {
regex TOP {
<directive>+
}
$ ping google.com
PING google.com (74.125.67.100): 56 data bytes
64 bytes from 74.125.67.100: icmp_seq=0 ttl=55 time=2354.364 ms
64 bytes from 74.125.67.100: icmp_seq=1 ttl=55 time=2377.646 ms
64 bytes from 74.125.67.100: icmp_seq=2 ttl=55 time=3527.856 ms
64 bytes from 74.125.67.100: icmp_seq=3 ttl=55 time=4063.793 ms
64 bytes from 74.125.67.100: icmp_seq=8 ttl=55 time=906.274 ms
64 bytes from 74.125.67.100: icmp_seq=9 ttl=55 time=110.338 ms
64 bytes from 74.125.67.100: icmp_seq=10 ttl=55 time=338.959 ms
64 bytes from 74.125.67.100: icmp_seq=11 ttl=55 time=977.077 ms
# provided the item in Keychain Access has the exact hostname
# in the 'name' field and the exact username in the 'account' field,
# this will output the password when given user@host in $1
# (You'll be prompted by OS X, obviously)
# Make it a service with Automator in Snow Leopard with Run Shell Script,
# Pass input as arguments.
security find-generic-password -a ${1%%@*} -s ${1##*@} -g 2>&1 1>/dev/null | sed 's/password: "\(.*\)"/\1/'
var hashloc = "";
new PeriodicalExecuter(function() {
if (hashloc != window.location.hash) {
hashloc = window.location.hash;
if (hashloc) {
var url = hashloc.slice(1);
new Ajax.Updater("content", "/foo" + url, {method: 'get', evalScripts: true});
}
}
}, 0.1);
# adapted from http://www.tobehurd.org/blog/development/usersites.html
#<Perl>
#use Apache2::PerlSections;
#$Apache2::PerlSections::Save = 1;
use File::Spec::Functions;
my %ip_map = (
'host.name1.com' => 'IP.AD.DRE.SS1:443',
'host.name2.net' => 'IP.AD.DRE.SS2:443',
'host.name3.org' => 'IP.AD.DRE.SS3:443',
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>org.collectd.collectd</string>
<key>ProgramArguments</key>
<array>
<string>/opt/collectd/sbin/collectd</string>
<string>-f</string>
$ ./configure --prefix=/usr/local/collectd --without-included-ltdl
checking build system type... i386-unknown-freebsd7.2
checking host system type... i386-unknown-freebsd7.2
checking for gcc... gcc
blah blah blah
checking whether libtool supports -dlopen/-dlpreopen... yes
checking for ltdl.h... no
checking where to find libltdl headers... -I${top_srcdir}/libltdl