php: Log Library Java: Get PID perl: id3 tag snippets

code snippets

 

[Bash] Dateien umbenennen

for f in *; do mv "$f" "`echo \"$f\" |sed -e 's/_/ /g'`"; done

[Oracle] EXPLAIN

set timing on set autotrace traceonly explain select ...

[Java] Hash MD5 SHA

import java.io.UnsupportedEncodingException; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; /** * encrypt the Passwort with SHA * @param pass * @return hash */ public String getPasswordHash(String pass) { try { byte[] bytes = pass.getBytes("8859_1"); /* replace SHA with MD5 */ MessageDigest md = MessageDigest.getInstance("SHA"); md.update(bytes); bytes = md.digest(); String hexHash = ""; for ( int i = 0; i < bytes.length; i++ ) { hexHash += byte2hex( bytes[i] ); } return hexHash; } catch (NoSuchAlgorithmException e) { e.printStackTrace(); return ""; } catch (UnsupportedEncodingException e) { e.printStackTrace(); return ""; } } /** * * @param byte * @return hex */ public String byte2hex( final byte b ) { final char codes[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'}; final char[] array = {codes[(b >> 4) & 0x0f], codes[b & 0x0f]}; return (new String( array )); }

[Perl] Commandline Arguments

foreach my $x (@ARGV) { if ($x =~ /^--help$/) { print $helptext;exit; } elsif ($x =~ /^--prefix=(.+)$/) { $prefix = $1; } else { # this is the directory $file = $x; } }