Blog xaie

Stupid Debian Kernel

5 Juli 2009 · Tinggalkan sebuah Komentar

I freaked out when my server computer didn’t boot to my new Debian install. I guess something about this generic kernel just ain’t right; I mean at least on this computer, because somehow it ran just fine on VirtualBox.

For a quick hack I tried booting from some live cd (I think it was a Slax) so at least I can mount it and get an older kernel from my other computer, extract the old 2.6.22-generic kernel from backup archive (that was coming from an Ubuntu 7.04 partition, because that’s my only kernel backup) and get that damned grub to play nicely by setting it to default. Why? Because I’m using an old CRT monitor, so old that I can’t see anything before 3 to 5 minutes after the first time i press power-on button or reset; I know.. I know it’s time to get a new one;).

Now at least I can get online from LAN-sharing because I can’t get Huawei E220 to work yet. Something that was as trivial as ‘wvdial MyNetProfile &’ have to wait because I know that I have to get/compile a better kernel. So, yeah busy. But the bright side of this whole situation is nothing of value deleted from this install …….. yet (O’ UNIX gods, please guide my fingers).

Aaaarrrggghhh!!!!

→ Leave a CommentKategori: Orang bego punya kegiatan
Tagged: , ,

updateln.py

18 Juni 2009 · Tinggalkan sebuah Komentar

A Python script to update links under a path to use new prefix.


#!/usr/bin/env python
# -*- coding: utf-8 -*-

import os, sys, getopt;
options = {'start': None, 'oprefix': None, 'nprefix': None, 'simulate': True};

class PathError (Exception):
  pass;

def ShowUsage():
  progname = os.path.split(sys.argv[0])[1];
  print progname;
  print '-'*len(progname)
  print " Usage: %s [-w] [-s startpath] -o oldprefix -n newprefix\n" % progname;
  print " Parameters: "
  print " -w, --write       Dont run the program run in simulation mode.\n";
  print " -s, --start-path  Use custom starting directory.\n";
  print " -o, --old-prefix  Find link(s) with prefix as specified by this parameter.\n";
  print " -n, --new-prefix  New prefix for the offending link(s) to use.\n";
####  

def GetOptions():
  global options;
  ret = 0;

  arguments = sys.argv[1:];

  try:
    wnt, dummy = getopt.getopt(arguments, "o:n:s:w", ["old-prefix=",
                    "new-prefix=", "start-path=", "write"]);
    for name, val in wnt:
      if name in ('-o', '--old-prefix'):
        options['oprefix'] = val;
      elif name in ('-n', '--new-prefix'):
        options['nprefix'] = val;
      elif name in ('-s', '--start-path'):
        options['start'] = val;
      elif name in ('-w', '--write'):
        options['simulate'] = False;
    ##

    if options['start'] == None:
      options['start'] = os.getcwd();
  except getopt.GetoptError:
    ret = -1;
  ##

  if (options['oprefix'] == None) or (options['nprefix'] == None): ret = -1;
  if ret != -1:
    print "Start      : %s" % options['start'];
    print "Old prefix : %s" % options['oprefix'];
    print "New prefix : %s" % options['nprefix'];
    if options['simulate'] == False:  print "WARNING    : This program may change links.";
    print;
  ##

  return ret;
####

def ProcessPath(curPath, recursive):
  proccount = 0;
  files = os.listdir(curPath);

  if len(files) > 0:
    print "Examining %s" % curPath;

  for entry in files:
    curFile = os.path.join(curPath, entry);

    if os.path.islink(curFile):
      linkPath = os.readlink(curFile);
      if linkPath.find(options['oprefix']) == 0:
        # we need to update this one
        newLinkPath = linkPath.replace(options['oprefix'], options['nprefix'],
                                      1);
        print "Fixing %s\n   Old path: %s\n   New path: %s" % (curFile,
          linkPath, newLinkPath);

        if options['simulate'] == False:
          # these two lines will modify/regenerate the symbolic link
          os.unlink(curFile);
          os.symlink(newLinkPath, curFile);
          proccount += 1;
        ##
      else:
        # good link, skip it
        pass;
    elif os.path.isdir( curFile ) and recursive:
      proccount += ProcessPath(curFile, recursive);
  ##    

  return proccount;
####

def main():
    if GetOptions() == 0:
      i = ProcessPath(options['start'], True);
      print;
      print ["Nothing processed by this program", \
             "There are %s link(s) processed" % i][i > 0] + '.';
    else:
      ShowUsage();
