Skip to content

Instantly share code, notes, and snippets.

@f99aq8ove
f99aq8ove / seq.pl
Created August 12, 2008 17:43
seq implementation in perl
#!/usr/bin/env perl
use strict;
use warnings;
my @args = @ARGV;
my %opt;
$opt{f} = '%g';
foreach (@args) {
// ==UserScript==
// @name youtube tweaks
// @description Add H.264 version link and .mp4 file link
// @namespace f99aq8ove.net
// @include http://*.youtube.com/watch?*
// ==/UserScript==
var video_file_url = function(fmt) {
var s = unsafeWindow.yt.getConfig("SWF_ARGS");
return "http://" + location.host + "/get_video?" +
@f99aq8ove
f99aq8ove / sysctl_cpufreq
Created January 24, 2009 05:05
munin plugin to show CPU frequency using sysctl for FreeBSD
#!/bin/sh
#
# CPU frequency from sysctl
#
if [ "$1" = "config" ]; then
echo "graph_title CPU frequency"
echo 'graph_category system'
echo "graph_info This graph shows the cpu frequency"
@f99aq8ove
f99aq8ove / get_launchpad_keys.sh
Created January 31, 2009 05:00
get launchpad PPA's keys
#!/bin/sh
for i in `perl -nle'print "https://launchpad.net/~$1/+archive/ppa" if m!deb\s+http://ppa\.launchpad\.net/(.+?)/!' /etc/apt/sources.list`; do
wget -q -O- "`wget -q -O- "$i" | perl -nle'print "http://keyserver.ubuntu.com:11371/pks/lookup?op=get&search=0x$1" if m!"http://keyserver.ubuntu.com:11371/pks/lookup\?search=.+?([[:xdigit:]]{16})&!'`" | sudo apt-key add -
done
@f99aq8ove
f99aq8ove / zfs_snapshot.sh
Created February 4, 2009 14:19
zfs snapshot auto-rotation script
#!/bin/sh
#
# zfs snapshot auto-rotation
#
# usage: zfs_snapshot.sh <mountpoint> <snapshot name> <number of keeping snapshots> [recursive]
#
# recursive option: Recursively create snapshot (zfs snapshot -r)
#
# for crontab
#
package MyCassandra;
use Any::Moose;
use namespace::autoclean;
use Net::Cassandra;
use Data::MessagePack;
use Data::Dumper;
use Encode;
has 'keyspace' => (is => 'ro', isa => 'Str');
--- a/portupgrade 2010-11-14 14:46:24.112307993 +0900
+++ b/portupgrade 2010-11-14 14:47:29.271209261 +0900
@@ -1001,7 +1001,7 @@
rescue IgnoreMarkError => e
$results << PkgResult.new(origin, :ignored, pkgname)
rescue => e
- $results << PkgResult.new(origin, e, pkgname)
+ $results << PkgResult.new(origin.nil? ? "nil" : origin, e, pkgname)
ensure
$use_packages, $use_packages_only = use_packages, use_packages_only
@f99aq8ove
f99aq8ove / gist:791181
Created January 22, 2011 15:32
parse JSON only
--- a/Stream.pm 2011-01-23 00:27:05.243140965 +0900
+++ b/Stream.pm 2011-01-23 00:28:17.402025511 +0900
@@ -154,7 +154,7 @@
my($handle, $json) = @_;
# Twitter stream returns "\x0a\x0d\x0a" if there's no matched tweets in ~30s.
$set_timeout->();
- if ($json) {
+ if ($json && $json =~ /^{/) {
my $tweet = $decode_json ? JSON::decode_json($json) : $json;
if ($on_delete && $tweet->{delete} && $tweet->{delete}->{status}) {
@f99aq8ove
f99aq8ove / unused_compat_libs
Created May 2, 2012 11:26
Find out unused compat libraries for FreeBSD.
#!/bin/sh -e
ldd_list=$(mktemp -t lddlist)
if [ $? = 0 ]; then
trap "rm -f '$ldd_list'" EXIT
fi
set +e
ldd /usr/local/bin/* /usr/local/lib/*.so* > "$ldd_list" 2> /dev/null
set -e
@f99aq8ove
f99aq8ove / dedupe.pl
Created May 5, 2012 09:44
dedupe duplicated files using hard-linking.
#!/usr/bin/env perl
use strict;
use warnings;
use File::Spec;
use Getopt::Long;
use Pod::Usage;
use Data::Dumper;