Skip to content

Instantly share code, notes, and snippets.

@takus
takus / sample-File-Find.pl
Created October 9, 2011 10:17
Sample code of File::Find
use File::Find;
my $dir = '/home/takus';
find(\&print_file, $dir);
sub print_file {
print $File::Find::name, "\n";
}
@takus
takus / find_all_files_recursively.pl
Created October 9, 2011 12:27
Find all files under a base directory recursively
#!/usr/bin/env perl
my $base_dir = shift;
my $ref_files = &get_file_paths($base_dir);
for (@$ref_files) {
print "$_\n";
}
@takus
takus / rm-with-trash.sh
Created October 11, 2011 02:06
hook script of rm
#!/bin/sh
# hook script of rm
#
# Setup
# alias rm="foo/bar/rm-with-trash.sh"
trash=$HOME/.trash
if [ ! -d $trash ]
@takus
takus / xargs-cp.sh
Created October 13, 2011 15:34
Give multi arguments to cp when using xargs
#!/bin/sh
find . -name '*.pdf' | xargs -i cp {} /tmp
@takus
takus / build.xml
Created October 25, 2011 05:00
ant example of building executable jar
<?xml version="1.0" encoding="UTF-8"?>
<project name="make_exec_jar" default="jar" basedir="." >
<target name="jar">
<jar basedir="../classes" jarfile="hello.jar">
<manifest>
<attribute name="Main-Class" value="me.takus.sample.Hello"/>
</manifest>
</jar>
</target>
</project>
@takus
takus / gist:1311351
Created October 25, 2011 05:01
ssh to remote host & execute command & stay at remote server after executing
ssh -t user@host "cd /path/to/dir && /bin/bash"
@takus
takus / output.gnu
Created October 28, 2011 04:42
Show realtime graph by gnuplot
plot "output"
pause 0.1
reread
watch
@takus
takus / slow_query_log_dump.pl
Created March 27, 2012 23:34
Fetches slow query logs from slow_log table of Amazon RDS
#!/usr/bin/env perl
=pod
Fetches slow query logs from slow_log table of Amazon RDS.
Things to change in this script for your own setup:
<root_user> to your rds root user (e.g. "root")
<root_pass> to your rds root password (e.g. "password")
<host_domain> to your rds host domain (e.g. "hoge.ap-northeast-1.rds.amazonaws.com")
@takus
takus / mongo-purge.pl
Created April 1, 2012 16:12
Purge unnecessary logs from MongoDB
#!/usr/bin/env perl
=pod
purge unnecessary logs from MongoDB
=cut
use strict;
use warnings;
use MongoDB;
@takus
takus / .perltidyrc
Created April 10, 2012 11:15
.perltidyrc described in "Perl Best Practice"
# Max line width is 78 cols
-l=78
# Indent level is 4 cols
-i=4
# Continuation indent is 4 cols
-ci=4
# Output to STDOUT