Skip to content

Instantly share code, notes, and snippets.

Avatar

Takumi Sakamoto takus

View GitHub Profile
@takus
takus / IPC-Cmd-Sample.pl
Created Oct 8, 2011
Execute external openssl command by using IPC::Cmd
View IPC-Cmd-Sample.pl
use IPC::Cmd qw/can_run run/;
our $OPENSSL = can_run('openssl') or die 'openssl is not installed!';
my $ok = run(
verbose => 0,
command => [
"openssl", "enc",
"-e", "-aes256",
"-in", $input,
@takus
takus / find-all-files-in-directory.pl
Created Oct 9, 2011
Find all files in a directory
View find-all-files-in-directory.pl
opendir DH, $dir or die "Error: can't open $dir : $!";
while (my $file = readdir DH) {
next if $file =~ /^\.{1,2}$/;
print $file, "\n";
}
closedir DH;
@takus
takus / sample-File-Find.pl
Created Oct 9, 2011
Sample code of File::Find
View sample-File-Find.pl
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 Oct 9, 2011
Find all files under a base directory recursively
View find_all_files_recursively.pl
#!/usr/bin/env perl
my $base_dir = shift;
my $ref_files = &get_file_paths($base_dir);
for (@$ref_files) {
print "$_\n";
}
@takus
takus / copy_to_temp_file.pl
Created Oct 9, 2011
Create temp file from existing file
View copy_to_temp_file.pl
#!/usr/bin/env perl
use strict;
use warnings;
use File::Temp;
use File::Copy;
my $origin_file = shift;
@takus
takus / rm-with-trash.sh
Created Oct 11, 2011
hook script of rm
View rm-with-trash.sh
#!/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 Oct 13, 2011
Give multi arguments to cp when using xargs
View xargs-cp.sh
#!/bin/sh
find . -name '*.pdf' | xargs -i cp {} /tmp
@takus
takus / build.xml
Created Oct 25, 2011
ant example of building executable jar
View build.xml
<?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 Oct 25, 2011
ssh to remote host & execute command & stay at remote server after executing
View gist:1311351
ssh -t user@host "cd /path/to/dir && /bin/bash"
@takus
takus / output.gnu
Created Oct 28, 2011
Show realtime graph by gnuplot
View output.gnu
plot "output"
pause 0.1
reread
watch
You can’t perform that action at this time.