####

if __name__ == '__main__':
    main();
##

→ Leave a CommentKategori: Ilmu
Tagged: , , ,

ssh_mp32ogg.sh

17 Juni 2009 · Tinggalkan sebuah Komentar

‘cos those MP3 wont convert by themselves.


#!/bin/sh

# -----------------------------------------------------------------------------
# It is a simple script to convert mp3 files (one at a time) to ogg on my
# other computer, because that's where the LAME codec is installed.
# Last edit: 5 June 2009
#
# It requires sox (with LAME installed) on the other computer.
#
# Usage: ssh_mp32ogg.sh [-s SERVER] [-u USERNAME] [-r BITRATE] infile outfile
# -----------------------------------------------------------------------------

mp3_fn=;
out_fn=;
server="CHIKUZA.KRYIE";	# default server
server_usr="ariel"	# default user @ server, must be exists
out_rate=4	# output bitrate to ~ 128

for cur_arg in "$@" ; do
  if [ -z "$mp3_fn" ] && [ -f "$cur_arg" ] ; then
    mp3_fn="$cur_arg";
    echo "Input file is $mp3_fn";
  elif [ -z "$out_fn" ] && [ ! -z "$mp3_fn" ] ; then
    out_fn="$cur_arg";
    echo "Output file is $out_fn";
  fi
done

while getopts s:u:r: OPTION; do
  case "$OPTION" in
	s)	shift `echo "$OPTIND -1" | bc`;
		server="$OPTARG";
		;;
	u)	shift `echo "$OPTIND -1" | bc`;
		server_usr="$OPTARG";
		;;
	r)	shift `echo "$OPTIND -1" | bc`;
		out_rate=`echo "$OPTARG / 32" | bc`;
		;;
  esac
done

# do the format conversion
cat "$1" | ssh $server_usr@$server "sox -S -t mp3 - -C $out_rate -t ogg -" > "$2"

→ Leave a CommentKategori: Ilmu · Orang bego punya kegiatan
Tagged: , , ,

Holy crackamoley Batman! I just know how to use escape keys in OpenSSH!

22 Mei 2009 · Tinggalkan sebuah Komentar

Few minutes ago I just found out that I can actually send SSH session into background by suspending it. From now on I can use one terminal for everything I need.

How is it done? That sneaky escape_char is the key. A quick glance at the ssh manual should explain you all about it, but I found it hard to practice; I just can’t understand what “The escape character is only recognized at the beginning of a line” is supposed to mean.

I mean I know that sentence in English, duh, but what the heck is this “at the beginning of a line” is all about? Are we talking about the shell prompt here or what, Vim? I recall that every time I send a command it occupy its own line, is this a trick to confuse newbie? Even though I know that you CAN type multiple-line commands, but that is not what I’m concerned about.

I tried to type ‘~?’ literally, but that didn’t work. As I just found out (by bashing my keyboard like a space chimps) “the beginning of a line” mentioned here is to put empty command before entering ~. So all I have to do in my terminal is this:

