Skip to main content

Posts

Showing posts from October, 2009

Locking a file in Java

Locking a file in Java is platform dependent. Write once run anywhere? Thumbs down. Some platforms will not allow a file access without a lock while others will. This is very useful especially when writing your own database (I know some people will argue but this is still happening in corporations handling very sensitive data). It starts with a simple file access. try { final File file = new File("Tables.dat"); final FileChannel fileChannel = new RandomAccessFile(file, "rw").getChannel(); // this method will block until a lock is acquired final FileLock lock =fileChannel.lock(); // this method will not block, it will return null or throw an exception lock = fileChannel.tryLock(); // TODO: do something with the file // release the lock lock.release(); // cleanup / close file fileChannel.close(); } catch (Exception e) { // TODO: handle exception } Caution: You really need to verify how the target platform...

Earth planner - Architect Felino Palafox Jr. (Manila Bulletin)

Earth planner Architect Felino Palafox, Jr. October 17, 2009, 8:49am THE MMetroplan is to Felino Palafox Jr. as the ark is to Noah. Through the plan and the ark, respectively, both forewarned their people of destruction to come their way if they didn’t mend their ways. Unfortunately, both were not heeded - and we all know what happened thereafter. “It was not an act of God. The devastation caused by Typhoon Ondoy could have been averted if humans only listened,’’ firmly believes world-renowned Filipino architect Palafox. Palafox, of course, completely knows what he was talking about. More than 30 years ago, in 1977, he came out with the Metro Manila Transport, Land Use and Development Planning project, a World Bank-funded report that aimed to protect Metro Manila from further flooding. In this report, recommendations were made for transportation, land use, zoning, and flood control, particularly in the eastern part of the metropolis, specifically in – you guessed it – Marikin...

vrms - Virtual Richard M. Stallman

Though I am aware that there are non-free packages lurking in my box, I want to be precise, thanks to Virtual Richard M. Stallman . Non-free packages installed on linux-conqueror fglrx-modaliases Identifiers supported by the ATI graphics driver linux-generic Complete Generic Linux kernel linux-restricted-modules- Non-free Linux 2.6.28 modules helper script linux-restricted-modules- Restricted Linux modules for generic kernels nvidia-173-kernel-source NVIDIA binary kernel module source nvidia-173-modaliases Modaliases for the NVIDIA binary X.Org driver nvidia-180-modaliases Modaliases for the NVIDIA binary X.Org driver nvidia-71-modaliases Modaliases for the NVIDIA binary X.Org driver nvidia-96-modaliases Modaliases for the NVIDIA binary X.Org driver nvidia-glx-173 NVIDIA binary Xorg driver skype Skype - Take a deep breath tangerine-icon-theme Tangerine Icon theme virtualbox-3.0 Sun Virt...

Linus’ discussion about goto statements

As discussed by Linus Torvalds 6 years ago, From: Linus Torvalds Subject: Re: any chance of 2.6.0-test*? Date: Sun, 12 Jan 2003 12:22:26 -0800 (PST) On Sun, 12 Jan 2003, Rob Wilkens wrote: > > However, I have always been taught, and have always believed that > “goto”s are inherently evil. They are the creators of spaghetti code No, you’ve been brainwashed by CS people who thought that Niklaus Wirth actually knew what he was talking about. He didn’t. He doesn’t have a frigging clue. > (you start reading through the code to understand it (months or years > after its written), and suddenly you jump to somewhere totally > unrelated, and then jump somewhere else backwards, and it all gets ugly > quickly). This makes later debugging of code total hell. Any if-statement is a goto. As are all structured loops. And sometimes structure is good. When it’s good, you should use it. And sometimes structure is _bad_, and gets into the way, and usi...