Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am f99aq8ove on github.
  • I am f99aq8ove (https://keybase.io/f99aq8ove) on keybase.
  • I have a public key ASDlDUOrJ9iwcuK35e46gPOwdiEodKSeOhWQ9V_nGwGPEQo

To claim this, I am signing this object:

@f99aq8ove
f99aq8ove / filename_normalizer.pl
Created January 4, 2014 22:47
Rename NFD directory/file name to NFC directory/file name recursively.
#!/usr/bin/perl
use strict;
use warnings;
use encoding 'utf-8';
use Unicode::Normalize;
use File::Basename qw/fileparse/;
use Getopt::Long;
my $noexecute = 0;
@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;
@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 / 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}) {
--- 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
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');
@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
#
@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 / 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"