$ < press Return / Enter >
$ < just press key combination to '~', which in my case Shift + ` >

It will be easier that way especially because I’m accustomed to reuse commands from history, walking through the command each character/word at a time, or plain-ol’ Ctrl + C.

For practice purpose I recommend you to try the ~? command. It will print the other available commands, lookup the manual to find out more.

All this time… can you imagine that??

→ Leave a CommentKategori: Ilmu · Orang bego punya kegiatan
Tagged: , ,

kidsxp_ico2png.py

21 Mei 2009 · Tinggalkan sebuah Komentar

Because I got ICO files and I want them in PNG.


#!/usr/bin/env python
# -*- coding: utf-8 -*-

import os, glob

# location of the files
sourceDir = "/media/yamazaki/Work/Pictures/Icons/KidsXP/"
# output directory
targetDir = "/tmp/kidsxp_png/"
# the real processor of this script: imagemagick
convertCmd = "convert %s[9] -resize %s %s"
# which categories to process? all of 'em?
processDirs = ("actions", "apps", "devices", "filesystems", "mimetypes")
# extract it and move into known usable sizes
knownSizes = ('16x16', '22x22', '32x32', '48x48', '64x64', '96x96', '128x128')

def processDir(path, thissize):
  print "Processing source path : %s" % path
  dummy, category = os.path.split(path)

  for item in glob.glob(path + '/*.ico'):
    dummy, itemName = os.path.split(item)
    tgtDir = os.path.join(targetDir, thissize, category, '')
    tgtName = itemName[:-3] + 'png' # "xyz.ico" filename to "xyz.png"

    print "Writing %20s -> %s" % (itemName, tgtDir + tgtName)
    if not os.path.exists(tgtDir):
      os.makedirs(tgtDir)

    cmd = convertCmd % (item, thissize, tgtDir + tgtName)

    # execute
    os.system(cmd)  # ooh! the horror!!
  ##
  print
##

for item in processDirs:
  s = sourceDir + item
  if os.path.isdir(s):
    for size in knownSizes:
      processDir(s, size)
  else:
    print "Skipping %s" % (s)
##

→ Leave a CommentKategori: Ilmu
Tagged: , , , ,

Jokes, because I’m bored to death!

12 April 2009 · Tinggalkan sebuah Komentar

  • If you put a million monkeys at a million keyboards, one of them will eventually write a Java program.
    The rest of them will write Perl programs.
  • Once upon a time there was a shepherd looking after his sheep on the side of a deserted road. Suddenly a brand new Porsche screeches to a halt. The driver, a man dressed in an Armani suit, Cerutti shoes, Ray-Ban sunglasses, TAG-Heuer wrist-watch, and a Versace tie, gets out and asks the Shepherd:

    Man: “If I can tell you how many sheep you have, will you give me one of them?”

    The shepherd looks at the young man, and then looks at the large flock of grazing sheep and replies:

    Shepherd: “Okay.”

    The young man parks the car, connects his laptop to the mobile-fax, enters a NASA Webster, scans the ground using his GPS, opens a database and 60 Excel tables filled with logarithms and pivot tables, then prints out a 150 page report on his high-tech mini-printer. He turns to the shepherd and says,

    Man: “You have exactly 1,586 sheep here.”

    The shepherd cheers,

    Shepherd: “That’s correct, you can have your sheep.”

    The young man makes his pick and puts it in the back of his Porsche. The shepherd looks at him and asks,

    Shepherd: “If I guess your profession, will you return my animal to me?”

    The young man answers;

    Man: “Yes, why not?”

    Shepherd: “You are an IT consultant.”

    Man: “How did you know?”

    Shepherd: “Very simple. First, you came here without being called. Second, you charged me a fee to tell me something I already knew, and third, you don’t understand anything about my business…Now can I have my DOG back?”

  • C++ – Where your friends have access to your private parts.
  • A pessimistic programmer sees the array as half empty.
    An optimistic programmer sees the array as half full.
    A real programmer sees the array as twice as big as it needs to be and calls realloc().
  • Computers are high-speed idiots, programmed by low-speed idiots.
  • There were three engineers in a car; an electrical engineer, a chemical engineer, and a Microsoft engineer.
    Suddenly, the car stops running and they pull off to the side of the road wondering what could be wrong.
    The electrical engineer suggests stripping down the electronics of the car and trying to trace where a fault may have occurred.
    The chemical engineer, not knowing much about cars, suggests maybe the fuel is becoming emulsified and getting blocked somewhere.
    The Microsoft engineer, not knowing much about anything, came up with a suggestion. “Why don’t we close all the windows, get out, get back in, and open all the windows and see if it works?”
  • The programmer to his son: “Here, I brought you a new basketball.”

    Son: “Thank you, daddy, but where is the user’s guide?”

  • Once a programmer drowned in the sea. Many Marines where at that time on the beach, but the programmer was shouting “F1 F1″ and nobody understood it.
  • Q: How do you keep a programmer in the shower all day?
    A: Give him a bottle of shampoo which says “lather, rinse, repeat.”
  • An inscription on the gravestone of a programmer reads:

    General protection fault – 10.10.61

    Runtime error – 23.09.1998

  • .NET is called .NET so that it wouldn’t show up in a Unix directory listing.
  • CD-ROM: Consumer Device, Rendered Obsolete in Months
    PCMCIA: People Can’t Memorize Computer Industry Acronyms
    ISDN: It Still Does Nothing
    SCSI: System Can’t See It
    MIPS: Meaningless Indication of Processor Speed
    DOS: Defunct Operating System
    WINDOWS: Will Install Needless Data On Whole System
    OS/2: Obsolete Soon, Too
    PnP: Plug and Pray
    APPLE: Arrogance Produces Profit-Losing Entity
    IBM: I Blame Microsoft
    MICROSOFT: Most Intelligent Customers Realize Our Software Only Fools Teenagers
    COBOL: Completely Obsolete Business Oriented Language
    LISP: Lots of Insipid and Stupid Parentheses
    MACINTOSH: Most Applications Crash; If Not, The Operating System Hangs
    AAAAA: American Association Against Acronym Abuse.
    WYSIWYMGIYRRLAAGW: What You See Is What You Might Get If You’re Really Really Lucky And All Goes Well.

→ Leave a CommentKategori: Uncategorized

Facebook sekarat? Yay!!

29 Maret 2009 · 3 Komentar

tee..hee..hee..Setelah sekian banyak website social networking yang “menjangkiti” Indonesia, dimana yang terbaru adalah Facebook (FB). Dengan banyaknya orang sekeliling gw yang mulai “main” FB gw bisa konfirmasikan bahwa Facebook punya basis pengguna yang cukup lumayan di Indonesia.

Kesan yang gw dapatkan dalam dua tahun terakhir adalah Facebook “lebih trendy” dan “gaul” daripada website-website sebelumnya seperti Multiply, Friendster, dan sebagainya. Kalau orang yang pintar bisa lebih kritis karena “trendy” dan “gaul” (yang disini berupa kata sifat) sangat subjektif dan tidak menjelaskan banyak hal; selain populer. Kesimpulan sementara yang bisa gw ambil: dasar latah.

Anyway, kemarin gw baca berita bahwa FB memiliki kesulitan finansial karena cost yang di-anggarkan untuk tiap user –dengan jumlah user sekarang ini yang sangat banyak– menyebabkan masalah serius dalam bisnis mereka. Nampaknya antara pemasukan dan pengeluaran mereka sudah njomplang sebelah gitu.

Untuk sementara gw sedang tertawa dalam hati seperti kucing dalam post ini. Pendapat pribadi gw? Biarin aja mati, gw mau lihat orang-orang yang keranjingan FB merana selama beberapa minggu. Emangnya tiap hari gak bisa hidup kalau tidak sentuh FB?

Kalo gw sendiri sih gak punya soalnya ogah!

→ 3 CommentsKategori: Pendapat gak penting
Tagged:

PulseAudio on Kubuntu 8.10

24 Maret 2009 · Tinggalkan sebuah Komentar

This part was supposed to be a part of A Few Days In KDE 4 post, but I think it deserves its own post.

First of all, when I played with my new Kubuntu I realized that I forgot to backup PulseAudio settings. Damn. Anyway, this might be a good read for everybody else trying to get PulseAudio working, which I did in 20 minutes or so (most of the times spent downloading PulseAudio and everything else needed to make it work) to get my previous setup.

For a starter, I have to enable ALSA to use PulseAudio output, so I typed this into ~/.asoundrc:


pcm.pulse {
  type  pulse
}

ctl.pulse {
  type  pulse
}

This should enable PulseAudio audio playback on ALSA (the one I’m using right now and in the past).

Next I have to (re)configure PulseAudio server in this computer, just create another file at ~/.pulse/default.pa and put this in it:


load-module module-alsa-sink
load-module module-native-protocol-tcp auth-ip-acl=127.0.0.1;192.168.0.0/24

The first line should load the ALSA module to make PulseAudio use ALSA. The next one is to use native TCP protocol nothing fancy really, with a restriction on clients able to ’send’ their sound to this computer. In this case I’m accepting sound from my local LAN (machines starting with “192.168″ on their IP) and localhost (127.0.0.1); of course with extra precaution put on my firewall to block all entrance using PulseAudio port through unwanted network interfaces.

I tried to start PulseAudio for the first time by typing pulseaudio on the console. Right now not only that I know my settings working but I also got ~/.pulse-cookie created by PulseAudio. This is important because this is the cookie that allow the client computer, the one that provides playback, the one with MPD playing my songs, to connect to this computer. This is like public key in SSH, if you know what I’m talking about. Anyway what I have to do is to copy it to the remote machine to make PulseAudio authentication work; scp to the rescue!

At this stage PulseAudio should run as your everyday program, while what I want is to start as a daemon. So to make PulseAudio start as a background program, I created another file called ~/.pulse/daemon.conf and put this in it, a self-explanatory line:


daemonize=yes

After that when I started pulseaudio it works in the background, perfect. Now I can listen to music like I did before :D .

→ Leave a CommentKategori: Ilmu
Tagged: , ,

A Few Days In KDE 4

18 Maret 2009 · Tinggalkan sebuah Komentar

I managed to install KDE 4 since the last post, it was not so hard but of course not without quirks. As I managed to post this thing on my new install of 8.10, been trying it for a few days, adjusting to new concepts and UI, etc. I can say that I’m disappointed with the new KDE, I prefer KDE 3.5 but I’ll survive this one; no.. and I still like this one over Gnome.

Getting Ready

First of all the installation process itself was not right after the ISO download. Before logging off I created a backup of my home directory, a simple tar command followed by scp took 4 ~ 5 minutes to backup everything to a safe place before restarting the box.

As a personal custom before installing new OS, I usually start the whole thing with diagnostic process, starting with defragging my XP installations (both of them), with mandatory scandisk on each system just to be safe, all took me 2 ~ 3 hours (slow, I know.. :) ). After I’m satisfied with my hard disk condition I rebooted to Kubuntu to copy the ISO file to my server box, which in turn will host my HTTP-based installation but a quick glance at my CDs pile found me a nice yet unused CD-RW, so I scratch that idea away. I thought a CD installation is better anyway because I might want to install this one on another machine. Burning the ISO image took 20 ~ 30 minutes including verification, of course I test the CD by mounting and browsing it for a while before logging off, yet again.

I restarted the box, alter the BIOS boot sequence and after a few seconds presented with the language selection menu only to be followed by the Live-CD boot menu. I added nofstab to the end of Live-CD boot parameters because I don’t want it to mount my filesystems because I want to resize my previous Linux installation to a comfortable 5 GB (from 3 GB :D ).

My First KDE 4 Experience

The new interface looked great, I enjoyed it for 5 minutes or so before I experienced my first KDE 4 crash notification; not good. The screen flickers, oh God, what can I say.. almost drive me nuts. I noticed my network already up (God bless the dude who invented DHCP), I login to my server box, get myself online and search the Google how to kill fix this. Either my Google-fu was strong that day or it was a common problem I don’t know, I found a solution to kill the ‘Detecting RANDR changes’ service in a minute (which is a good thing because the next minute I might gone postal).

Making Rooms

I started the install process, a nice one I might add. It detected my hard disk layout right away, and of course I chose manual partitioning. The interface reminds me to Partition Magic, somehow for a few seconds I hesitated to delete my Linux install although I know I did backup everything: documents, logs, home directory, including deb packages.

Anyway after a few seconds of self-cursing I deleted my old Linux partition, and resize the previous partition to make room for a larger ‘unallocated’ partition. I reformat the new and larger partition as ext3, and set its mount point to ‘/’ before moving forward. After a few minutes, formatting file system was a success and I have to accept that my old Linux partition is gone, with everything that I forgot to backup; if any.

Post Installation

The installation took, roughly, 30 minutes for me without any problem along the process. Nice. After a disturbing startup sound getting cut-off after a few seconds (I know this is not supposed to be like this, not that I’ve installed it on my harddisk) I played around with KDE 4. Nice interface and all, but I do miss things from KDE 3.5 though.

After get bored with playing around on the interface (all those shininess only lasts for a few hours) I have to restore any important settings from my previous setup, things such as SSH known hosts, a few tiny python scripts to get things going, and a plethora of articles, books, and saved pages to finish since I don’t have the time to read them all, yet.

→ Leave a CommentKategori: Orang bego punya kegiatan
Tagged: ,

Lo, Intrepid Ibex is coming

7 Maret 2009 · Tinggalkan sebuah Komentar

It would be a couple of minutes now, to finish my download of Kubuntu Intrepid Ibex. Yeah really, I embraced the idea to download Ubuntu, something was unthinkable on my previous dial up connection. Nice to see someone spend their monthly quota on something other than stupid Youtube video streams, right?

I’m using Kubuntu Gutsy Gibbon and the idea got into me after I drool over a few KDE 4 screenshots. The decision was not without doubt, however, I put quite a few days before hitting that download link yesterday. I know there are several issues on KDE 4, both on usability front and stability wise with the later more weighs more important to me.

Well, its done now. I shall march forward to the sweat, blood, and tears after a fresh install!! (and prospective self-loathing why I did this in the first place). This might my last time posting this using my trusted Kubuntu 7.10.

→ Leave a CommentKategori: Uncategorized