changeset 237:0d008b554aac

Merge with moefetch! Probably shouldn't be done but it's just much more convenient this way.
author Edho Arief <edho@myconan.net>
date Sun, 02 Oct 2011 04:33:47 +0700
parents e2a96553da9a (diff) 515ffebe9bba (current diff)
children 5dcbf6ab0109 73e90355bbd7
files
diffstat 41 files changed, 1926 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.hgignore	Sun Oct 02 04:33:47 2011 +0700
@@ -0,0 +1,2 @@
+\.orig$
+\.swp$
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LICENSE	Sun Oct 02 04:33:47 2011 +0700
@@ -0,0 +1,13 @@
+Copyright (c) 2010-2011, Edho Arief <edho@myconan.net>
+
+Permission to use, copy, modify, and/or distribute this software for any
+purpose with or without fee is hereby granted, provided that the above
+copyright notice and this permission notice appear in all copies.
+
+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bin/256colors2.pl	Sun Oct 02 04:33:47 2011 +0700
@@ -0,0 +1,63 @@
+#!/usr/bin/perl
+# Author: Todd Larason <jtl@molehill.org>
+# $XFree86: xc/programs/xterm/vttests/256colors2.pl,v 1.2 2002/03/26 01:46:43 dickey Exp $
+
+# use the resources for colors 0-15 - usually more-or-less a
+# reproduction of the standard ANSI colors, but possibly more
+# pleasing shades
+
+# colors 16-231 are a 6x6x6 color cube
+for ($red = 0; $red < 6; $red++) {
+    for ($green = 0; $green < 6; $green++) {
+	for ($blue = 0; $blue < 6; $blue++) {
+	    printf("\x1b]4;%d;rgb:%2.2x/%2.2x/%2.2x\x1b\\",
+		   16 + ($red * 36) + ($green * 6) + $blue,
+		   ($red ? ($red * 40 + 55) : 0),
+		   ($green ? ($green * 40 + 55) : 0),
+		   ($blue ? ($blue * 40 + 55) : 0));
+	}
+    }
+}
+
+# colors 232-255 are a grayscale ramp, intentionally leaving out
+# black and white
+for ($gray = 0; $gray < 24; $gray++) {
+    $level = ($gray * 10) + 8;
+    printf("\x1b]4;%d;rgb:%2.2x/%2.2x/%2.2x\x1b\\",
+	   232 + $gray, $level, $level, $level);
+}
+
+
+# display the colors
+
+# first the system ones:
+print "System colors:\n";
+for ($color = 0; $color < 8; $color++) {
+    print "\x1b[48;5;${color}m  ";
+}
+print "\x1b[0m\n";
+for ($color = 8; $color < 16; $color++) {
+    print "\x1b[48;5;${color}m  ";
+}
+print "\x1b[0m\n\n";
+
+# now the color cube
+print "Color cube, 6x6x6:\n";
+for ($green = 0; $green < 6; $green++) {
+    for ($red = 0; $red < 6; $red++) {
+	for ($blue = 0; $blue < 6; $blue++) {
+	    $color = 16 + ($red * 36) + ($green * 6) + $blue;
+	    print "\x1b[48;5;${color}m  ";
+	}
+	print "\x1b[0m ";
+    }
+    print "\n";
+}
+
+
+# now the grayscale ramp
+print "Grayscale ramp:\n";
+for ($color = 232; $color < 256; $color++) {
+    print "\x1b[48;5;${color}m  ";
+}
+print "\x1b[0m\n";
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bin/basicopt	Sun Oct 02 04:33:47 2011 +0700
@@ -0,0 +1,11 @@
+#!/bin/sh
+get_filename() {
+	printf "%s\n" "$*" | sed -e 's/^\(.*\)\.[^.]*$/\1/'
+}
+get_extension() {
+	if [ -n "$(printf "%s\n" "$*" | sed -e 's/^[^.]*//')" ]; then
+		printf "%s\n" "$*" | sed -e 's/^.*\(\.[^.]*$\)/\1/'
+	else
+		printf "%s\n" ""
+	fi
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bin/cek	Sun Oct 02 04:33:47 2011 +0700
@@ -0,0 +1,53 @@
+#!/bin/sh
+
+bn() { basename "/$*"; }
+#cs() { cksfv -- "$@"; }
+cs() { cek.py "$@"; }
+if [ "$#" -lt 1 ]; then
+	cat <<EOF
+Usage: $(bn "$0") file1 file2 ... fileN
+EOF
+	exit 1
+fi
+
+file_ok=0
+file_unre=0
+file_err=0
+file_nocrc=0
+for file in "$@"; do
+	st="nofile"
+	if [ -f "${file}" ] && [ -r "${file}" ]; then
+		crc=$(cs "${file}" | tail -1 | sed -e 's/.*\([A-F0-9]\{8\}\)$/\1/')
+		nocrc=$(bn "${file}" | sed -e 's/.*[[(][A-Fa-f0-9]\{8\}[])].*//')
+		st="nocrc"
+		if [ ! -n "${nocrc}" ]; then
+		# the filename has CRC. Yay
+			filecrc=$(bn "${file}" | sed -e 's/.*[[(]\([A-Fa-f0-9]\{8\}\)[])].*/\1/;y/abcdef/ABCDEF/')
+			if [ "${filecrc}" = "${crc}" ]; then
+				st="fileok"
+				file_ok=$((file_ok+1))
+			else
+				st="filerr"
+				file_err=$((file_err+1))
+			fi
+		else
+			st="nocrc"
+			file_nocrc=$((file_nocrc+1))
+		fi
+	else
+		st="nofile"
+		file_unre=$((file_unre+1))
+	fi
+	case "${st}" in
+		"nofile") ret="not a file or unreadable";;
+		"nocrc") ret="${crc}";;
+		"fileok") ret="${crc} - OK!";;
+		"filerr") ret="${crc} - ERROR - should be ${filecrc}";;
+	esac
+	printf "%s\n" "${file}: ${ret}"
+done
+echo "--------------------------------"
+[ "${file_ok}" -gt 0 ] && echo "Files ok: ${file_ok}"
+[ "${file_err}" -gt 0 ] && echo "Files broken: ${file_err}"
+[ "${file_nocrc}" -gt 0 ] && echo "Files without crc information: ${file_nocrc}"
+[ "${file_unre}" -gt 0 ] && echo "Files unreadable or not file: ${file_unre}"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bin/cek.pl	Sun Oct 02 04:33:47 2011 +0700
@@ -0,0 +1,49 @@
+#!/usr/bin/env perl
+
+use strict;
+use warnings;
+use String::CRC32;
+use File::Basename;
+
+my @files = @ARGV or print("Usage: ",basename($0)," file1 file2 ... fileN\n") && exit(1);
+my $num_ok=0;
+my $num_err=0;
+my $num_nf=0;
+my $num_na=@files;
+
+foreach(@files) {
+	my $filename = $_;
+	my ($name_crc,$real_crc);
+	unless (-f $filename) {
+		$num_nf++;$num_na--;
+		print(qq(Could not find "$filename", skipping\n));
+		next();
+	}
+	if(/(\[|\()([0-9A-F]{8})(\]|\))/i){
+		$name_crc=uc($2);
+	}
+	open(FILE,"<",$filename);
+	binmode(FILE);
+	$real_crc=sprintf("%08X",crc32(*FILE));
+	close(FILE);
+	if($name_crc) {
+		$num_na--;
+		if($name_crc eq $real_crc) {
+			$num_ok++;
+			print("$filename: OK - $real_crc\n");
+		} else {
+			$num_err++;
+			print("$filename: NOT OK - $real_crc, should be $name_crc\n");
+		}
+	} else {
+		print("$filename: $real_crc\n");
+	}
+}
+
+printf("%s\n","-"x40);
+if($num_ok > 0) { print("Files OK: $num_ok\n"); }
+if($num_err > 0) { print("Files error: $num_err\n"); }
+if($num_nf > 0) { print("Files not found: $num_nf\n"); }
+if($num_na > 0) { print("Files without crc information: $num_na\n"); }
+
+exit(0);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bin/cek.py	Sun Oct 02 04:33:47 2011 +0700
@@ -0,0 +1,22 @@
+#!/usr/bin/env python
+
+import zlib, os, sys
+
+def get_file_crc32(filename):
+  block_size = 1*2**20
+  return_code = 0
+  file_crc32 = 0
+  file_digest = 0
+  file_handle = open(filename, "rb")
+  if return_code == 0:
+    file_block = file_handle.read(block_size)
+    while file_block:
+      file_digest = zlib.crc32(file_block, file_digest)
+      file_block = file_handle.read(block_size)
+    file_handle.close()
+    file_digest = file_digest & 0xffffffff
+  return "%08X" % file_digest
+
+if __name__ == "__main__":
+  for file in sys.argv[1:]:
+    print "%s %s" % (file, get_file_crc32(file))
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bin/cek.rb	Sun Oct 02 04:33:47 2011 +0700
@@ -0,0 +1,14 @@
+#!/usr/bin/env ruby
+require 'zlib'
+
+block = 1048576
+ARGV.each do |filename|
+	crc = 0
+	file = File.open(filename, 'rb')
+	currentbyte = 0
+	while (line = file.read(block)) do
+		crc = Zlib.crc32(line,crc)
+	end
+	file.close
+	printf("%s %08X\n", filename, crc.to_s)
+end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bin/dumpshot	Sun Oct 02 04:33:47 2011 +0700
@@ -0,0 +1,28 @@
+#!/usr/bin/env python
+
+import sys, os, re
+
+def is_shotfile(inpath):
+  finpath = os.path.basename(inpath)
+  return (finpath[-4:] == ".png") and (finpath[:4] == "shot")
+
+def main(source_files, targetdir):
+  max_shot=0
+  try:
+    current_files=os.listdir(targetdir)
+    for current_file in current_files:
+      if is_shotfile(current_file):
+        file_shot = int(re.findall("\d+", current_file)[0])
+        if file_shot > max_shot:
+          max_shot = file_shot
+    for source_file in source_files:
+      if is_shotfile(source_file):
+        max_shot += 1
+        target_file = os.path.join(targetdir, "shot%04d.png" % max_shot)
+        print "Moving: %s => %s" % (source_file, target_file)
+        os.rename(source_file, target_file)
+  except:
+    print "(%s: %s)" % (sys.exc_type, sys.exc_value)
+
+if __name__ == "__main__":
+  main(sys.argv[2:], sys.argv[1])
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bin/ed2k	Sun Oct 02 04:33:47 2011 +0700
@@ -0,0 +1,26 @@
+#!/usr/bin/env ruby
+require 'openssl'
+
+def file_ed2k(file_name, output_mode = "hash")
+  ed2k_block = 9500*1024 #ed2k block size is 9500 KiB
+  ed2k_hash = ""
+  file = File.open(file_name, 'rb')
+  file_size = file.stat.size #while at it, fetch the size of the file
+  while (block = file.read(ed2k_block)) do
+    ed2k_hash << OpenSSL::Digest::MD4.digest(block) #hashes are concatenated md4 per block size for ed2k hash
+  end
+  ed2k_hash << OpenSSL::Digest::MD4.digest("") if file_size % ed2k_block == 0 #on size of modulo block size, append another md4 hash of a blank string
+  file.close
+  ed2k_hash = OpenSSL::Digest::MD4.hexdigest(ed2k_hash) #finally
+  return case output_mode #there are 2 modes, just the has, or complete with link.
+    when "hash"
+      ed2k_hash
+    when "link"
+      "ed2k://|file|#{File.basename(file_name)}|#{file_size}|#{ed2k_hash}|"
+    end
+end
+
+ARGV.each do |file_name|
+  next unless File.file?(file_name) and File.readable?(file_name)
+  printf("%s\n", file_ed2k(file_name,"link"))
+end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bin/ed2k.py	Sun Oct 02 04:33:47 2011 +0700
@@ -0,0 +1,19 @@
+#!/usr/bin/env python
+
+import os, sys
+from Crypto.Hash import MD4
+
+def ed2k(filename):
+  block = 9500*1024
+  hash = ""
+  file = open(filename, "rb")
+  fileblock = file.read(block)
+  while fileblock:
+    hash += MD4.new(fileblock).digest()
+    fileblock = file.read(block)
+  file.close()
+  return MD4.new(hash).hexdigest()
+
+if __name__ == "__main__":
+  for file in sys.argv[1:]:
+    print "%s %s" %(ed2k(file), file)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bin/index	Sun Oct 02 04:33:47 2011 +0700
@@ -0,0 +1,176 @@
+#!/bin/sh
+
+#un(POSIX / bourne shell)-ness: "read -r"
+
+WORKDIR="${PWD}"
+TEMPFILE="${WORKDIR}/temp/all"
+RESFILE="${WORKDIR}/list/all"
+ARCDIR="${WORKDIR}/archives"
+FILEDIRS="complete1 complete3 complete4 complete5 incomplete movie"
+#FILEDIRS="complete-all incomplete movie"
+
+Err_Fatal() {
+	echo "Error: $*"
+	exit 1
+}
+
+Progress_Init() {
+	_last="-"
+	printf "${_last}"
+}
+
+Progress_Anim() {
+	case "${_last}" in
+		/) _last="-";;
+		-) _last=\\;;
+		\\) _last=\|;;
+		\|) _last="/";;
+	esac
+	printf "\b${_last}"
+}
+
+Progress_Done() { printf "\bdone\n"; }
+
+Check_Dirs() {
+	[ -w "${WORKDIR}" ] || Err_Fatal "Unable to write ${WORKDIR}"
+	for dir in temp list archives backup; do
+		mkdir -p "${WORKDIR}/${dir}" 2>/dev/null
+		[ -w "${WORKDIR}/${dir}" ] || Err_Fatal "Unable to write ${WORKDIR}/${dir}"
+	done
+}
+
+Finish_Copy() {
+	printf "Copying result files... "
+	rm "${WORKDIR}/list/"*
+	cp "${WORKDIR}/temp/"* "${WORKDIR}/list"
+	mkdir -p "archives/${DATE}" && cp "${WORKDIR}/temp/"* "${WORKDIR}/archives/${DATE}"
+	echo "done"
+}
+
+Generate_File_List() {
+	printf "Generating list of files... "
+	> "${TEMPFILE}-bare"
+	for i in ${FILEDIRS}; do
+		printf "${i}... "
+		dir="/anime/${i}"
+		[ -d "${dir}" ] && find "${dir}/"* -type f >> "${TEMPFILE}-bare"
+	done
+	echo "done"
+	printf "Checking list validity... "
+	[ -n "$(grep -v ^/ "${TEMPFILE}-bare")" ] && Err_Fatal "Newline in filename. Please check ${TEMPFILE}-bare"
+	echo "done"
+
+	printf "Generating list of filenames... "
+	sed -e 's/.*\/\([^/]*\)/\1/' "${TEMPFILE}-bare" > "${TEMPFILE}-basename"
+	echo "done"
+
+	printf "Sorting and finding duplicates... "
+	sort -- "${TEMPFILE}-basename" > "${TEMPFILE}-basename-sorted"
+	mv -- "${TEMPFILE}-basename-sorted" "${TEMPFILE}-basename"
+	sort -u -- "${TEMPFILE}-basename" > "${TEMPFILE}-basename-sortuniq"
+	comm -23 -- "${TEMPFILE}-basename" "${TEMPFILE}-basename-sortuniq" > "${TEMPFILE}-dup-basename"
+	echo "done"
+	if [ "$(wc -l < "${TEMPFILE}-dup-basename")" -gt 0 ]; then 
+		> "${TEMPFILE}-dup-bare"
+		printf "Duplicate files detected. Generating list of duplicates... "
+		Progress_Init
+		while read -r dup; do
+			fgrep "${dup}" "${TEMPFILE}-bare" >> "${TEMPFILE}-dup-bare"
+			Progress_Anim
+		done < "${TEMPFILE}-dup-basename"
+		Progress_Done
+		Err_Fatal "Duplicated files detected. Please resolve this before continuing.
+       Check ${TEMPFILE}-dup-basename for list of duplicates"
+	else
+		rm "${TEMPFILE}-dup-basename" "${TEMPFILE}-basename-sortuniq"
+	fi
+	#yay finished
+}
+
+Generate_New_List() {
+	printf "Generating list of new files... "
+	Progress_Init
+	> "${TEMPFILE}-newbase"
+	sort "${RESFILE}-basename" > "${TEMPFILE}-res-basename"
+	mv "${TEMPFILE}-res-basename" "${RESFILE}-basename"
+	comm -13 "${RESFILE}-basename" "${TEMPFILE}-basename" > "${TEMPFILE}-newbase"
+	Progress_Anim
+	> "${TEMPFILE}-new"
+	while read -r added; do
+		fgrep "${added}" "${TEMPFILE}-bare" >> "${TEMPFILE}-new"
+		Progress_Anim
+	done < "${TEMPFILE}-newbase"
+	rm "${TEMPFILE}-newbase"
+	Progress_Done
+}
+
+Init_Check() {
+	cp "${TEMPFILE}-bare" "${TEMPFILE}-new"
+}
+
+Run_ed2k() {
+	#[ "$(echo $(wc -l < "${TEMPFILE}-new"))" -eq 0 ] && Err_Fatal "Not an error. Just lazy to create new handler. (Nothing new)"
+	printf "Generating ed2k links...0"
+	> "${TEMPFILE}-ed2k-newlist"
+	num=0
+	while read -r file; do
+		ed2k -l "${file}" >> "${TEMPFILE}-ed2k-newlist"
+		num=$((num+1))
+		if [ "$((num%10))" -eq 0 ]; then
+			printf "${num}"
+		else
+			printf "."
+		fi
+	done < "${TEMPFILE}-new"
+	echo " done"
+}
+
+Generate_Removed() {
+	printf "Generating list of removed files... "
+	Progress_Init
+	cp "${TEMPFILE}-ed2k-newlist" "${ARCDIR}/ed2k-newlist.${DATE}"
+	cat "${RESFILE}-ed2k-newlist" >> "${TEMPFILE}-ed2k-newlist"
+	sort -u "${TEMPFILE}-ed2k-newlist" > "${TEMPFILE}-ed2k-newlist-temp"
+	mv "${TEMPFILE}-ed2k-newlist-temp" "${TEMPFILE}-ed2k-newlist"
+	Progress_Anim
+	comm -13 "${TEMPFILE}-basename" "${RESFILE}-basename" | sort > "${TEMPFILE}-removed"
+	Progress_Anim
+	if [ "$(echo $(wc -l < "${TEMPFILE}-removed"))" -gt 0 ]; then
+		> "${TEMPFILE}-ed2k-newlisttemp"
+		while read -r deleted; do
+			fgrep "${deleted}" "${TEMPFILE}-ed2k-newlist" >> "${TEMPFILE}-ed2k-removed"
+			Progress_Anim
+			fgrep -v "${deleted}" "${TEMPFILE}-ed2k-newlist" > "${TEMPFILE}-ed2k-newlisttemp"
+			mv "${TEMPFILE}-ed2k-newlisttemp" "${TEMPFILE}-ed2k-newlist"
+			Progress_Anim
+		done < "${TEMPFILE}-removed"
+		cp "${TEMPFILE}-ed2k-removed" "${ARCDIR}/ed2k-removed.${DATE}"
+		#sed -e 's/ed2k:\/\/|file|\(.*\)|[^|]*|[^|]*|$/\1/' "${TEMPFILE}-ed2k-removed" > "${TEMPFILE}-base-removed"
+		Progress_Anim
+		while read -r deleted; do
+			fgrep "${deleted}" "${RESFILE}-bare" >> "${TEMPFILE}-bare-removed"
+			Progress_Anim
+		done < "${TEMPFILE}-removed"
+		cp "${TEMPFILE}-bare-removed" "${ARCDIR}/bare-removed.${DATE}"
+	fi
+	Progress_Done
+}
+
+INIT=
+UPDATE=
+DATE=$(date -u "+%Y%m%d-%H.%M")
+case "$1" in
+	init) INIT=1;;
+	update|up) UPDATE=1;;
+	*) Err_Fatal "You fail.";;
+esac
+Check_Dirs 
+[ -n "${UPDATE}" ] && cd "${WORKDIR}" && tar zcf "${WORKDIR}/backup/${DATE}.tar.gz" "temp" "list" "archives"
+[ -n "${UPDATE}" ] && rm "${WORKDIR}/temp/"* 2>/dev/null
+Generate_File_List
+[ -n "${INIT}" ] && Init_Check
+[ -n "${UPDATE}" ] && Generate_New_List
+Run_ed2k 
+[ -n "${UPDATE}" ] && Generate_Removed
+Finish_Copy
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bin/index2	Sun Oct 02 04:33:47 2011 +0700
@@ -0,0 +1,39 @@
+#!/bin/sh
+
+# Index version 2! Much better than first one. Hopefully.
+
+# Execute safely.
+safe_path()
+{
+	__start=$(printf "%s" | cut -c 1)
+	__path=
+	case "${__start}" in
+		.|/) __path="$*";;
+		*) __path="./$*";;
+	esac
+	printf "%s" "${__path}"
+}
+
+get_basename() { basename "$(safe_path "$*")"; }
+get_basename_pipe() { sed -e 's#.*/\([/]*\)$#\1#'; }
+
+filename_hash()
+{
+	printf "%s" "$(get_basename "$*")" 
+}
+generate_table_of_files()
+{
+	filetable_generator "$@"
+}
+filetable_generator()
+{
+	# Uses perl for speed.
+	perl -e 'use File::Find;
+use Digest::SHA1 qw(sha1_hex);
+use_warnings;
+use_strict;
+sub printer { printf("%s\n", sha1_hex($_)) if(-e && -f && !-l); } 
+find(\&printer, @ARGV);' "$@"
+}
+_srcdir=.
+generate_table_of_files "$@"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bin/lren	Sun Oct 02 04:33:47 2011 +0700
@@ -0,0 +1,28 @@
+#!/usr/bin/env perl
+
+use warnings;
+use strict;
+use File::Basename;
+
+my @files = @ARGV or print("Usage: ",basename($0)," file1 ... fileN\n") && exit(1);
+my $skip=0;
+foreach (@files) {
+	my $newname = $_;
+	print(qq(Could not find file "$_", skipping\n)) and next() unless -e $_;
+  $newname =~ s/_/ /g;
+  $newname =~ s/.* Ep([[:digit:]]+) .*/[Anime-Takeover] You're Under Arrest! - $1 [v2].mkv/;
+	$newname =~ s/ +/ /g;
+	print(qq($_: $newname already exists, skipping\n)) and next() if -e $newname and $_ ne $newname;
+	if ($_ eq $newname) {
+		print("$_: no need to rename, skipping\n");
+	} else {
+		if($skip==1) { print("Result: $_ --> $newname\n"); }
+		else {
+			if(rename($_, $newname)) { print("$_ -> $newname\n"); }
+			else { print("$_: rename failed\n"); }
+		}
+	}
+	next();
+}
+
+exit(0);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bin/mgren	Sun Oct 02 04:33:47 2011 +0700
@@ -0,0 +1,11 @@
+#!/usr/bin/env ruby
+TITLE_MAPS={ "otaku no musume-san" => 1 }
+TITLE_REAL={ 1 => "Otaku no Musume-san" }
+
+def get_title
+  
+end
+
+ARGV.each do |file|
+  next unless File.file?(file) and File.readable?(file)
+end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bin/moeauto	Sun Oct 02 04:33:47 2011 +0700
@@ -0,0 +1,24 @@
+#!/bin/sh
+
+if [ "$#" -lt 1 ]; then
+	cat <<EOF
+Usage: $(basename -- "$0")
+EOF
+	exit 1
+fi
+
+if [ ! -r "$*" ] || [ -d "$*" ]; then
+	cat <<EOF
+File "$*" can't be read!
+EOF
+	exit 1
+fi
+
+SERVER=
+while read LINE; do
+	if [ -n "$(printf "%s" "${LINE}" | grep "^SERVER=")" ]; then
+		SERVER=$(printf "%s" "${LINE}" | sed -e 's/SERVER=//')
+	else
+		[ -n "${SERVER}" ] && [ ! -z "$(printf "%s" "${LINE}" | grep -v "^$")" ] && moefetch fetch -s "${SERVER}" ${LINE}
+	fi
+done < "$*"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bin/moeauto-genlink	Sun Oct 02 04:33:47 2011 +0700
@@ -0,0 +1,24 @@
+#!/bin/sh
+
+if [ "$#" -lt 1 ]; then
+	cat <<EOF
+Usage: $(basename -- "$0")
+EOF
+	exit 1
+fi
+
+if [ ! -r "$*" ] || [ -d "$*" ]; then
+	cat <<EOF
+File "$*" can't be read!
+EOF
+	exit 1
+fi
+
+SERVER=
+while read LINE; do
+	if [ -n "$(printf "%s" "${LINE}" | grep "^SERVER=")" ]; then
+		SERVER=$(printf "%s" "${LINE}" | sed -e 's/SERVER=//')
+	else
+		[ -n "${SERVER}" ] && [ ! -z "$(printf "%s" "${LINE}" | grep -v "^$")" ] && moefetch check -s "${SERVER}" ${LINE}
+	fi
+done < "$*"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bin/moedump	Sun Oct 02 04:33:47 2011 +0700
@@ -0,0 +1,38 @@
+#!/bin/sh
+
+safe_mv() { mv -- "$@"; }
+safe_ln() { ln -s -- "$1" "$2"; }
+safe_basename() { basename -- "$1"; }
+get_md5() { ${MD5} -- "$1" | cut -d' ' -f1; }
+get_filename() { safe_basename "${1%.*}"; }
+
+eod() { "$@" || errx "$@"; }
+errx() { echo "Error executing: $@"; exit 1; }
+MD5="md5sum"
+[ "$(safe_basename "${PWD}")" = ".all" ] || { echo "Wrong working directory. This script must be run in .all directory. Aborting."; exit 1; }
+
+[ -d "../.trash" ] || eod mkdir ../.trash
+
+echo "Total files: $(find ../* -type f | wc -l) files."
+
+num=0
+for i in ../*/*
+do
+	if [ -h "$i" ]
+	then
+		[ -f "$i" ] || { eod safe_mv "$i" "../.trash" && echo "Broken file: $(safe_basename "$i"). Moved to trash."; }
+	else
+		if [ "$(get_md5 "$i")" = "$(get_filename "$i")" ]
+		then
+			eod safe_mv "$i" . 
+			eod safe_ln "../.all/$(safe_basename "$i")" "$i" 
+		else 
+			eod safe_mv "$i" "../.trash" && echo "Broken file: $(get_filename "$i"). Moved to .trash."
+		fi
+		printf "%s" "."
+		num=$((num+1))
+		[ "$((num%100))" -eq 0 ] && printf "${num}"
+	fi
+done
+
+echo "done"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bin/old-cek	Sun Oct 02 04:33:47 2011 +0700
@@ -0,0 +1,49 @@
+#!/usr/bin/perl
+
+use warnings;
+use strict;
+use String::CRC32;
+use File::Basename;
+
+unless($#ARGV+1>0) {
+	print("Usage: ", basename($0), " file1 ... fileN\n");
+	exit(1);
+}
+
+my @files = @ARGV;
+#or print("Usage: ", basename($0), " file1 ... fileN\n") && exit(1);
+    # print usage message if called without arguments
+
+foreach (@files) {
+	my $filename = $_;
+	my ($input, $name_checksum, $real_checksum, $checksum);
+	unless((-r $filename) && (-f $filename)) {
+		print(qq("$filename" is not a file or unreadable, skipping\n));
+		next();
+	}
+	#print(qq(Could not find file "$filename", skipping\n)) and next() unless -r $filename;
+	#print(qq("$filename" is not a file, skipping\n)) and next() unless -f $filename;
+
+	open(FILE,$filename);
+	$real_checksum = sprintf("%08X",crc32(*FILE));
+	close(FILE);
+
+	if ( /(\[|\()([0-9A-F]{8})(\]|\))/i ) { # does it have a checksum?
+		$name_checksum = $2;
+		if (lc($real_checksum) eq lc($name_checksum)) {
+			print("${filename}: $real_checksum - OK!\n");
+			next();
+		}
+        else {
+            print("${filename}: $real_checksum - NOT OK! Should be ${name_checksum}!\n");
+            next();
+        }
+    }
+    else { # can't find checksum in filename, just print filename + generated checksum and let the user do the thinking
+        print("${filename}: $real_checksum\n");
+        next();
+	}
+}
+
+exit(0);
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bin/patren	Sun Oct 02 04:33:47 2011 +0700
@@ -0,0 +1,11 @@
+#!/usr/bin/env ruby
+TITLE_MAPS={ "otaku no musume-san" => 1 }
+TITLE_REAL={ 1 => "Otaku no Musume-san" }
+
+def get_title
+  
+end
+
+ARGV.each do |file|
+  next unless File.file?(file) and File.readable?(file)
+end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bin/proxy-loop	Sun Oct 02 04:33:47 2011 +0700
@@ -0,0 +1,5 @@
+#!/bin/sh
+while true; do
+  ssh -N localhost
+  sleep 10
+done
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bin/putcrc	Sun Oct 02 04:33:47 2011 +0700
@@ -0,0 +1,32 @@
+#!/bin/sh
+safe_path()
+{
+	# It all depends on the first character.
+	__start=$(printf "%s" "$*" | cut -c 1)
+	__path=
+	case "${__start}" in
+		.|/) __path="$*";; # . and / is safe. No change.
+		*) __path="./$*";; # Anything else must be prefixed with ./
+	esac
+	printf "%s" "${__path}" # Return.
+}
+
+if [ "$#" -lt 1 ]; then
+	cat <<EOF
+Usage: $(basename "/$0") file1 file2 ... fileN
+EOF
+	exit 1
+fi
+
+for file in "$@"; do
+	if [ -f "${file}" ] && [ -r "${file}" ] && [ -n "$(printf "%s\n" "${file}" | sed -e 's/.*[A-F0-9]\{8\}.*//')" ]; then
+		filename="$(basename "$(safe_path "${file}")")"
+		dirname="$(dirname "$(safe_path "${file}")")"
+		myfile="$(printf "%s\n" "${filename%.*}" | sed -e 's/\([^]]\)$/\1 /')"
+		myext="${filename##*.}"; if [ "${myext}" = "${filename}" ]; then myext=""; else myext=".${myext}"; fi
+		crc=$(cek.py "$(safe_path "${file}")" | tail -1 | sed -e 's/.*\([A-F0-9]\{8\}\)$/\1/')
+		mv -- "${file}" "${dirname}/${myfile}[${crc}]${myext}" && printf "%s => %s\n" "${file}" "${myfile}[${crc}]${myext}"
+	else
+		printf "%s\n" "${file} is not a file or unreadable"
+	fi
+done
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bin/putcrc.pl	Sun Oct 02 04:33:47 2011 +0700
@@ -0,0 +1,29 @@
+#!/usr/bin/perl
+
+use warnings;
+use strict;
+use String::CRC32;
+
+my @files = @ARGV or print("Usage: ren file1 ... fileN\n") && exit(1);
+my $skip=0;
+foreach (@files) {
+	my $newname = $_;
+	open(FILE,$_);
+	my $crc=sprintf("%08X",crc32(*FILE));
+	close(FILE);
+	$newname =~ s/(.*)\.([^.]*)/$1 [$crc].$2/;
+	$newname =~ s/\] (\[$crc)/]$1/;
+	print(qq($_: $newname already exists, skipping\n)) and next() if -e $newname and $_ ne $newname;
+	if ($_ eq $newname) {
+		print("$_: no need to rename, skipping\n");
+	} else {
+		if($skip==1) { print("$_ --> $newname\n"); }
+		else {
+			if(rename($_, $newname)) { print("$_ -> $newname\n"); }
+			else { print("$_: rename failed"); }
+		}
+	}
+	next();
+}
+
+exit(0);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bin/putend	Sun Oct 02 04:33:47 2011 +0700
@@ -0,0 +1,28 @@
+#!/usr/bin/env perl
+
+use warnings;
+use strict;
+use File::Basename;
+
+my @files = @ARGV or print("Usage: ",basename($0)," file1 ... fileN\n") && exit(1);
+my $skip=0;
+foreach (@files) {
+  print(qq(Could not find file "$_", skipping\n)) and next() unless -e $_;
+  my $newname = $_;
+  $newname =~ s/(\.[^.]+$)/[End]$1/;
+  $newname =~ s/ (\[.*\])(\[End\])\./ $2$1./;
+  $newname =~ s/([^ ])(\[End\]\.)/$1 $2/;
+  print(qq($_: $newname already exists, skipping\n)) and next() if -e $newname and $_ ne $newname;
+  if ($_ eq $newname) {
+    print("$_: no need to rename, skipping\n");
+  } else {
+    if($skip==1) { print("Result: $_ --> $newname\n"); }
+    else {
+      if(rename($_, $newname)) { print("$_ -> $newname\n"); }
+      else { print("$_: rename failed\n"); }
+    }
+  }
+  next();
+}
+
+exit(0);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bin/rar2zip	Sun Oct 02 04:33:47 2011 +0700
@@ -0,0 +1,30 @@
+#!/bin/sh
+to_lower() {
+  printf "%s" "$1" | tr '[:upper:]' '[:lower:]'
+}
+full_path() {
+  # It all depends on the first character.
+  start=${i%${i#?}}
+  path=
+  case "${start}" in
+    /) path="${1}";; # / is absolute. No change.
+    *) path="${2}/${1}";; # Anything else must be prefixed with $2 (hopefully $PWD)
+  esac
+  printf "%s" "${path}" # Return.
+}
+for i in "$@"; do
+  src_ext="${i##*.}"
+  src_path="$(full_path "${i}" "${PWD}")"
+  if [ -f "${src_path}" ] && [ -r "${src_path}" ] && [ "${src_ext}" != "${i}" ] && [ "$(to_lower ${src_ext})" = "rar" ]; then
+    tmpdir=".tmp.${i##*/}"
+    if mkdir -p "${tmpdir}"; then
+      if 7z x -o"${tmpdir}" -- "${src_path}"; then
+        (cd "${tmpdir}" && 7z a -mx=1 -tzip "${src_path%.*}.zip" -- "*";)
+      fi
+      rm -r "${tmpdir}"
+    fi
+  else
+    echo "Invalid input: ${i}"
+  fi
+done
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bin/recompress	Sun Oct 02 04:33:47 2011 +0700
@@ -0,0 +1,46 @@
+#!/usr/bin/env python
+
+import sys, os
+from PIL import Image
+
+
+# Raises a generic exception (exception.Exception) if input is not a PNG file.
+def repng(filename):
+  im = Image.open(filename)
+  if im.format == "PNG":
+    im.save(filename, "PNG", optimize=1)
+  else:
+    raise Exception("Not a PNG image file")
+
+def hbytes(inbyte):
+  units = ["B", "kB", "MB", "GB", "TB", "PB"] 
+  outbyte = float(inbyte)
+  current_unit = 0
+  while outbyte > 1000:
+    outbyte /= 1000
+    current_unit += 1
+  return "%.2f %s" % (outbyte, units[current_unit])
+
+def sane_fn(filename):
+  import re
+  return re.sub(r"[\x00-\x1F\x7F\n\r]", "?", filename)
+
+def main(files):
+  for filename in files:
+    print "Recompressing %s:" % sane_fn(filename),
+    sys.stdout.flush()
+    try:
+      byte_orig = os.path.getsize(filename)
+      repng(filename)
+      byte_new = os.path.getsize(filename)
+      print "OK (%s => %s, %.2f%% saving)" % (hbytes(byte_orig), hbytes(byte_new), (byte_orig - byte_new)*100/float(byte_orig)),
+      re = 0
+    except:
+      print "Failed",
+      print "(%s: %s)" % (sys.exc_type, sys.exc_value),
+      re = 1
+    finally:
+      print "[%s]" % re
+
+if __name__ == "__main__":
+  main(sys.argv[1:])
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bin/ren	Sun Oct 02 04:33:47 2011 +0700
@@ -0,0 +1,483 @@
+#!/usr/bin/env perl
+
+use warnings;
+use strict;
+use File::Basename;
+
+my @files = @ARGV or print("Usage: ",basename($0)," file1 ... fileN\n") && exit(1);
+my $skip=0;
+foreach (@files) {
+  print(qq(Could not find file "$_", skipping\n)) and next() unless -e $_;
+  my $newname = $_;
+  #START HERE
+  $newname =~ s/_/ /g;
+  # GROUP NAMES
+  $newname =~ s/\[UTW Mazui\]/[UTW-Mazui]/i;
+  $newname =~ s/\[t-n\]/[T-N]/i;
+  #TITLE AND NAMES
+  $newname =~ s/^(\(|\[)W B(\)|\])/[W_B]/;
+  if ($newname =~ m/\[(Doremi|Elysium)/) {
+    $newname =~ s/\.([a-z0-9]+)$/,$1/i;
+    $newname =~ s/\./ /g;
+    $newname =~ s/,([a-z0-9]+)$/.$1/i;
+  }
+  $newname =~ s/^Genesis of Aquarion - (\d+) \[3xR\]\[Blu-ray.720p.H264.FLAC.AC3\](v2|)/[3xR] Genesis of Aquarion - $1 [$2 720p BD]/;
+  $newname =~ s/^Otogi Zoshi Act\.(\d+)\[x264 AAC\]\[SSP-Corp\]/[SSP-Corp] Otogi Zoshi - $1 /;
+  $newname =~ s/Onii-chan no Koto Nanka Zenzen Suki Janain Dakara ne!! - (\d+) \[Uncut\]/Onii-chan no Koto Nanka Zenzen Suki Janain Dakara ne!! - $1 /;
+  $newname =~ s/^(Ayashi no Ceres|Chikyuu Shoujo Arjuna|Futari wa Precure  Splash Star) - (\d+)\[\d+\] - .*(\[DVD\])(\[[^]]+\])(\[[a-f0-9]{8}\]\.[^.]+)$/$4 $1 - $2 $3$5/i;
+  $newname =~ s/^(Futari wa Precure  Splash Star) - (C\d+)\[\d+\] - .*(\[DVD\])(\[[^]]+\])(\[[a-f0-9]{8}\]\.[^.]+)$/$4 $1 - $2 $3$5/i;
+  $newname =~ s/^(Air Master|Black Jack Special|Cinderella Boy|Damekko Doubutsu|Crystal Blaze) - (\d+)\[\d+\] - .*(\[[^]]+\])(\[[a-f0-9]{8}\]\.[^.]+)$/$3 $1 - $2 $4/i;
+  $newname =~ s/^cor\.extras\.infinite\.ryvius\.textless\.opening(\d+)\./[cor] Infinite Ryvius - Opening $1 (Clean) /;
+  $newname =~ s/^cor\.extras\.infinite\.ryvius\.textless\.ending(\d+)\./[cor] Infinite Ryvius - Ending $1 (Clean) /;
+  $newname =~ s/^cor\.extras\.infinite\.ryvius\.art\.gallery\.and\.audio\.drama(\d+)\./[cor] Infinite Ryvius - Picture Drama $1 /;
+  $newname =~ s/^cor\.extras\.infinite\.ryvius\.ryvius\.vj\.mix(\d+)\./[cor] Infinite Ryvius - Ryvius VJ Mix $1 /;
+  $newname =~ s/^cor\.extras\.infinite\.ryvius\.ryvius\.illusion(\d+)\.mini-episode(\d+)\./[cor] Infinite Ryvius - Ryvius Illusion $1 - Mini Episode $2 /;
+  $newname =~ s/^cor\.extras\.infinite\.ryvius\.ryvius\.illusion(\d+)\.(introduction|ending)\./[cor] Infinite Ryvius - Ryvius Illusion $1 - $2 /;
+  $newname =~ s/ (Ryvius Illusion \d+) - ending / $1 - Ending /;
+  $newname =~ s/ (Ryvius Illusion \d+) - introduction / $1 - Introduction /;
+  $newname =~ s/^Arigatou\.Tokyo\.Majin\.Ep(\d+)\./[Arigatou] Tokyo Majin - $1 /;
+  $newname =~ s/ (Inazuma Eleven - )(\d{2}) / $1 0$2 /;
+  $newname =~ s/\] *Pocket Monsters - (\d+) - .*\[(H264 |)SUB\]/] Pokemon - $1 /i;
+  $newname =~ s/\] Fafner - /] Soukyuu no Fafner - /;
+  $newname =~ s/\] Mashiro iro symphony - /] Mashiro-iro Symphony - /i;
+  $newname =~ s/\] To Aru Kagaku no Railgun /] Toaru Kagaku no Railgun /i;
+  $newname =~ s/\] To Aru Majutsu no Index /] Toaru Majutsu no Index /i;
+  $newname =~ s/\] Shakugan no Shana III /] Shakugan no Shana Final /i;
+  $newname =~ s/\] Boku Ha Tomodachi Ga Sukunai - /] Boku wa Tomodachi ga Sukunai - /i;
+  $newname =~ s/\] Seikon no Qwaser II BD - (\d+) \[720p\]/] Seikon no Qwaser II - $1 [720p BD]/i;
+  $newname =~ s/\] Seikon no Qwaser Picture Drama - (\d+) /] Seikon no Qwaser - Picture Drama $1 /i;
+  $newname =~ s/\] Fortune Arterial Akai Yakusoku - /] Fortune Arterial - /;
+  $newname =~ s/\[HorribleSubs\] Hunter X Hunter - /[HorribleSubs] Hunter x Hunter (2011) - /i;
+  $newname =~ s/\] Ookami to Koushinryou - /] Spice and Wolf - /;
+  $newname =~ s/\] Kamen Rider Blade /] Kamen Rider Blade /i;
+  $newname =~ s/\] Mobile Suit Gundam AGE - /] Gundam AGE - /i;
+  $newname =~ s/\] Soredemo Machi wa Mawatte Iru - /] Soredemo Machi wa Mawatteiru - /;
+  $newname =~ s/\] Spiral - (\d+) .* \[640 x 480\]\[H\.264\]/] Spiral - $1 /;
+  $newname =~ s/\] Mayo Chiki - / ] Mayo Chiki! - /i;
+  $newname =~ s/\] Naruto Shippuden - /] Naruto Shippuuden - /i;
+  $newname =~ s/\] Maji de Watashi ni Koi Shinasai!! /] Maji de Watashi ni Koi Shinasai! /i;
+  $newname =~ s/\] Sei Juushi Bismarck /] Sei Juushi Bismark /i;
+  $newname =~ s/\] Tamayura - hitotose - /] Tamayura ~hitotose~ - /i;
+  $newname =~ s/\] Yumekui Merry /] Dream Eater Merry /i;
+  $newname =~ s/^Arigatou\.Tsubasa\.Chronicles\.(|2\.)(\d{2})(|v2)\./[Arigatou] Tsubasa Chronicles $1 - $2$3/;
+  $newname =~ s/^Niea\.Under\.Seven\.(\d+)\.\(Dual\.Audio\)\.XVID\.\[AM\]/[AM] Niea Under Seven - $1/;
+  $newname =~ s/ Tsubasa Chronicles 2\. - / Tsubasa Chronicles 2 /;
+  $newname =~ s/ *Moritasan wa Mukuchi */ Morita-san wa Mukuchi /i;
+  $newname =~ s/ Hanasakeru Seishonen / Hanasakeru Seishounen /i;
+  $newname =~ s/^YAMATO 3x(\d+).*/Yamato S3 - $1.mkv/i;
+  $newname =~ s/ - (Ending|Opening) (\d+ *[a-z]*) (Clean) / - $1 $2 ($3) /i;
+  $newname =~ s/^\[T-N\]Mirai Sentai TimeRanger (\d+)(\[[A-F0-9]{8}\])DVD(|ver2|ver3)(\.avi)$/[T-N] Mirai Sentai Time Ranger - $1 $3 [DVD]$2$4/;
+  $newname =~ s/^Yamato (\d+) - remaster \(Central Anime\)/[Central Anime] Yamato - $1 /i;
+  $newname =~ s/^Yamato S2 (\d+) - remaster \(Central Anime\)/[Central Anime] Yamato S2 - $1 /i;
+  $newname =~ s/\[TSuNDeRe\]Tsuyokiss\.(\d+)\./[Tsundere] Tsuyokiss - $1 /i;
+  $newname =~ s/\[RANDOMFAGGOTS\]/[Randomfaggots]/i;
+  $newname =~ s/\[Keroro\]\.(\d+)\.\[Xvid\.mp3\]\./[Keroro] Keroro Gunsou - $1 /i;
+  $newname =~ s/\[Keroro\] \.(\d+)\. \[\.mp3\] \. /[Keroro] Keroro Gunsou - $1 /i;
+  $newname =~ s/\[WPP & T-N\]/[WPP T-N]/;
+  $newname =~ s/(\[Jumonji-Giri\]) *\[[^]]+\]/$1/i;
+  $newname =~ s/ Yuru Yuri / YuruYuri /i;
+  $newname =~ s/ Clannad - After Story / Clannad After Story /i;
+  $newname =~ s/ Manyuu Hikenchou - (\d+) ~DC~ / Manyuu Hikenchou - $1 [Uncut]/;
+  $newname =~ s/\[Elysium\]K-ON!!\.EP(\d+)\(BD\.1080p\.FLAC\)/[Elysium] K-ON!! - $1 [1080p BD]/i;
+  $newname =~ s/\[Elysium\]K-ON!!\.(ED|OP)(\d+)\(BD\.1080p\.FLAC\)/[Elysium] K-ON!! - $1 $2 [1080p BD]/i;
+  $newname =~ s/\[Elysium\]K-ON!!\.SP\d+\[EP(\d+)\]\(BD\.1080p\.FLAC\)/[Elysium] K-ON!! - $1 [1080p BD]/i;
+  $newname =~ s/^\[wpp\]digimon frontier /[wpp] Digimon Frontier /i;
+  $newname =~ s/^\[ACX\]Fantastic Children - (\d+) .*/[ACX] Fantastic Children - $1.mkv/i;
+  $newname =~ s/\[a-s\] sakigake!! cromartie high school - (\d+) - .* /[a-S] Sakigake!! Cromartie High School - $1 /;
+  $newname =~ s/zx\.tenchi-universe\./[zx] Tenchi Universe - /;
+  $newname =~ s/\[Saizen & Shinsen-Subs\]/[Saizen-SHS]/i;
+  $newname =~ s/ ro-kyu-bu(!)? / Ro-Kyu-Bu! /i;
+  $newname =~ s/^cor\.tv\.infinite\.ryvius\.(\d+)\./[cor] Infinite Ryvius - $1 /i;
+  $newname =~ s/ Ore no Imouto ga Konna ni Kawaii Wake ga Nai / Ore no Imouto /i;
+  $newname =~ s/ no 6 / No. 6 /i;
+  $newname =~ s/\[ACX\]Gantz - (\d+) .* \[SaintDeath\] /[ACX] Gantz - $1 /i;
+  $newname =~ s/ THE iDOLM\@STER / The Idolm\@ster /i;
+  $newname =~ s/^- (\d+) - (\[neo1024\])/$2 Luping III S3 - $2/i;
+  $newname =~ s/ Luping III S3 / Lupin III S3 /i;
+  $newname =~ s/( Transformers Headmasters - \d+) - .*\[/$1 [/i;
+  $newname =~ s/^cor\.tv\.getbackers\.(\d+)\./[cor] GetBackers - $1 /;
+  $newname =~ s/^cor\.extras\.getbackers\.(opening|ending)(\d+)\./[cor] GetBackers - $1 $2 /;
+  $newname =~ s/^Revolutionary Girl Utena /[Henshin] Revolutionary Girl Utena /;
+  $newname =~ s/His and Her Circumstances/His and Her Circumstances/i;
+  $newname =~ s/ Lime-iro Senkitan / Lime-Colored War Tales /i;
+  $newname =~ s/(Ninja Scroll) TV Ep\.(\d+)\[.*(\[SSP-Corp\])/$3 $1 - $2 /i;
+  $newname =~ s/Magical Girl Madoka Magica/Puella Magi Madoka Magica/i;
+  $newname =~ s/ Pretty Rhythm Aurora Dream / Pretty Rhythm - Aurora Dream /i;
+  $newname =~ s/(\[dvdrip\] Transformers \(1984\) -) E(\d+) .*(\.avi)/$1 $2 $3/;
+  $newname =~ s/ Highschool of the Dead / High School of the Dead /i;
+  $newname =~ s/LOGH Gaiden 2 E(\d+) .*(\.avi|\.mkv)/Legend of Galactic Heroes Gaiden 2 - $1$2/i;
+  $newname =~ s/^\[RaX\] *Kiba - (\d+) - .* (\[v2\] \[|\[)/[RaX] Kiba - $1 $2/;
+  $newname =~ s/ (Gosick - \d+) \(Batch\) / $1 /;
+  $newname =~ s/ Clannad - After Story - / Clannad After Story - /;
+  $newname =~ s/ Ikoku Meiro no Croisée / Ikoku Meiro no Kurowaaze /i;
+  $newname =~ s/^Mahoujin Guruguru TV2 - Doki Doki Densetsu Ep(\d+) \((Chamelenia)\)/[Chamelenia] Mahoujin Guruguru 2 - Doki Doki Densetsu - $1/i;
+  $newname =~ s/\.divx5\.ogm$/.ogm/;
+  #$newname =~ s/\[(neo1024)\] Lupin III - (\d+) - .+ \[/[$1] Lupin III S2 - $2 [/;
+  $newname =~ s/ Lupin S2 - / Lupin III S2 - /;
+  $newname =~ s/ Prince of Tennis (\d+)/ Prince of Tennis - $1/i;
+  $newname =~ s/ Boogiepop - / Boogiepop Phantom - /i;
+  $newname =~ s/ Aika Zero OVA / Aika Zero /i;
+  $newname =~ s/^\[A-BT&Pakapuka\]PopoloCrois 2003 Ep/[A-BT Pakapuka] PopoloCrois (2003) - /;
+  $newname =~ s/^\[A-BT&Pakapuka\] PopoloCrois Story 1998 /[A-BT Pakapuka] PopoloCrois (1998) - /;
+  $newname =~ s/ (Pollyanna|Happy Kappi) Episode (\d+) / $1 - $2 /;
+  $newname =~ s/\(G P\) Now and Then Here and There \(R2J\)/[G P] Now and Then Here and There - /;
+  $newname =~ s/^\[Jumonji-Giri\]\[Soldats\]\[AonE&HQA\] D\.C\. Da Capo /[Jumonji-Giri] Da Capo /i;
+  $newname =~ s/\[A-Flux&Lunar\]/[A-Flux Lunar]/i;
+  $newname =~ s/^(Mushishi) - (\d+) - .* - (\[niizk\])/$3 $1 - $1/;
+  $newname =~ s/^(Saikano) (\d+)\[h\.264-AAC\](\[SSP-Corp\])/$3 $1 - $2 /;
+  $newname =~ s/^PitaTen.* Ep (\d+) .*\.avi/[Hnk] Pita Ten - $1.avi/;
+  $newname =~ s/^\[a-S\] Inuyasha - (\d+|\d+-\d+) /Inuyasha - $1 [a-S]/;
+  $newname =~ s/\[DVD\]\[AHQ\]/[AHQ][DVD]/;
+  $newname =~ s/\[THORA\]/[Thora]/i;
+  $newname =~ s/\[subdesu\]/[SubDesu]/i;
+  $newname =~ s/ Zettai Shougeki - Platonic Heart / Zettai Shougeki /i;
+  $newname =~ s/^ef a tale of memories (prologue|- Opening \d+|- Ending \d+|- \d+) .*THORA/[Thora] ef - a tale of memories - $1 [1080p BD]/i;
+  $newname =~ s/ A-Channel / A Channel /i;
+  $newname =~ s/^mars daybreak /[V-A] Mars Daybreak - /;
+  $newname =~ s/ Shuffle! Episode / Shuffle! /;
+  $newname =~ s/ A-Channel / A Channel /;
+  $newname =~ s/ Moshidora \(Moshi Koko Yakyu no Joshi Manager ga Drucker no Management o Yondara\) / Moshidora /;
+  $newname =~ s/^\[ZA\]\.Saint\.Seiya\.Episode\.(\d+)\.DVDrip\.\[X264\.AAC\(Jpn-Fre\)\.Sub\(Fre-Eng\)\.Chap\]\.mkv$/[D-YFI] Saint Seiya - $1 [DVD].mkv/;
+  $newname =~ s/^HajimeNoIppo.*Round(\d+)-.*\(anime-mx\)/[Anime-MX] Fighting Spirit - $1 /;
+  $newname =~ s/^(\[ACX\])(Final Fantasy Unlimited) - (\d+) .*\[ALI\] /$1 $2 - $3 /;
+  $newname =~ s/^\[a-s\] inuyasha - (\d+-\d+) rs2 /[a-S] Inuyasha - $1 /;
+  $newname =~ s/^(\[Kira-Fansub\]) Uchuu no (Stellvia) /$1 $2 /;
+  $newname =~ s/^(\[RaX\])(Chobits) - (\d+`\d) .*\(x264 aac\) /$1 $2 - $3 /;
+  $newname =~ s/ Maria( |†)Holic / Maria+Holic /i;
+  $newname =~ s/ C³ / C3 - Cube x Cursed x Curious /i;
+  $newname =~ s/ C3 Cube x Cursed x Curious / C3 - Cube x Cursed x Curious /i;
+  $newname =~ s/ Fate( ⁄ | )Zero / Fate-Zero /i;
+  $newname =~ s/ Pollyanna Episode / Pollyanna /;
+  $newname =~ s/^Legend of Galactic Heroes - (\d+) \(([A-F0-9]{8})\) \[Central Anime\]/[Central Anime] Legend of Galactic Heroes - $1 [$2]/;
+  $newname =~ s/\[Hnk\]/[HnK]/;
+  $newname =~ s/^Inuyasha - (\d+|\d+-\d+)\[167\] - .*(\[DVD\]\[AHQ\])/Inuyasha - $1 $2/;
+  $newname =~ s/^Saint Seiya Hades OVA - (\d+) \[(AonE-SpA|SpA)\]/[$2] Saint Seiya Hades OVA - $1/;
+  $newname =~ s/\[\d+\] Saint Seiya Hades OVA - (\d+)/[SpA] Saint Seiya Hades OVA - $1/;
+  $newname =~ s/ Digimon Tamers - (\d)\./ Digimon Tamers - 0$1./;
+  $newname =~ s/ Kore wa Zombie Desu ka / Kore wa Zombie desu ka /i;
+  $newname =~ s/ Infinite Stratos - IS - / Infinite Stratos - /;
+  $newname =~ s/Shadow\.Star\.Narutaru\.(\d+)\.\(Dual\.Audio\)\.XVID\.\[AM\]/[AM] Narutaru - $1 /;
+  $newname =~ s/Outlaw Star Remastered E(\d+) .*'/ Outlaw Star - $1 /;
+  $newname =~ s/Ground Defense Force Mao-chan (\d+)\[h\.264-AAC\]\[SSP-Corp\]/[SSP-Corp] Mao-chan - $1 /;
+  $newname =~ s/Koi Kaze (\d+) \[NAG&anime fin\]/[NAG anime-fin] Koi Kaze - $1 /;
+  $newname =~ s/ Toradora - / Toradora! - /;
+  $newname =~ s/ Dragon Crisis / Dragon Crisis! /;
+  $newname =~ s/ Mao Chan / Mao-chan /;
+  $newname =~ s/^Arigatou\.Bleach\.(\d+)\.\[h264\.AAC\]/Bleach - $1 [Arigatou]/;
+  $newname =~ s/^Arigatou\.Bleach\.(\d+)\.\[x264\.AAC\]/Bleach - $1 [Arigatou]/;
+  $newname =~ s/^Arigatou\.Bleach\.(\d+)\. \[\.AAC\]/Bleach - $1 [Arigatou]/;
+  $newname =~ s/^Arigatou\.Bleach\.(\d+)v2\. \[\.AAC\]/Bleach - $1 [Arigatou][v2]/;
+  $newname =~ s/ Ep(\d+)v3 \[R2 Video\]/ - $1 [v3]/;
+  $newname =~ s/ Brighter Than The Dawning Blue - Crescent Love Ep(\d+) Subbed / Brigher Than The Dawning Blue - Crescent Love - $1 /;
+  $newname =~ s/ Brighter Than The Dawning Blue - Crescent Love - (\d+) Subbed / Brigher Than The Dawning Blue - Crescent Love - $1 /;
+  $newname =~ s/ Character Monologue 0/ Character Monologue /;
+  $newname =~ s/Ookami-san\.to\.Shichinin\.no\.Nakama-tachi\.EP(\d+)\(BD\.1080p\.AAC\)/Ookami-san - $1 [1080p BD]/;
+  $newname =~ s/Ore.?tachi ni tsubasa wa nai /Oretachi ni Tsubasa wa Nai /i;
+  $newname =~ s/\[anime-rg . ray=out\]/[anime-rg ray=out]/;
+  $newname =~ s/^Arigatou\.Soul\.Eater\.Ep(\d+)\. \[x264\.AAC\]/[Arigatou] Soul Eater - $1 /;
+  $newname =~ s/^\[Doremi\]\.HeartCatch\.PreCure!\.(\d+)\.\[1280x720\]\./[Doremi] HeartCatch PreCure! - $1 [720p]/;
+  $newname =~ s/^\[Doremi-CureCom\]\.Suite\.PreCure!\.(\d+)\.\[1280x720\]\./[Doremi-CureCom] Suite PreCure! - $1 [720p]/;
+  $newname =~ s/^\[Doremi\]\.Motto\.Ojamajo\.Doremi\.(\d+)\./[Doremi] Motto Ojamajo Doremi - $1 /;
+  $newname =~ s/^\[Doremi\] *\.Ojamajo\.Doremi\.Dokkaan!\.(\d+)\./[Doremi] Ojamajo Doremi Dokkaan! - $1 /;
+  $newname =~ s/^\[HorribleSubs\] Lilpri /[HorribleSubs] Hime Chen! Otogi Chikku Idol Lilpri - /i;
+  $newname =~ s/^\[Jumonji-Giri\] \[AnY\]/[Jumonji-Giri]/;
+  $newname =~ s/\[(BWS|PM)\]Pocket Monsters Best Wishes (\d+) .+\[H264 /[$1] Pokemon Best Wishes - $2 [/;
+  $newname =~ s/ Ookiku Furikabutte - The Summer Tournament Chapter / Ookiku Furikabutte S2 /;
+  $newname =~ s/Les Miserables Shoujo Cosette /Les Miserables /;
+  $newname =~ s/\[Elysium\]Baka\.to\.Test\.to\.Shoukanjuu\.(EP)?/[Elysium] Baka to Test to Shokanju/;
+  $newname =~ s/\[Elysium\] Baka to Test to Shokanju/[Elysium] Baka to Test to Shokanju /;
+  $newname =~ s/ Baka to Test to Shou?kanjuu? / Baka to Test to Shokanju /;
+  $newname =~ s/\(BD\.1080p\.FLAC\)/[1080p BD]/;
+  $newname =~ s/Saizen & SD/Saizen-SD/;
+  $newname =~ s/Bleach - (\d{2}) /Bleach - 0$1 /;
+  $newname =~ s/Omamori Himari - ED \(Clean\) - 0(\d) / Omamori Himari - Ending $1 (Clean) /;
+  $newname =~ s/Omamori Himari - Opening \(Clean\) - (\d{2}) / Omamori Himari - Opening $1 (Clean) /;
+  $newname =~ s/\(B-A\)Great Teacher Onizuka - Lesson /[B-A] Great Teacher Onizuka - /;
+  $newname =~ s/Xam'd Lost Memories - (\d+) .* \[1080p,BluRay,,DTS\] - THORA\.mkv/[THORA] Xam'd Lost Memories - $1 [1080p BD].mkv/;
+  $newname =~ s/\(G P\) Escaflowne \(Remastered\)/[G_P] Escaflowne/;
+  $newname =~ s/^\(G P\) /[G_P] /;
+  $newname =~ s/SD&Taka/SD-Taka/;
+  $newname =~ s/Seikai no Senki/Banner of the Stars/;
+  $newname =~ s/Onii-chan no Koto \.\.\. /Onii-chan no Koto Nanka Zenzen Suki Janain Dakara ne /;
+  $newname =~ s/Onii-chan no Koto Nanka Zenzen Suki Janain Dakara ne /Onii-chan no Koto Nanka Zenzen Suki Janain Dakara ne!! /;
+  $newname =~ s/^Strawberry 100% - (\d+\.?\d*) \[ReDone-MDC\]/[ReDone-MDC] Strawberry 100% - $1 /;
+  $newname =~ s/^Strawberry 100% - OVA 0(\d+\.?\d*) \[ReDone-MDC\]/[ReDone-MDC] Strawberry 100% OVA - $1 /;
+  $newname =~ s/Dragonball Kai/Dragon Ball Kai/;
+  $newname =~ s/Natsu no Arashi - Akinai-chuu/Summer Storm! - Open for Business/;
+  $newname =~ s/Natsu no Arashi/Summer Storm!/;
+  $newname =~ s/Naruto (\d+-\d+) /Naruto - $1 /;
+  $newname =~ s/Lupin III Series 1 - (\d+) - .+ \[neo1024\]/[neo1024] Lupin III - $1 /;
+  $newname =~ s/Mitsudomoe Picture Drama - 0/Mitsudomoe Picture Drama - /;
+  $newname =~ s/^(Fullmetal Alchemist Brotherhood .*|Star Driver .*)(\[AtsA\])/$2 $1 /i;
+  $newname =~ s/(Sora no Woto|Ichiban Ushiro no Daimaou|Mayoi Neko Overrun!) - ([^ ]+|OP Clean|ED Clean|Theater [a-z0-9]+) \[BD 1080p\]\[AtsA\]/[AtsA] $1 - $2 [1080p BD]/;
+  $newname =~ s/(Sora no Woto|Ichiban Ushiro no Daimaou|Mayoi Neko Overrun!) ([^ ]+|Opening Clean|Ending Clean|Theater - [a-z0-9]+) \[1080p BD\]\[AtsA\]/[AtsA] $1 - $2 [1080p BD]/;
+  $newname =~ s/Battle\.Programmer\.Shirase\./Battle Programmer Shirase /;
+  $newname =~ s/Battle Programmer Shirase - 0/Battle Programmer Shirase - /;
+  $newname =~ s/ Kuragehime / Princess Jellyfish /;
+  $newname =~ s/^\[OZC\]Code Geass Lelouch of the Rebellion R2 E(\d+) .*/[OZC] Code Geass R2 - $1.mkv/;
+  $newname =~ s/ Panty and Stocking with Garterbelt / Panty & Stocking with Garterbelt /;
+  $newname =~ s/ Spice and Wolf S2 / Spice and Wolf II /;
+  $newname =~ s/\[A-E & Saizen\]/[A-E Saizen]/;
+  $newname =~ s/\[Flomp\]\[SD\]/[Flomp]/;
+  $newname =~ s/\[Jumonji-Giri\]\[Ishin\]/[Jumonji-Giri]/;
+  $newname =~ s/\[Jumonji-Giri\]\[F-B&A-E\]/[Jumonji-Giri]/;
+  $newname =~ s/\[Jumonji-Giri\] \[Lunar\]/[Jumonji-Giri]/;
+  $newname =~ s/\[A-Kraze & Diffusion\]/[A-Kraze Diffusion]/;
+  $newname =~ s/ The Story Of Saiunkoku / Saiunkoku Monogatari /i;
+  $newname =~ s/Code Geass Lelouch of the Rebellion Episode (\d+) .*(\.mkv)$/ Code Geass - $1$2/i;
+  $newname =~ s/ To LOVE-Ru / To Love-Ru /i;
+  $newname =~ s/ Inuyasha Kanketsuhen / Inuyasha Kanketsu-hen /;
+  $newname =~ s/ AIR / Air /;
+  $newname =~ s/ Sister Princess Re Pure / Sister Princess Repure /;
+  $newname =~ s/C:\\Users\\Gad\\Desktop\\yankee-megane\\Release\\//;
+  $newname =~ s/ Ep(\d+)/ $1/i;
+  $newname =~ s/\(END\)/[End]/i;
+  $newname =~ s/\(BD 1280x720 h264 JP.EN AAC\)/[720p BD]/i;
+  $newname =~ s/\[Final\]//i;
+  $newname =~ s/DB&L-E/DB L-E/;
+  $newname =~ s/IY-F&Oki/IY-F Oki/;
+  $newname =~ s/L-E&AonE/AonE L-E/;
+  $newname =~ s/^(Detective Conan - [[:digit:]]+-?[[:digit:]]*) (\[DCTP[^]]*\])(.+)$/$2 $1 $3/;
+  $newname =~ s/^(Detective Conan - [[:digit:]]+-?[[:digit:]]*) (\[AZFS[^]]*\])(.+)$/$2 $1 $3/;
+  $newname =~ s/^\[Derp\] Legend of the Legendary Heroes /[Derp] The Legend of the Legendary Heroes /;
+  $newname =~ s/ Sengoku BASARA Two / Sengoku Basara Two /;
+  $newname =~ s/ Asobi ni Ikuyo! / Asobi ni Iku Yo! /;
+  $newname =~ s/ Shinrei Tantei Yakumo / Psychic Detective Yakumo /;
+  $newname =~ s/ Ikkitousen Xtreme Xecutor OVA - 0/ Ikkitousen Xtreme Xecutor OVA - /;
+  $newname =~ s/ Megane na Kanojo OVA - 0/ Megane na Kanojo OVA - /;
+  $newname =~ s/\.Strange\.Dawn\.(\d+)\./ Strange Dawn - $1 /;
+  $newname =~ s/ (Tegami Bachi|Letter Bee) REVERSE / Letter Bee Reverse /i;
+  $newname =~ s/ Sora No Otoshimono / Sora no Otoshimono /;
+  $newname =~ s/ Kidou Tenshi Angelic Layer (ep)?/ Angelic Layer /i;
+  $newname =~ s/ Sora No Otoshimono - Forte / Sora no Otoshimono Forte /i;
+  $newname =~ s/ Shinryaku! Ika Musume / Squid Girl /;
+  #$newname =~ s/ Squid Girl / Shinryaku! Ika Musume /;
+  $newname =~ s/ Seikimatsu Occult Gakuin / Occult Academy /;
+  $newname =~ s/ Arakawa Under the Bridge ×2 / Arakawa Under the Bridge x2 /;
+  $newname =~ s/ K-ON!! S2 / K-ON!! /;
+  $newname =~ s/ Ookami-san To Shichinin No Nakama-tachi / Ookami-san /;
+  $newname =~ s/ K-On!! / K-ON!! /;
+  $newname =~ s/ Ore No Imouto / Ore no Imouto /;
+  $newname =~ s/ A Certain Magical Index II / Toaru Majutsu no Index II /i;
+  $newname =~ s/ TV Broadcast \[720p/ [LQ 720p/;
+  $newname =~ s/ ED(\d+[a-z]*)/ - Ending $1 /i;
+  $newname =~ s/ OP(\d+[a-z]*)/ - Opening $1 /i;
+  $newname =~ s/ ED / - Ending /;
+  $newname =~ s/ Clean (Opening|Ending) v2/ - $1 (Clean) [v2]/i;
+  $newname =~ s/ Creditless (Opening|Ending) (\d+) / - $1 $2 (Clean) /i;
+  $newname =~ s/ Ep(\d+) Creditless Ending / - Ending $1 (Clean) /i;
+  $newname =~ s/ (NCED|Ending Clean) / - Ending (Clean) /i;
+  $newname =~ s/ NCED(\d+) / - Ending $1 (Clean) /i;
+  $newname =~ s/ (NCOP|Opening Clean) / - Opening (Clean)/i;
+  $newname =~ s/ OP / - Opening /;
+  $newname =~ s/ (\d+-\d+) / - $1 /;
+  $newname =~ s/ - - / - /g;
+  $newname =~ s/ Ep / /ig;
+  ##SLICED BREAD
+  $newname =~ s/(\(|\[) *(10bit-v2) *(\)|\])/[v2]/i;
+  $newname =~ s/(\(|\[) *(720x480|10-?bit|10bit 480p H264|640x360|640x360 H264 AAC|h264\.aac|hi10p|10bit|\d+th Release|x264\.aac|xvid|divx5\.2\.1|divx5\.1|divx5\.05|divx5\.1\.1|h\.?264 AC3|848x480|H264 848x480|h264-480p AAC|h\.264-480p) *(\)|\])//i;
+  $newname =~ s/\[(DVD 10bit)\]/[DVD]/i;
+  $newname =~ s/(\(|\[) *(DVD H264 720x480 AAC|DVD 704x480 H264 AC3|DVD 704x480|DVDRip\.Xvid\.864x480\.Vorbis|DVD H264 848x480|DVD 720x480|DVD H264 720x480|DVD, wmv, mp3) *(\)|\])/[DVD]/i;
+  $newname =~ s/(\(|\[) *(BD\]\[1080p-FLAC|1920x1080 Hi10p h264 AAC|BD 1920x1080 x264 AAC|BD 1080p Hi10P|BDRip 1080p x264 FLAC|BD-1080p-|BD-1080p-FLAC|1920x1038 Blu-Ray FLAC|1920x1080 Blu-Ray FLAC|1920x1080 h264 BD FLAC|1920x1080 BD|BD\.1080p\.FLAC|BD 1080p H\.264 AAC 5\.1|BD 1080p) *(\)|\])/[1080p BD]/i;
+  $newname =~ s/(\(|\[) *(Hi10P 1280x720 H264|Hi10P 1280x720|1280x720 Hi10P|1280x720 5\.1|1280x720 x264 AAC|1280x720 H264 AAC|720p H264 AAC|1280x720|1280x720 H\.?264 AAC) *(\)|\])/[720p]/i;
+  $newname =~ s/(\(|\[) *(BDrip 720p Vorbis|BD 720p Hi10P AAC|BD, 720p,|BD 720p H264-AAC|BDRip 720p|BD, 720p, ,|1280x720 BD|BD 1280x720 H264 AAC|BD 720p|BD 720p FLAC|BD 1280x720 H264 AAC) *(\)|\])/[720p BD]/i;
+  $newname =~ s/(\(|\[) *(BD 540p) *(\)|\])/[BD]/i;
+  $newname =~ s/(\(|\[) *(1024x576|H264 1024x576) *(\)|\])/[576p]/i;
+  $newname =~ s/(\(|\[) *(1920x1080) *(\)|\])/[1080p]/i;
+  ##SLICED BREAD pt.2
+  $newname =~ s/(\d+)v(\d+)/$1 [v$2]/i;
+  $newname =~ s/\[BD\]\[1920x1080 H264-Flac\]/[1080p BD]/i;
+  $newname =~ s/\[BD\]\[720p-AAC\]/[720p BD]/i;
+  $newname =~ s/\.DVD/[DVD]/;
+  #$newname =~ s/ ~(.+)~ / - $1 /;
+  $newname =~ s/v2 \(BD-1080p\) / [v2 1080p BD]/i;
+  $newname =~ s/v2 \(BD H264 1280x960 24fps AAC\) / [v2 960p BD]/i;
+  $newname =~ s/BD 1280x720 FLAC\]/ 720p BD]/i;
+  $newname =~ s/\[HD\]\.mp4/.mp4/;
+  $newname =~ s/\[\.?AC3\]//i;
+  $newname =~ s/\[720p H264 AAC5\.1\]/[720p]/;
+  $newname =~ s/\[BD 720p\]/[720p BD]/;
+  $newname =~ s/ \(BD H264 1280x960 24fps AAC\) / [960p BD]/i;
+  $newname =~ s/ \(h\.264\) //i;
+  $newname =~ s/\(xvid-mp3\)//i;
+  $newname =~ s/\(BD 1920x1080 *\)/[1080p BD]/i;
+  $newname =~ s/\[BD 1080p\]/[1080p BD]/i;
+  $newname =~ s/v3 \(BD-1080p\) / [v3 1080p BD]/i;
+  $newname =~ s/v0 \[720p\]/ [v0 720p]/i;
+  $newname =~ s/v0 \[/ [v0 /i;
+  $newname =~ s/\[BD 1920x1080\]/[1080p BD]/;
+  $newname =~ s/\[1080p - Bluray\]/[1080p BD]/;
+  $newname =~ s/\[Bluray - 1080p\]/[1080p BD]/;
+  $newname =~ s/\[BD 1080p AAC\]/[1080p BD]/;
+  $newname =~ s/ \(BD-1080p\) / [1080p BD]/i;
+  $newname =~ s/ \(720p, BD\) / [720p BD]/i;
+  $newname =~ s/ \(BD 1280x960 24fps 5\.1ch\) / [960p BD]/i;
+  $newname =~ s/ \(Bluray, 720p, AAC\) / [720p BD]/i;
+  $newname =~ s/ \(720p,BluRay\) / [720p BD]/i;
+  $newname =~ s/ \(BD, 720p, FLAC\) / [720p BD]/i;
+  $newname =~ s/\[END\]/[End]/;
+  $newname =~ s/\[BD\]\[720p FLAC\]/[720p BD]/;
+  $newname =~ s/\[BD\]\[720p\]/[720p BD]/;
+  $newname =~ s/\[BD\]\[1080p\]/[1080p BD]/;
+  $newname =~ s/\[h264-480p AAC\]//;
+  $newname =~ s/\[h.264-480p\]//i;
+  $newname =~ s/ v3 \[720p\]/[v3 720p]/i;
+  $newname =~ s/1280x720 H264 OGG/720p/;
+  $newname =~ s/ \[BD 1080p FLAC\]/ [1080p BD]/i;
+  $newname =~ s/ \[720p BD FLAC\]/ [720p BD]/i;
+  $newname =~ s/ \[720p Blu-ray AAC\]/ [720p BD]/i;
+  $newname =~ s/ \[BD\]\[h264-1080p FLAC\]/ [1080p BD]/i;
+  $newname =~ s/ \(1920x1080\) \[BD\]/ [1080p BD]/i;
+  $newname =~ s/ \(960x720 Blu-Ray FLAC\) / [720p BD]/i;
+  $newname =~ s/ \(1920x1080 Blu-Ray FLAC\) / [1080p BD]/i;
+  $newname =~ s/ \(1280x720 Blu-Ray FLAC\) / [720p BD]/i;
+  $newname =~ s/ \(1280x720 h264 BD FLAC\) / [720p BD]/i;
+  $newname =~ s/\((704|720)x480 DVD (AC3|AAC)\)/ [DVD]/i;
+  $newname =~ s/ \(960x720\) \[BD\]/ [720p BD]/i;
+  $newname =~ s/\(704x396\)//;
+  $newname =~ s/\(1280x720\)/ [720p]/i;
+  $newname =~ s/\(1920x1080\)/ [1080p]/i;
+  $newname =~ s/\(1024x576\)/ [576p]/i;
+  $newname =~ s/\[v(\d+) 1024x576\]/[v$1 576p]/i;
+  $newname =~ s/\(1280x720 h264\)/ [720p]/i;
+  $newname =~ s/\(1280x720 ?(h264|x264)?( aac)?\)/ [720p]/i;
+  $newname =~ s/\(720p\)/[720p]/i;
+  $newname =~ s/\(1080p\)/[1080p]/i;
+  $newname =~ s/\(1080p,BD\)/[1080p BD]/i;
+  $newname =~ s/\(BD,1080p\)/[1080p BD]/i;
+  $newname =~ s/\((BD 720p)\)/ [720p BD]/i;
+  $newname =~ s/\(DVD\)/ [DVD]/i;
+  $newname =~ s/\[h264-480p\]//i;
+  $newname =~ s/\[H264\]//i;
+  $newname =~ s/\[DVD\]\[v2\]/[v2 DVD]/i;
+  $newname =~ s/xvid//i;
+  $newname =~ s/\[(AC3|AAC|H264|X264)\]//i;
+  $newname =~ s/\[H264&MP3\]//i;
+  $newname =~ s/\[H264-AAC\]//i;
+  $newname =~ s/\+AAC//i;
+  $newname =~ s/\[720x480 H264-Vorbis\]//i;
+  $newname =~ s/\[BD\]\[1280x720 H264-Flac\]/[720p BD]/i;
+  $newname =~ s/\[h264 Vorbis\]//i;
+  $newname =~ s/\[640x480 h\.264 AAC\]//i;
+  $newname =~ s/\[720x480 AR h\.264 AAC\]//i;
+  $newname =~ s/\[DVD H264 640x476\]/[DVD]/i;
+  $newname =~ s/\[720p\]/[720p]/i;
+  $newname =~ s/\[720p\]\[BD\]/[720p BD]/i;
+  $newname =~ s/\[H264 1280x720\]/[720p]/i;
+  $newname =~ s/\[H264 1280x720 OGG\]/[720p]/i;
+  $newname =~ s/\[1280x720\]/[720p]/i;
+  $newname =~ s/\[1280x720 BD\]/[720p BD]/i;
+  $newname =~ s/\[h264-720p\]/[720p]/i;
+  $newname =~ s/\[h264-1080p FLAC\]/[1080p]/i;
+  $newname =~ s/\[BD\]\[h264-1080p AC3\]/[1080p BD]/i;
+  $newname =~ s/\[-/[/i;
+  $newname =~ s/ \(1280x720 x264 AAC\)/ [720p]/i;
+  $newname =~ s/ *\( *\d+x(1080|960|720|576) *Blu-Ray *(FLAC|) *\) */[$1p BD]/i;
+  $newname =~ s/\[720p\]\[v2\]/[v2 720p]/i;
+  $newname =~ s/\[480p\]//i;
+  $newname =~ s/\[v2\]\[720p\]/[v2 720p]/i;
+  $newname =~ s/\[(v\d)\]\[(\d+p)(| BD)\]/[$1 $2$3]/i;
+  $newname =~ s/\[H264 - AAC\]//i;
+  $newname =~ s/\[H264 1280x720 AAC\] /[720p]/i;
+  $newname =~ s/\[DVD 480p\]/[DVD]/i;
+  $newname =~ s/\[704x480 DVD\]/[DVD]/i;
+  $newname =~ s/\[720p\]\[End\]/[End 720p]/i;
+  $newname =~ s/ R2 DVD\(H264\.AC3\)/ [DVD]/i;
+  $newname =~ s/ - Ep / - /i;
+  $newname =~ s/(h|x)\.?264//i;
+  $newname =~ s/\[BD\]\[1080p-?\]/[1080p BD]/;
+  $newname =~ s/AAC5\.1//;
+  $newname =~ s/FLAC//;
+  $newname =~ s/ aac//i;
+  $newname =~ s/ ac3//i;
+  $newname =~ s/\.DVD/ [DVD]/i;
+  $newname =~ s/ DVD / [DVD] /i;
+  $newname =~ s/\(DVD ?\)/ [DVD] /i;
+  $newname =~ s/ Ep(\d+) / - $1 /;
+  $newname =~ s/ Ep(\d+)v2 / - $1 [v2]/;
+  $newname =~ s/ (\d+) / - $1 /;
+  $newname =~ s/ (\d+)v(2|3) / $1 [v${2}]/;
+  $newname =~ s/\[720x480 AR FLAC\]//i;
+  $newname =~ s/\[DVD 640x480\]/[DVD]/;
+  $newname =~ s/\[BD 1280x720\]/[720p BD]/i;
+  $newname =~ s/\[v(\d+) (1280x)(720)\]/[v$1 $3p]/i;
+  $newname =~ s/ Episode (- )+(\d+) / - $2 /;
+  $newname =~ s/ - (\d+) *v(\d) / - $1 [v$2]/i;
+  $newname =~ s/\[V(\d)\]/[v$1]/;
+  #DANGEROUS CLEANUPS
+  $newname =~ s/ \[v(2|3)\]\[(.+)\]\[([0-9A-Fa-f]{8})\]/ [v$1 $2][$3]/;
+  $newname =~ s/\]/] /g;
+  $newname =~ s/\[/ [/g;
+  $newname =~ s/\] +\[/][/g;
+  $newname =~ s/(\[|\() +/$1/g;
+  $newname =~ s/ +(\]|\))/$1/g;
+  $newname =~ s/( -)+ / - /g;
+  $newname =~ s/(\[|\()([0-9a-fA-F]{8})(\]|\))/[\U$2]/;
+  $newname =~ s/ +(\.\w{3})$/$1/;
+  $newname =~ s/\[\]//g;
+  $newname =~ s/\(\)//g;
+  $newname =~ s/ - (\d+) - (\d+) / $1 - $2 /;
+  #EXCEPTIONS
+  $newname =~ s/^\[DB&L-E\]/[DB L-E]/;
+  $newname =~ s/ VS Knight Lamune & - 40 fire / VS Knight Lamune & 40 fire /;
+  $newname =~ s/ RAINBOW / Rainbow /;
+  $newname =~ s/ (Infinite Ryvius - Ryvius Illusion|Infinite Ryvius - Ryvius VJ Mix|Kara no Kyoukai - Cinema Intro) - / $1 /;
+  $newname =~ s/ Golgo - 13 / Golgo 13 /;
+  $newname =~ s/ Strike Witches - 2 / Strike Witches 2 - /;
+  $newname =~ s/ 07-GHOST / 07-Ghost /;
+  $newname =~ s/ K-ON!! B-Side Theater - Uraon!! - / K-ON!! B-Side Theater - Uraon!! /;
+  $newname =~ s/ Captain Tsubasa Road to - 2002 / Captain Tsubasa Road to 2002 /;
+  $newname =~ s/ Ultraviolet Code - 044 - / Ultraviolet Code 044 - /;
+  $newname =~ s/ Persona - 3 Picture Drama - She Goes For A Walk / Persona 3 Picture Drama - She Goes For A Walk - /;
+  $newname =~ s/ SP0/ - Special /;
+  $newname =~ s/ SP(\d+) / - Special $1 /;
+  $newname =~ s/ Special - / - Special /;
+  $newname =~ s/ Animated Commentary - / - Animated Commentary /;
+  $newname =~ s/ Fullmetal Alchemist Brotherhood (- |)Skit - / Fullmetal Alchemist Brotherhood - Skit /i;
+  $newname =~ s/ - Picture Drama - / - Picture Drama /;
+  $newname =~ s/ (Mayoi Neko Overrun! - Theater) - / $1 /;
+  $newname =~ s/ Opening - / Opening /;
+  $newname =~ s/ Ending - / Ending /;
+  $newname =~ s/ Hidamari Sketch Hoshimittsu - Special / Hidamari Sketch Hoshimittsu Special - /;
+  $newname =~ s/ Spice and Wolf S2 - BD Menu - 0/ Spice and Wolf S2 - BD Menu /;
+  $newname =~ s/ Canvas - 2 - / Canvas 2 - /;
+  $newname =~ s/ To Heart - 2 / To Heart 2 /;
+  $newname =~ s/ Tsubasa Chronicles - 2 (\d{2}) / Tsubasa Chronicles 2 - $1 /;
+  $newname =~ s/ Mitsudomoe - 2 - / Mitsudomoe 2 - /;
+  $newname =~ s/ Morita-san wa Mukuchi - 2 / Morita-san wa Mukuchi 2 /i;
+  $newname =~ s/ Eyeshield - 21 - / Eyeshield 21 - /;
+  $newname =~ s/ - opening - (\d+) / - Opening $1 /i;
+  $newname =~ s/ - ending - (\d+) / - Ending $1 /i;
+  $newname =~ s/ Eyeshield 21 - (\d{2}) / Eyeshield 21 - 0$1 /;
+  $newname =~ s/ Eyeshield 21 - (\d{2})-(\d{2}) / Eyeshield 21 - 0$1-0$2 /;
+  $newname =~ s/ - 2010 Young Animator / 2010 Young Animator /;
+  $newname =~ s/ Mahoujin Guruguru - 2 - Doki Doki Densetsu - / Mahoujin Guruguru 2 - Doki Doki Densetsu - /;
+  $newname =~ s/ The World God Only Knows - 2 - / The World God Only Knows 2 - /;
+  $newname =~ s/ Legend of Galactic Heroes Gaiden - 2 - / Legend of Galactic Heroes Gaiden 2 - /;
+  $newname =~ s/ Kara no Kyoukai - (\d+) / Kara no Kyoukai - Chapter $1/;
+  $newname =~ s/\[G P\]/[G_P]/i;
+  #SAFE CLEANUPS
+  $newname =~ s/ +/ /g;
+  $newname =~ s/^ +//;
+  $newname =~ s/(- )+/- /;
+  $newname =~ s/^\[N - F\]/[N-F]/;
+  $newname =~ s/^\[K-F & AKUPX\]/[K-F AKUPX]/;
+  $newname =~ s/^\[([&!\.\s\w\- ]+)\] (Air Master|Crystal Blaze|Fairy Tail|Yawara|Ultraviolet Code 044|Gintama|Prince of Tennis|Lupin III S2|Kyou Kara Maou|Bleach|Naruto|One Piece|Detective Conan) - (Ending \d+|Opening \d+|Special \d+|\d+|\d+-\d+) /$2 - $3 [$1]/;
+  $newname =~ s/^Naruto - (\d{2}) /Naruto - 0$1 /;
+  $newname =~ s/^Fairy Tail - (\d{2}) /Fairy Tail - 0$1 /;
+  $newname =~ s/^Naruto - (\d{2})-(\d{2}) /Naruto - 0$1-0$2 /;
+  if ($^O eq "MSWin32") { $newname =~ s/ *\\ */\\/g; }
+  print(qq($_: $newname already exists, skipping\n)) and next() if -e $newname and $_ ne $newname;
+  if ($_ eq $newname) {
+    print("$_: no need to rename, skipping\n");
+  } else {
+    if($skip==1) { print("Result: $_ --> $newname\n"); }
+    else {
+      if(rename($_, $newname)) { print("$_ -> $newname\n"); }
+      else { print("$_: rename failed\n"); }
+    }
+  }
+  next();
+}
+
+exit(0);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bin/rmcrc	Sun Oct 02 04:33:47 2011 +0700
@@ -0,0 +1,27 @@
+#!/usr/bin/env perl
+
+use warnings;
+use strict;
+use File::Basename;
+
+my @files = @ARGV or print("Usage: ",basename($0)," file1 ... fileN\n") && exit(1);
+my $skip=0;
+foreach (@files) {
+  print(qq(Could not find file "$_", skipping\n)) and next() unless -e $_;
+  my $newname = $_;
+  $newname =~ s/\[[[:xdigit:]]{8}\]//i;
+  $newname =~ s/ *(\.\w+)$/$1/;
+  print(qq($_: $newname already exists, skipping\n)) and next() if -e $newname and $_ ne $newname;
+  if ($_ eq $newname) {
+    print("$_: no need to rename, skipping\n");
+  } else {
+    if($skip==1) { print("Result: $_ --> $newname\n"); }
+    else {
+      if(rename($_, $newname)) { print("$_ -> $newname\n"); }
+      else { print("$_: rename failed\n"); }
+    }
+  }
+  next();
+}
+
+exit(0);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bin/smu	Sun Oct 02 04:33:47 2011 +0700
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+keyword=$(printf "%s\n" "$*" | tr ' ' '*')
+find /anime/music/ -iname "*${keyword}*"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bin/statfun	Sun Oct 02 04:33:47 2011 +0700
@@ -0,0 +1,8 @@
+#!/bin/sh
+> /tmp/mainlogfun
+while read line; do
+	filename=$(printf "%s" "${line}" | grep OK\ DOWNLOAD | grep -v "^$" | sed -e 's/.*OK DOWNLOAD: Client "[^"]*", "\(.*\)"..*/\1/')
+	basename -- "${filename}" >> /tmp/mainlogfun
+done < /srv/log/vsftpd/main.log
+grep -v "^$" /tmp/mainlogfun > /root/mainlogfun
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bin/termcolors.sh	Sun Oct 02 04:33:47 2011 +0700
@@ -0,0 +1,44 @@
+#!/bin/sh
+
+# Usage:
+#   _c [bold_|]<color> <text>
+#
+#   <color> can be one of:
+#     black, blue, green, cyan, red, purple, brown, gray
+#   Prefix the color with bold_ to use bold style/light color.
+#
+# Example:
+#   To print word "Hello" in bold blue:
+#     _c bold_blue "Hello"
+#
+#   To print text with only one word colored:
+#     echo "Hello, $(c green world)."
+#
+# To do:
+#   Support for background color, underline, etc.
+#
+
+_c() {
+  color_name="${1}"
+  shift
+  text="${*}"
+  esq="\033["
+  r="${esq}0m" # r for reset
+  case "${color_name}" in
+    bold_*) color="1;";;
+    *) color="0;";;
+  esac
+  case "${color_name}" in
+    *black) color="${color}30";;
+    *blue) color="${color}34";;
+    *green) color="${color}32";;
+    *cyan) color="${color}36";;
+    *red) color="${color}31";;
+    *purple) color="${color}35";;
+    *brown) color="${color}33";;
+    *gray) color="${color}37";;
+  esac
+  color="${esq}${color}m"
+  printf "${color}%s${r}" "${text}"
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bin/testcrc	Sun Oct 02 04:33:47 2011 +0700
@@ -0,0 +1,16 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+use String::CRC32;
+
+my @files = @ARGV or print("Usage u fail") && exit(1);
+
+foreach(@files) {
+	my $filename = $_;
+	open(FILE,$filename);
+	my $crc=crc32(*FILE);
+	close(FILE);
+	$crc=sprintf("%X",$crc);
+	print("$filename: $crc\n");
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bin/xkcdmania	Sun Oct 02 04:33:47 2011 +0700
@@ -0,0 +1,29 @@
+#!/bin/sh
+
+dir="/anime/misc/webcomics/xkcd"
+[ -d "${dir}" ] || exit 1
+
+fetchlink() {
+  if [ "$1" -a "$2" ]; then
+    wget --quiet -O "$2" "$1"
+  else
+    return 1
+  fi
+}
+latest=$(fetchlink http://xkcd.com/ - | grep 'Permanent link' | sed -e 's/.*\/\([0-9]*\)\/.*/\1/')
+[ -n "${latest}" ] || exit 1
+next=1
+while [ "${next}" -le "${latest}" ]; do
+  to_dl="${to_dl} ${next}"
+  next=$((next + 1))
+done
+
+for i in $to_dl
+do
+  if [ ! -n "$(find "$dir/$(printf '%04d' $i)"* -type f 2>/dev/null)" ] && [ "${i}" -ne 404 ]; then
+    page=$(fetchlink "http://xkcd.com/$i/" -)
+    img=$(echo "$page" | grep 'Image URL' | sed -e 's/.*\(http[^<]*\).*/\1/' | head -n 1)
+    echo "$(echo "$page" | grep "src" | grep "$img" | sed -e 's/.*title="\([^\"]*\)".*/\1/')" > "$dir/$(printf '%04d' $i) $(basename $img | sed -e 's/\(.*\)\..*/\1/').txt"
+    fetchlink "${img}" "$dir/$(printf '%04d' $i) $(basename "$img")"
+  fi
+done
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rc/bash	Sun Oct 02 04:33:47 2011 +0700
@@ -0,0 +1,93 @@
+#!/usr/bin/env bash
+
+if [ "${ECOS_BASH_LOADED}" != "yes" ]; then
+  ECOS_BASH_LOADED="yes"
+else
+  return
+fi
+
+[ -f "${HOME}/.ecos_bash.before" ] && . "${HOME}/.ecos_bash.before"
+
+_org_path="${PATH}"
+export PATH="${HOME}/.ecos_bin:${HOME}/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin"
+
+PS1='[\u@\h \W]\$ '
+#PS1='[\[\e[0;33m\]\u\[\e[0m\]@\[\e[0;32m\]\h\[\e[0m\] \[\e[1;34m\]\W\[\e[0m\]]\$ '
+
+shopt -s histappend
+PROMPT_COMMAND='history -a'
+export HISTFILESIZE=10000
+export HISTCONTROL=ignoredups
+
+export PAGER="less -Rins"
+export EDITOR=vi
+export LANG="en_US.UTF-8"
+unset LS_COLORS
+
+alias less="less -Rins"
+#assuming POSIX grep
+alias fgrep="grep -F"
+alias egrep="grep -E"
+alias ls="ls -F"
+alias rm="rm -i"
+alias rd="rdesktop -g 1280x600 -K -a 16 -z -P -r sound:off -r clipboard:CLIPBOARD -5"
+
+_has_rm_I=
+_has_gnu_ls=
+_has_gnu_grep=
+case "$(uname -s)" in
+  Linux)
+    _has_rm_I=y
+    _has_gnu_ls=y
+    _has_gnu_grep=y
+  ;;
+  SunOS)
+    [ -x /usr/gnu/bin/rm ] && _has_rm_I=y
+    [ -x /usr/gnu/bin/ls ] && _has_gnu_ls=y
+    [ -x /usr/gnu/bin/grep ] && _has_gnu_grep=y
+    [ -d /usr/xpg4/bin ] && PATH="/usr/xpg4/bin:${PATH}"
+    [ -d /opt/csw/bin ] && PATH="/opt/csw/bin:${PATH}"
+    [ -d /opt/csw/sbin ] && PATH="/opt/csw/sbin:${PATH}"
+    [ -d /usr/gnu/bin ] && PATH="/usr/gnu/bin:${PATH}"
+    export PATH
+    alias ping="ping -s"
+    alias ping6="ping -A inet6"
+  ;;
+  FreeBSD)
+    _has_rm_I=y
+    export CLICOLOR=
+    export LSCOLORS=ExGxFxdxCxegedabagExEx
+  ;;
+  OpenBSD)
+    if command -v colorls > /dev/null 2>&1; then
+      export CLICOLOR=
+      export LSCOLORS=ExGxFxdxCxegedabagExEx
+      alias ls='colorls -F'
+    fi
+  ;;
+  CYGWIN*)
+    export PATH="${PATH}:${_org_path}"
+  ;;
+esac
+
+[ "${_has_rm_I}" = y ] && alias rm="rm -I"
+[ "${_has_gnu_ls}" = y ] && alias ls="ls -F --color=auto"
+[ "${_has_gnu_grep}" = y ] && alias grep="grep --color=auto"
+
+unset _has_rm_I
+unset _has_gnu_ls
+unset _has_gnu_grep
+
+
+case "${TERM}" in
+  xterm*|screen*|dtterm)
+    PROMPT_COMMAND='echo -ne "\033]0;${LOGNAME}@${HOSTNAME}: ${PWD}\007";'"${PROMPT_COMMAND}"
+  ;;
+esac
+
+if command -v vim > /dev/null 2>&1; then
+  alias vi=vim
+  export EDITOR=vim
+fi
+[ -f "${HOME}/.ecos_bash.after" ] && . "${HOME}/.ecos_bash.after"
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rc/hg	Sun Oct 02 04:33:47 2011 +0700
@@ -0,0 +1,18 @@
+[ui]
+username = Edho Arief <edho@myconan.net>
+merge = vimdiff
+verbose = true
+
+[merge-tools]
+vimdiff.executable = vim
+vimdiff.args = -d $base $local $output $other +close +close
+
+[extensions]
+#hgext.convert = 
+#progress =
+
+[hostfingerprints]
+bitbucket.org = 81:2b:08:90:dc:d3:71:ee:e0:7c:b4:75:ce:9b:6c:48:94:56:a1:fe
+
+[defaults]
+addremove = --similarity 100
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rc/inputrc	Sun Oct 02 04:33:47 2011 +0700
@@ -0,0 +1,33 @@
+#Basic settings
+set bell-style none
+set keymap emacs
+
+#Home/End
+#GNOME Terminal
+"\eOH": beginning-of-line
+"\eOF": end-of-line
+#tmux
+"\e[1~": beginning-of-line
+"\e[4~": end-of-line
+
+#Delete
+"\e[3~": delete-char
+
+#Alt-Left/Right
+#GNOME Terminal
+"\e[1;3D": backward-word
+"\e[1;3C": forward-word
+#tmux
+"\e\e[D": backward-word
+"\e\e[C": forward-word
+
+#Up/Down
+"\e[A": history-search-backward
+"\e[B": history-search-forward
+#GNOME Terminal
+"\eOA": history-search-backward
+"\eOB": history-search-forward
+
+#Misc
+"\C-w": unix-filename-rubout
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rc/tcsh	Sun Oct 02 04:33:47 2011 +0700
@@ -0,0 +1,104 @@
+#!/usr/bin/env tcsh
+[ -e "${HOME}/.ecos_tcsh.before" ] && source "${HOME}/.ecos_tcsh.before"
+umask 22
+limit coredumpsize 0
+
+set prompt="[%B%n@%m %~%b]%# "
+set path=({,/usr}/{bin,sbin} "${HOME}"/{,.ecos_}bin)
+set history=1000
+set savehist=1000
+set nobeep
+set filec
+
+setenv EDITOR vi
+setenv PAGER less
+setenv BLOCKSIZE K
+setenv LC_COLLATE C
+setenv LANG en_US.UTF-8
+
+unset autologout
+unset autoexpand
+unset autolist
+unset ignoreeof
+
+unalias \*
+alias rd "rdesktop -g 1280x700 -K -a 16 -z -P -r sound:off -r clipboard:CLIPBOARD -5"
+alias h history 25
+alias j jobs -l
+alias la ls -A
+alias ll ls -lA
+alias ls ls -F
+alias rm rm -i
+
+if ($?prompt) then
+  set gnuls_opts="--color=auto --group-directories-first -F"
+  set iscolor=0
+  switch (${TERM})
+    case xterm*:
+    case dtterm:
+    case screen*:
+      setenv CLICOLOR 
+      set myhost=`hostname | cut -d '.' -f 1`
+      set prompt="[%{\033[0;33m%}%n%{\033[0m%}@%{\033[0;32m%}%m%{\033[0m%} %{\033[1;34m%}%c%{\033[0m%}]%# "
+      alias mypwd 'printf "%s\n" "${PWD}" | sed -e "s#^${HOME}#~#"'
+      alias precmd 'printf "\033]0;${USER}@${myhost}: %s\007" "`mypwd`"'
+      set iscolor=1
+    breaksw
+  endsw
+
+  if ("$TERM" == "screen") then
+    bindkey '\e[1~' beginning-of-line
+    bindkey '\e[3~' delete-char
+    bindkey '\e[4~' end-of-line
+    bindkey '\e[5~' history-search-backward
+    bindkey '\e[6~' history-search-forward
+    bindkey '\eOD' backward-word
+    bindkey '\eOC' forward-word
+    bindkey '\e\e[D' backward-word
+    bindkey '\e\e[C' forward-word
+  endif
+  bindkey "^W" backward-delete-word
+  bindkey -k up history-search-backward
+  bindkey -k down history-search-forward
+endif
+
+switch (`uname -s`)
+  case FreeBSD:
+    set path=(${path} /usr/local/{bin,sbin})
+    setenv LSCOLORS ExGxFxdxCxegedabagExEx
+    alias ls ls -FG
+    ( which gnuls ) > /dev/null && alias ls gnuls ${gnuls_opts}
+    alias man man -o
+    alias rm rm -I
+    alias top top -P
+  breaksw
+  case NetBSD:
+    set path=(${path} /usr/pkg/{bin,sbin})
+    breaksw
+  case OpenBSD:
+    set path=(${path} /usr/local/{bin,sbin})
+    setenv LSCOLORS ExGxFxdxCxegedabagExEx
+    [ "${iscolor}" -eq 1 ] && setenv TERM xterm-256color
+    ( which colorls ) > /dev/null && alias ls colorls -FG
+  breaksw
+  case DragonFly:
+    set path=(${path} /usr/pkg/{bin,sbin})
+    setenv LSCOLORS ExGxFxdxCxegedabagExEx
+    alias ls ls -FG
+  breaksw
+  case SunOS:
+    set path=(${path} /usr/{gnu,csw,xpg4}/{bin,sbin})
+    [ -x /usr/gnu/bin/ls ] && alias ls /usr/gnu/bin/ls ${gnuls_opts}
+  breaksw
+  case Linux:
+    alias ls ls ${gnuls_opts}
+    alias grep grep --color=auto
+  breaksw
+endsw
+unset gnuls_opts
+
+( which vim ) > /dev/null && alias vi vim && setenv EDITOR vim
+
+[ -e "${HOME}/.ecos_tcsh.after" ] && source "${HOME}/.ecos_tcsh.after"
+
+[ -x "/usr/games/fortune" ] && "/usr/games/fortune"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rc/tmux	Sun Oct 02 04:33:47 2011 +0700
@@ -0,0 +1,29 @@
+##PRE-1.4
+#set -g terminal-overrides '*:acsc@'
+
+##UNDEFINED. NEED CHECK WHICH VERSION
+set -g repeat-time 0
+set -g status-bg blue
+set -g status-fg white
+
+set -g status-left '[#S]'
+set -g status-left-attr bold
+set -g status-left-fg yellow
+
+set -g status-right '#[fg=yellow,bold]#H | %b-%d %H:%M '
+
+set -g status-utf8 on
+setw -g utf8 on
+
+#set -g pane-border-bg black
+#set -g pane-border-fg white
+#set -g pane-active-border-bg black
+set -g pane-active-border-fg blue
+
+set -g set-titles on
+set -g set-titles-string '[#S] #I:#W #T'
+
+setw -g window-status-current-bg red
+setw -g window-status-current-fg white
+setw -g window-status-current-format '#I:#W'
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rc/vim	Sun Oct 02 04:33:47 2011 +0700
@@ -0,0 +1,29 @@
+set showmode
+set showcmd
+set nomodeline
+set autoindent
+set lazyredraw
+set vb t_vb=
+set ruler
+set nohls
+set nocompatible
+set backspace=2
+set esckeys
+set noerrorbells
+syntax on
+set ts=2
+set expandtab
+set title
+
+map <C-t><up> :tabr<cr>
+map <C-t><down> :tabl<cr>
+map <C-t><left> :tabp<cr>
+map <C-t><right> :tabn<cr>
+map <C-t>p :tabp<cr>
+map <C-t>n :tabn<cr>
+map <C-t><C-t> :NERDTreeToggle<cr>
+map <C-t><C-m> :NERDTreeMirror<cr>
+
+"autocmd VimEnter * NERDTree
+"autocmd BufEnter * NERDTreeMirror
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rc/zsh	Sun Oct 02 04:33:47 2011 +0700
@@ -0,0 +1,26 @@
+#!/usr/bin/env zsh
+[ -f "${HOME}/.ecos_zsh.before" ] && . "${HOME}/.ecos_zsh.before"
+case $TERM in
+  xterm*|screen*)
+    precmd () {print -Pn "\e]0;%n@%m: %~\a"}
+  ;;
+esac
+PS1='[%n@%m %~]%% '
+export PATH="${HOME}/.ecos_bin:${PATH}"
+HISTFILE=~/.histfile
+HISTSIZE=10000
+SAVEHIST=10000
+setopt appendhistory nomatch
+unsetopt autocd beep extendedglob notify
+bindkey -e
+bindkey '^[[A' history-search-backward
+bindkey '^[[B' history-search-forward
+
+autoload -Uz compinit
+compinit
+
+export EDITOR=vi
+export PAGER='less -Rins'
+alias less='less -Rins'
+alias ls='ls -F'
+[ -f "${HOME}/.ecos_zsh.after" ] && . "${HOME}/.ecos_zsh.after"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/setup	Sun Oct 02 04:33:47 2011 +0700
@@ -0,0 +1,113 @@
+#!/bin/sh
+
+basedir="`dirname "${0}"`"
+cd "${basedir}"
+basedir="`pwd`"
+rcdir="${basedir}/rc"
+bindir="${basedir}/bin"
+
+test -n "${HOME}" || exit 1
+
+_echo() {
+  _echon "${*}"; printf "\n"
+}
+_echon() {
+  printf "%s" "${*}"
+}
+
+_tcsh() {
+  case "$1" in
+    uninstall|install)
+      _rc "${1}" "tcsh" ".ecos_tcsh"
+      _init "${1}" '[ -r "${HOME}/.ecos_tcsh" ] && source "${HOME}/.ecos_tcsh" #ECCORE_TCSH' ".cshrc"
+    ;;
+  esac
+}
+
+_bash() {
+  case "$1" in
+    uninstall|install)
+      _rc "${1}" "bash" ".ecos_bash"
+     _init "${1}" '[ -r "${HOME}/.ecos_bash" ] && . "${HOME}/.ecos_bash" #ECCORE_BASH' ".bash_profile"
+     _init "${1}" '[ -r "${HOME}/.ecos_bash" ] && . "${HOME}/.ecos_bash" #ECCORE_BASH' ".bashrc"
+    ;;
+  esac
+}
+
+_zsh() {
+  case "$1" in
+    uninstall|install)
+      _rc "${1}" "zsh" ".ecos_zsh"
+      _init "${1}" '[ -r "${HOME}/.ecos_zsh" ] && . "${HOME}/.ecos_zsh" #ECCORE_ZSH' ".zshrc"
+    ;;
+  esac
+}
+
+_rc() {
+  if test -z "${3}" || test -z "${2}" || test -z "${1}"; then
+    _echo "Invalid command."
+    return
+  fi
+  _srcfile="${rcdir}/${2}"
+  _dstfile="${HOME}/${3}"
+  if test ! -h "${_dstfile}"; then
+    if test -f "${_dstfile}"; then
+      cp "${_dstfile}" "${_dstfile}.bak"
+      _echo "${_dstfile} backed up to ${_dstfile}.bak"
+    elif test -d "${_dstfile}"; then
+      cp -r "${_dstfile}" "${_dstfile}.bak"
+      _echo "Directory ${_dstfile} backed up to ${_dstfile}.bak"
+    fi
+  fi
+  rm -rf "${_dstfile}"
+  case "${1}" in
+    install)
+      ln -fs "${_srcfile}" "${_dstfile}"
+      _echo "Installed ${_dstfile}"
+    ;;
+    uninstall)
+      _echo "Removed ${_dstfile}"
+    ;;
+  esac
+}
+
+_init() {
+  _script="${HOME}/${3}"
+  _scripttmp="${HOME}/.tmp.${3}"
+  _data="${2}"
+  if [ -f "${_script}" ]; then
+    grep -v "${_data}" "${_script}" > "${_scripttmp}"
+    mv -f "${_scripttmp}" "${_script}"
+  fi
+  case "${1}" in
+    install)
+      _echo "${_data}" >> "${_script}"
+      _echo "Added autostart to ${_script}"
+    ;;
+    uninstall)
+      _echo "Removed autostart from ${_script}"
+    ;;
+  esac
+}
+
+_help() {
+  cat <<EOF
+Usage: ${0} [install|uninstall]
+EOF
+}
+
+case "${1}" in
+  install|uninstall)
+    for i in tcsh bash zsh; do
+      _"${i}" "${1}"
+    done
+    _rc "${1}" "tmux" ".tmux.conf"
+    _rc "${1}" "hg" ".hgrc"
+    _rc "${1}" "vim" ".vimrc"
+    _rc "${1}" "inputrc" ".inputrc"
+    _rc "${1}" "../bin" ".ecos_bin"
+  ;;
+  *)
+    _help
+  ;;
+esac