Skip to content

Instantly share code, notes, and snippets.

View ryochin's full-sized avatar
🏠
Working at home

Ryo Okamoto ryochin

🏠
Working at home
View GitHub Profile
@ryochin
ryochin / gist:1156124
Created August 19, 2011 05:35
Moonphase for Objective-C
@interface MoonPhase : NSObject {
@private
NSDate *now;
}
- (float) phase;
@end
// ---------------------------------------
@ryochin
ryochin / gist:1372456
Created November 17, 2011 05:38
'switch' with TTerse bug
#!/usr/bin/perl --
use strict;
use Text::Xslate;
my $xs = Text::Xslate->new(
syntax => 'TTerse',
);
my $template = <<'END';
@ryochin
ryochin / gist:1372787
Created November 17, 2011 09:33
number str is treated as int with Xslate
#!/usr/bin/perl --
use strict;
use Text::Xslate;
my $xs = Text::Xslate->new(
syntax => 'TTerse',
);
my $template = <<'END';
@ryochin
ryochin / ping-syn.pl
Created November 22, 2011 05:24
Net::Ping in 'syn' mode
#!/usr/bin/perl --
use strict;
use Net::Ping;
my $p = Net::Ping->new("syn");
$p->port_number( scalar getservbyname("http", "tcp") );
$p->hires(1);
my $host = shift @ARGV // "127.0.0.1";
@ryochin
ryochin / recover_incomplete_url_opml.pl
Created September 21, 2012 07:55
recover incomplete feed url for Fresh Reader broken OPML
#!/usr/bin/perl --
# fill real rss feed url for Fresh Reader broken OPML
use strict;
use warnings;
use Path::Class qw(file);
use CGI;
use Feed::Find;
use utf8;
@ryochin
ryochin / mysql_qcache_ratio
Created November 9, 2012 06:09
munin plugin: mysql query cache ratio
#!/usr/bin/perl --
# see also: mytop(1)
use strict;
use warnings;
use DBI;
use Cache::SharedMemoryCache;
my $config = {
dsn => $ENV{'mysqlconnection'} || 'DBI:mysql:mysql',
@ryochin
ryochin / build_for_iphoneos.sh
Last active December 11, 2015 08:58 — forked from fbettag/build_for_iphoneos.sh
libsox build script for iOS
#!/bin/bash
#
# for sox-14.4.0 on OSX 10.8 + Xcode 4.5
################################################################################
#
# Copyright (c) 2008-2009 Christopher J. Stawarz
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation files
@ryochin
ryochin / gist:4712585
Created February 5, 2013 06:03
my gitconfig
#
[color]
branch = auto
diff = auto
# diff = false
status = auto
[color "branch"]
current = yellow reverse
local = yellow
@ryochin
ryochin / pod-clipper
Created June 27, 2013 08:14
split perl source/pod to save to Mod.pm/Mod.pod
#!/usr/bin/env perl
# split perl source/pod to save to Mod.pm/Mod.pod
use strict;
use warnings;
use Path::Class qw(file);
use Pod::Clipper;
my $file = shift @ARGV or die "usage: $0 <perl module file>";
@ryochin
ryochin / timemachine_find_large_files.pl
Created July 24, 2013 03:40
make a sorted list of 'tmutil compare' by file size, in order to find large ones.
#!/usr/bin/env perl
use strict;
use warnings;
use Term::ANSIColor qw(:constants);
use Number::Bytes::Human ();
use utf8;
my $from = shift @ARGV or die "usage: $0 <from> <to>";