Skip to content

Instantly share code, notes, and snippets.

View moznion's full-sized avatar

moznion moznion

View GitHub Profile
@moznion
moznion / gist:3877609
Created October 12, 2012 06:22
grep-alias
#!/usr/bin/env perl
use strict;
use warnings;
my $grep_opt = "--color=auto";
if ($ARGV[0] =~ /^\-/) {
unless ($ARGV[2]) {
system("grep $grep_opt $ARGV[0] $ARGV[1] *");
@moznion
moznion / get_full_path.pl
Created October 18, 2012 13:17
Get full path of executing script
use FindBin;
sub get_full_path {
return $FindBin::Bin . '/' . $FindBin::Script;
}
@moznion
moznion / pdfpLaTeX.sh
Created October 18, 2012 15:00
Convert Japanese TeX file to PDF file
#!/bin/sh
platex $1
dvipdfmx $1
@moznion
moznion / old_get_full_path.pl
Created October 22, 2012 01:17
OLD VERSION!!! Current version is gist: 3911761.
use Cwd;
use File::Basename;
sub get_full_path {
my ($filename, $dir_path) = File::Basename::fileparse $0;
my $current_path = Cwd::getcwd();
$dir_path =~ s!^$current_path!!;
$dir_path =~ s!^\.?/!!;
return $current_path . '/' . $dir_path . $filename;
@moznion
moznion / .vimrc
Created October 24, 2012 05:14
vimrc file
"vim:set ts=8 sts=2 sw=2 tw=0:
"----------------------------------------------------------------------------
"Vundle
"
set nocompatible
filetype off
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
@moznion
moznion / gitConfig.sh
Last active October 12, 2015 00:38
Set up git
#!/bin/sh
# Alias
git config --global alias.br 'branch'
git config --global alias.ci 'commit'
git config --global alias.co 'checkout'
git config --global alias.di 'diff'
git config --global alias.dw 'diff --word-diff'
git config --global alias.l 'log --decorate'
git config --global alias.mg 'merge'
@moznion
moznion / gist:3967917
Created October 28, 2012 06:52
Sample code for perl beginners #5
my @list = (1,2,3,4,5,6,7,8,9,10);
foreach my $elem (@list) {
sleep(1);
print $elem;
}
@moznion
moznion / gist:4129859
Created November 22, 2012 07:47
Hook AssertionError by groovy
private shouldAssertionError(Closure c) {
try {
c.call();
fail ("Error");
} catch (AssertionError expected) {
assert true; // Successful
}
}
@moznion
moznion / gist:4134242
Created November 23, 2012 06:28
Sample source code written in Java
public class Sample {
private boolean isActive;
private boolean hoge;
private boolean fuga;
public final void foo() throws IllegalAccessException, NullPointerException {
if (!this.isActive) {
throw new AssertionError();
}
@moznion
moznion / gist:4134246
Created November 23, 2012 06:32
Reinventing shouldFail() part1
import groovy.util.GroovyTestCase
public class Test extends GroovyTestCase {
private shouldError(Closure c) {
try {
c.call()
assert false // Failure
} catch (Error expected) {
assert true //Successful