changeset 83:b65925c07cf6

Merge
author Edho Prima Arief <me@myconan.net>
date Sat, 09 Jul 2011 15:34:55 +0700
parents 428c308e609d (diff) 5f430d2aac9d (current diff)
children 4a22703b183c
files
diffstat 6 files changed, 27 insertions(+), 43 deletions(-) [+]
line wrap: on
line diff
--- a/bin/cek	Mon Jun 27 21:33:08 2011 +0700
+++ b/bin/cek	Sat Jul 09 15:34:55 2011 +0700
@@ -2,7 +2,7 @@
 
 bn() { basename "/$*"; }
 #cs() { cksfv -- "$@"; }
-cs() { cek.pl "$@"; }
+cs() { cek.py "$@"; }
 if [ "$#" -lt 1 ]; then
 	cat <<EOF
 Usage: $(bn "$0") file1 file2 ... fileN
--- a/bin/cek.pl	Mon Jun 27 21:33:08 2011 +0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,41 +0,0 @@
-#!/usr/bin/env perl
-
-use warnings;
-use strict;
-use Compress::Zlib;
-
-sub get_file_crc32 {
-  my $block_size = 1*2**20;
-  my $crc32_digest = 0;
-  my $return_code = 0;
-  my $file_name = $_[0];
-  if (!$file_name) {
-    #internal error, no file name passed to the function
-    $return_code = 10;
-  } elsif (!-f $file_name) {
-    #input file name is not a file
-    $return_code = 11;
-  } elsif (!-r $file_name) {
-    #input file is not readable
-    $return_code = 12;
-  }
-  if ($return_code == 0) {
-   open(my $file_handle, '<', $file_name);
-   binmode($file_handle);
-    while(sysread($file_handle, $_, $block_size)) {
-      $crc32_digest = crc32($_, $crc32_digest);
-    }
-    close($file_handle);
-  }
-  return ($return_code, sprintf('%08X', $crc32_digest));
-}
-
-foreach (@ARGV) {
-  my $file_name = $_;
-  my @crc32 = get_file_crc32($file_name);
-  printf("%s %s", $file_name, $crc32[1]);
-  if ($crc32[0] > 0) {
-    printf(" [ERR%02d]", $crc32[0]);
-  }
-  printf("\n");
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bin/cek.py	Sat Jul 09 15:34:55 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))
--- a/bin/putcrc	Mon Jun 27 21:33:08 2011 +0700
+++ b/bin/putcrc	Sat Jul 09 15:34:55 2011 +0700
@@ -24,7 +24,7 @@
 		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.rb "$(safe_path "${file}")" | tail -1 | sed -e 's/.*\([A-F0-9]\{8\}\)$/\1/')
+		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"
--- a/bin/ren	Mon Jun 27 21:33:08 2011 +0700
+++ b/bin/ren	Sat Jul 09 15:34:55 2011 +0700
@@ -18,6 +18,7 @@
   $newname =~ s/\[DVD\]\[AHQ\]/[AHQ][DVD]/;
   $newname =~ s/\[subdesu\]/[SubDesu]/i;
   $newname =~ s/ Zettai Shougeki - Platonic Heart / Zettai Shougeki /i;
+  $newname =~ s/ A-Channel / A Channel /i;
   $newname =~ s/^mars daybreak /[V-A] Mars Daybreak - /;
   $newname =~ s/ Shuffle! Episode / Shuffle! /;
   $newname =~ s/^\[ZA\]\.Saint\.Seiya\.Episode\.(\d+)\.DVDrip\.\[X264\.AAC\(Jpn-Fre\)\.Sub\(Fre-Eng\)\.Chap\]\.mkv$/[D-YFI] Saint Seiya - $1 [DVD].mkv/;
--- a/tcsh	Mon Jun 27 21:33:08 2011 +0700
+++ b/tcsh	Sat Jul 09 15:34:55 2011 +0700
@@ -97,3 +97,5 @@
 ( 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"