Friday, December 12, 2008

Inama Nushif

Unfortunately, my entire Linux continuum is going to shut down for a while, as i have just lost my laptop to a backpack snacher yesterday.

As I am sitting here, thinking about my unfortunate event. I don't really know what to feel like. I do blame myself, but to how long can you hold your alert senses? you can't be invincible forever, no one can. everyone is bound to have openings at some point. Not having my new laptop feels a bit like giving up smoking for me. i just needed that speed that my old Mac can't really provide by now.

and i'm also confused about what i really want at this point, to say no to "smoking", or to get myself a new laptop, in which i could also get stolen. and i don't really know what brand to choose either, and my reason of having a new laptop is being challenged too, why do i really need a new one?

... i think i'm just gona lay low, and ponder for sometime about this... i need some time... to reborn

Saturday, November 15, 2008

Java Hack: creating multiple classes within one file

I know there are plenty of people out there that don't really like java, and also plenty that do. Those that do says Java is easier to program, but the most good point is that java compilers/interpreters must follow a very strict rule of implementation, such that java code can run on any machine without a problem. now that sounds good, but Java is also a very strict programming langauge, and one the things that I have been having some problem with is they don't allow you to create multiple classes within one file, thinking that by having each file a separate class, everything looks more clear. While that is true, it also become a pain in the ass when you're dealing with a huge program with thousands of classes, which implies thousands of files, and each single one of them are listed in your Package Explorer, and some of them are so small you wonder why they have to be listed as a single file at all. so i figured out a trick to convert multiple classes in java into one file, breaking that rule.

the idea of putting multiple classes inside one is to convert a java class into what C++ refers to as a namespace, a live package that has both static and instance of itself, and putting all the other classes you want to conceal into the file as private member classes of the "namespace". This is the key idea of how to break from the one file one class rule. here is the procedure:

1. copy/create a private class inside your "namespace" class
2. write a public class generator function for each private class that is in the namespace class. the generator function will take all the arguments for the constructor and pass it to the private class constructor. it returns the instance once it is generated
3. create a public singleton instance of the namespace class. note that static instance does not work here.

and wala! now whenever you want to create a new class that is declared in the namespace class, just call the singleton instance and its generator function. and my friends, you have just turned a java class into a C++ namespace

Friday, September 26, 2008

5 searching commands in linux

1. find

2. locate
-uses a database of file location instead of searching the real location, the database only updated everyday

3. whereis [-bsm]
- returns the location for a specific command line command, -b gives the location of the binary, -s gives the location of the source, and -m gives the location of the man pages

4. which
- returns all the location for the specific command. it searches the PATH env variable for locating the binary. great if there are multiple versions of a command in PATH.
- it returns the full path for each version of the command

5. type [-a]
- returns the type of command this console is using for the default, could be a shell built in, a UNIX command, a linux command etc. -a gives this property for all commands that are with the same name

Sunday, September 14, 2008

Cloud Computing Digest

Cloud Computing is a fairly new internet service structure. it provide ways to virtually map physical storage, internet access together with a web based application for a remote user. The advantage of cloud computing is the reduction in the amount of server and energy needed to run a large scale service.
the idea of cloud computing resides in thinking of whole bunch of servers running for different services as a cloud, instead of independently running machines. It virtuallizes all physical machines into several layers: infrastructure service layer, platform service layer, and software service layer.

infrastructure service layer manages web throughput and storage space for remote server, giving each remote client a fixed network power and storage space without having all those service being tied down to one service machine. it also provide ways to run a operating platform on top of the infrastructure layer, limiting the storage and service to specific platforms that uses it.

the platform service layer provide users a selection of applications they could use. an example of platform service is the google application engine

the software service layer contains web applications the user may use, one example would be Google Apps.

information digested from here

Monday, September 8, 2008

some more UNIX tips

1. auto-complete features in all shells:

bash: TAB or double TAB
cash: escape
korn: escape \ or double escape (depends on EDITOR var setting, either vi or emacs)

2. accessing previous command arguments from shell
$! access the last argument of the last command entry
!:1 or another number can access the last command argument at the position starting from 1

3. pushd and popd creates a stack of file locations that can be accessed without using cd command. it can also manipulate the stack, rotating its order with +i or -i where i is the rotation number to rotate, + puts the frontmost to the back, - puts the backmost to the front

4. curl command can be used to retrieve web information, use -s to ignore processing output, use -o to download any file from the internet

5. name matching special characters:
^ -> matching anything to the starting of line as in ^A
? -> matching anything at the end of the line A?
[] -> matching any character within the bracket, use - for indicating range
[^]-> matching any character except for those within the bracket
. -> match a single character of any value except for EOF
* -> match 0 or more preceding characters to expression
\{x,y\} -> match to x to y occurence of the preceding
\{x\} -> match to exactly x occurence of the preceding
\{x,\} -> match to x or more occurence of the preceding

6. some awk example (more examples)

$ cat text
testing the awk command
$ awk '{ i = length($0); print i }' text
23
$ awk '{ i = index($0,”ing”); print i}' text
5
$ awk 'BEGIN { i = 1 } { n = split($0,a," "); while (i <= n) {print a[i]; i++;} }' text

(summarized from here)

Wednesday, September 3, 2008

Google Chrome, so much faster and so much more simple to use

it looks like google's new browser: Chrome is so 5 times faster than firefox and other browsers in general. it is also very small and very simple to use.

you may download it here

Thursday, August 28, 2008

another good reminder that lots of fun google search techniques are here

1. "define:" gives you the meaning of all words you write afterwards
2. "time" gives you the time of location
3. google search can be used as calculator with equation and end with '='
4. currency conversion by in
5. get the map of a city by map
6. get related search results using the "related:" keyword
7. use + and - in search term to plus a meaning or minus a meaning to the search term
8. type in a 3 digit and get the area where the 3 digit is used as phone number initial
9. quote search terms to get the exact result you want