Sunday, July 6, 2008

[News] My Latest Java

I wrote my first Java program today.
Besides the fact that it's Java, it rocks.

package vk_root;

import java.io.InputStreamReader;
import java.io.BufferedReader;

/*
* This program can find the root of any positive real integer
* at any given (positive real) base.
* It's my first Java program, so please don't laugh at the lameness
* of the code.
*
* raise will *raise* an integer to a given power.
* root will return 0 on failure.
* disp is there because typing out System.out.println() sucks.
* pass makes me (a Python-er) feel at home here.
* stupid is helpful.
* shell interacts with the user.
* main is straight-forward.
*
* This program is command-line aware, e.g;
* $ java -jar vk_java_app.jar 16 2
* 4
* $
*
* I have to stick this in;
* #!/usr/bin/env python
* def root(num, base):
for x in range(2, num/base+1):
if x**base == num:
return x
* >>> root(16, 2)
* 4
*
* *sigh*
*/

public class Main {
public static int raise (int num, int base) {
int copy = num;
for (int pos=1; pos!=base; pos++) {
num = copy*num;
}
return num;
}
public static int root (int num, int base) {
int cap = num/base+1;
int[] range = new int[cap];
for (int start=0; start<=(num/base); start++) {
range[start] = start;
}
for (int pos=0; pos
if (raise(range[pos], base) == num) {
return range[pos];
}
}
return 0;
}
public static void disp(int msg) {
System.out.println(msg);
}
public static int pass() {
return 0;
}
public static void stupid() {
System.out.println("Stop being a dummy.");
}
public static int shell() {
InputStreamReader isr = new InputStreamReader( System.in );
BufferedReader stdin = new BufferedReader( isr );
try {
System.out.println("Enter a number: ");
String in_num = stdin.readLine();
if (in_num.equals("exit")) {
return 1;
}
System.out.println("Enter a base: ");
String in_base = stdin.readLine();
if (in_base.equals("exit")) {
return 1;
}
System.out.println("The root:");
disp(root(Integer.parseInt(in_num), Integer.parseInt(in_base)));
}
catch (java.io.IOException e) {
stupid();
return 0;
}
catch (java.lang.NumberFormatException e) {
stupid();
return 0;
}
catch (java.lang.NegativeArraySizeException e) {
stupid();
return 0;
}
return 0;
}
public static void main(String[] args) {
/*
disp(root(16, 2));
disp(root(49, 2));
disp(root(1000, 3));
disp(root(16,4));
disp(root(625, 5));
*/
try {
disp(root(Integer.parseInt(args[0]), Integer.parseInt(args[1])));
if (args[2].equals("quiet")) {
// UGLY!!!
System.exit(0);
}
} catch (java.lang.ArrayIndexOutOfBoundsException e) {
// System.out.println(e);
pass();
}
System.out.println("(Type exit at any time to stop the application.)");
for (;;) {
if (shell() != 0) {
break;
}
}
}
}

Wednesday, June 18, 2008

[Internet] Opera Wins III

Webmonkey speed test;



This makes Opera, what, almost 4 times faster? Meh. I'll edit and post sunspider next.

Sunday, June 15, 2008

[Programming] Java.

Those of you that know me have undoubtedly heard my bitching about Java. Well, I am going to try and present a un-biased comparison between Java and other languages in relation to functionality. Yes - Rodney, this will be interesting.

[*] Ease of Coding:
> The Winner: Python
Many complain that Python syntax is too lax and that 'a variable can be ANYTHING!!!'.
Well, that's a good thing.
> Why Java Sucks at This:
Java syntax is pretty C-like, and I hate the verbosity. I do prefer Java syntax over Perl's, though Perl is infinitely more useful.

[*] Speed (Execution Time):
> The Winner: C++
I don't even need a valid argument here; if you doubt me, go take your code and write a flawless C++ equivalent. Then bring me profiling results from both projects (or don't, seeing as all I'm going to do is tell you 'I told you so.').
> Why Java Sucks at This:
Unless you can natively run Java bytecode (SPARC comps), then you know that you need a JVM, a JRE, a JDK, an SDK, an IDE, a UML editor, various plugins, lots of time, a high-speed bandwith connection, and lots of patience to get a complete working Java programming environment. I'm talking about 1gb+ of downloads.
After you put up with that crap, your Java code has to compile.
Then, your binary has to call the JVM.
Right before that, the JRE has got to run a trillion checks and prompt you for updates or tell you to by SUN's crap.
Then after the JVM's glacial load time, it will decide whether it feels like interpreting your Java or not.
When it does, it will (very slowly) check your code for errors or deprecated statements.
Then, if it hasn't randomly crashed or had memory leaks or encountered some bizarre error, it will convert the Java bytecode into something your OS can work with. Then, things happen. Slowly.

It can take a noob anywhere up to 4 hours to download & install Java, write a hello world CLI app, and then compile->interpret->and execute it. May I remind you that this can be done in bash with

$ echo "#include iostream.h\n int main(void){std::cout << 'Hello World.\n';}" >> hw.cpp && gcc hw.cpp -O3 -march=native -o hw && chmod 0777 hw && ./hw
#or
$ python -c "print 'Hello World.'"
#or
$ echo 'Hello World'
#or
$ tiemu -mod=83 -BASIC=':ClrHome:DISP "HELLO WORLD."'
#or
$ echo "(printf 'Hello World.')" |xargs mred
#or
$ zenity --info --text "Hello World."
#or
$ brainfuck "++>++++++>+++++<+[>[->+<]<->++++++++++<]>>.<[-]>[-<++>]<----------------. ---------------.+++++.<+++[-<++++++++++>]<.>>+.++++++++++.<<.>>+.------------.---.<<.>>---.+++.++++++++++++++.+.<<+.[-]++++++++++"
?

[*] Least Crappy:
> The Winner: Z80 ASM
No wasted code, fast, efficent (relatively), and powerful.
> Why Java Sucks at This:
Java is full of the essence of SUK.

* I DO expect flame.

[Internet] Opera Wins II.

There have been (in the past, as well as now) comments about Opera's lack of Facebook skillz and image loading issues. Well, suck on this bitches;


This page was loaded very quickly, and it didn't do any of that random 'page shaking' crap Gecko-based browsers (e.g Firefox, Flock) do. Also note that the chat and notification works perfectly, something even the latest firefox3rc sucks at.

Oh, and for you "I like AdBlock too much to switch!" and "Opera doesn't look right!" people, just look at the screenshot. No ads, and definitely a sexier interface than Firefox... Also featuring System Theme integration for Windows AND Linux AND Mac.


---
Yes, I use a Vista theme on XP. As much as I detest all things Microsoft, it makes NO F****** SENSE to press the damn Start button every time you want to shutdown your computer.

Thursday, June 12, 2008

[Other] OWNED! PWNT! LMFAO!








Nuff sed.

[Internet] Opera Wins.

Firefox 3 vs. Opera 9.5? As much as I hate to say this;

Opera WINS. Big time.

This isn't a formal comparison - but let's just consider these things;

* Cold Start Load Time Winner: Opera (by FAR)

* Warm Start Load Time Winner: Opera

* Standards Compliancy Winner: Opera

* Features Winner: Tie!!! Opera lacks features like the cool find and good spellcheck, but firefox is a real resource hog about it.

* Most Likely to be Supported Winner: Firefox (Though YOU can help change that.)

* Cooler Name Winner: Firefox (No contest. Opera is a pretty dumb name, no offense.)

* General Cool Factor Winner: Firefox (Now if Opera goes Open Source and gets a decent ad campaign...)

* Raw Speed Winner: Opera

* CSS/Javascript Speed Winner: Opera (by FAR)

* Page Load Time Winner: Opera

* Innovation/Integration Winner: Opera (it integrates very well with Linux with full static qt and gtk supported binaries - and it has it's own mail and chat and other cool stuff).

Thursday, June 5, 2008

[Other] Obama. Yes.

Obama and Clinton are talking, and to tell you the truth, it's been long overdue.

Well, they have 'spoken' to each other lately, just in a different scope of things (I hope).

In the earlier days, I thought that Ms. Clinton was running a dirty campaign and generally bitching a tad too much, but I realize that in the end - it's helped Obama.

Imagine if all the wonderful BS Clinton pulled out on Obama arose a week before November? Hell for Dems, I'd say.

Let's face it, we know there's going to be a democratic president, and we know now that it's going to Obama.

What we don't know is what the hell he's going to do that will fix partisanship and the remove the murky cloud the 'special interest' groups put over Washington. The rest of the 'issues' would go the same way with either Clinton/Obama I think. Their policies aren't radically different or anything.

If Clinton decides to bitch some more, and NOT run with Obama - the Democrats are going to be divided, weaker, and less likely to get things done!

Proof? Look at Congress. With all of the major talk a while back about the Dems sweeping the houses, we still have plenty of Gridlock, the War is still going on, and our health class [b]still[/b] does not have 1/4 the textbooks it needs (well, not that I'd like to see that one change but still).

Meh. I hope things get fixed.

Friday, May 30, 2008

[Linux] I'm All Arch!

After 3 days of intensive Arch hacking, my Pentium 4 computer with a crappy Intel i810 Graphics Card and 1 GB of RAM is booting in 16 seconds, from GRUB to Compiz Fusion.

This is a vast improvement over Ubuntu (which took 40 seconds to get to GDM, never mind Compiz...)!

I am extremely excited about Arch. It's much faster (not only boot time, but general responsiveness) than your average distro and so far, it's community has proven itself to be far more resourceful, helpful, and encouraging than any other I have seen.

As soon as you post one question on their forums, you get 10 constructive responses in less than 30 minutes! Their wiki is also a great resource, their articles on Xorg and Gnome setup are better than every random howto I've seen combined!

Oh, and there's no doubt - Pacman KILLS apt. You can get from a installation CD to a fullscreen terminal to a complete Desktop Environment in under 30 minutes, mainly because Pacman just rocks. The user repositories and yaourt are pretty awesome too. You know my post about building bleeding compiz code from git? That can be done with this command;

$ yaourt -S compiz-git

Yeah. Yeah. That's kickass.

COME TO THE DARK SIDE!!! WE HAVE PKGBUILDS!!!

Screenshot: Cube
Screenshot: Expo
Screenshot: ArchMenu
Screenshot: Ease Of Arch
Screenshot: GimpIN'
Screenshot: Capless


More to come...

Tuesday, May 27, 2008

[Linux] That's It! I'm going to give Arch a shot.

Yes, I know there are a billion sites that have have distro-quest posts, but this one is about mine, and maybe you'll actually make a decision after reading it ;). Here goes...

I've been with Ubuntu for 11 months now, and I've had my ups and downs.
It was my first Linux distro, and I eventually grew a lot happier with it than I was with XP.

During that time, I gave Suse, Fedora, Zenwalk, and Gentoo a shot to impress me (on a spare partition). I'm sorry to say this, but I came screaming back to Ubuntu. Maybe it was the GNOME/KDE issue, or maybe it was the ridiculous installation processes for these distros - but none of these 'float my boat'. (I recently got Gentoo working, and it's not bad at all - but I just don't have the time to polish it up like I can Ubuntu.)

I have mixed impressions on Zenwalk - even though it is by all definitions an excellent distro, I just can't seem to get used to it. The desktop environment is definitely not as sleek as Ubuntu's, yet the boot process is a good 6 seconds faster... Netpkg (Zenwalk package manager) is sub-standard, but at least the distro isn't as bloated as Suse or (well any KDE distro).

And now, after this (admittedly small) amount of distro-hopping - I've found what looks like my dream distro. Arch Linux. Let me explain myself;

> I have an i686 computer. Whaddya' know, Arch is i686 optimized!
> No offense to the etymology, community, or meaning of Ubuntu, but Arch definitely sounds cooler.
> I have enough Linux background to compile a kernel with just a root shell and an internet conenction - so I can probably handle installing Arch ;).
> What drew me to Gentoo was the intense customization opportunities, but I like Ubuntu because it just works. Arch is a good mix between the two.
> pacman beats apt-get. you can rebuild all packages on your system (from source) if you wish with one command.
> Arch has a very strong, intelligent, and dedicated forums/community (and even 'sub'-communities. These guys love Arch so much that they have ported Arch to other architectures, and there is a special version of KDE fully optimized for Arch).
> Arch has rapidly growing repos.
> Arch forums load faster than Ubuntu's (bad reason, but still)
> Arch is not bloated

The most important reason I think Arch is great is that people are raving about it. From increased speed to usability - lots of people are checking out Arch. I even found a couple threads on distro-specific forums talking about how users are switching to Arch all of the time O_O.

I think I'm going to give Arch a shot, and stick with it. I'll post how it goes later.

Monday, May 26, 2008

[Linux] Bleeding Compiz Fusion From GIT

To put it shortly, it is amazing. This post is cool too, don't miss it!
(HOWTO in it :D.)

Normally, people complain that their compiled code (in most cases, it is a stable kernel) runs at about the same speed as a pre-compiled generic executable.

But in this case, bleeding compiz code runs noticeably faster than the version that ships with Ubuntu 8.04. Not only that, but new features such as cube deformation, atlantis, fish-eye, enhanced water (& animations), and improved snappiness are fantastic.

I was about to post screenshots of my slick new desktop, but I decided to write a HOWTO for you people instead.

Note: I am a Debian/Ubuntu user, so I will post instructions assuming you have apt (Advanced Package Tool) available. I also tend to favor Gnome, so please comment if you have KDE/XFCE or rpm/yum/emerge/pacman/urpmi/w/e questions.
Note #2: [code] [/code] tags indicate that you should copy and paste the text between them into a terminal - and then hit enter. (You really do have to specify, you know?)
Note #3: I also do not assume any responsibility for damages these commands cause, though you are free to cuss me out if they break anything on your comp. This worked for me... BUT IT MIGHT NOT FOR YOU.

------------------ Compiz From GIT HowTo ------------------
Edit: Here is an experimental script I wrote (2:30 A.M) to automate this. Enjoy.
Direct Link

1a. Please update yourself;
[code]
sudo apt-get update && sudo apt-get upgrade
[code]

1b. If you are under Gnome/XFCE, install;
[code]
sudo apt-get install libgconf2-devlibgnome-desktop-dev libgnome-window-settings-dev xorg-dev
[/code]
If you are under KDE, install;
[code]
sudo apt-get install kde-devel kde4-devel
[/code]

2. Now, for everyone, install;
[code]
sudo apt-get install build-essential libxcomposite-dev libpng12-dev libsm-dev libxrandr-dev libxdamage-dev libxinerama-dev libstartup-notification0-dev libgl1-mesa-dev libglu1-mesa-dev libmetacity-dev librsvg2-dev libdbus-1-dev libdbus-glib-1-dev gitweb curl autoconf automake automake1.9 libtool intltool libxslt1-dev xsltproc libwnck-dev python-dev libX11-xcb-dev pyrex-mode python-pyrex x11proto-scrnsaver-dev libxss-dev xorg-dev
[/code]

3. Now, please exit Compiz Fusion ([code]metacity --replace[/code])

4. You will need to uninstall;
[code]
sudo apt-get remove libgnome-compiz-manager0 compiz-extra libcompizconfig0 compiz-dev compiz-gtk compiz-kde compiz-settings libcompizconfig-backend-gconf compiz-config-ini gcompizthemer compiz-plugins libgnome-compiz-manager-dev compizconfig-backend-kde compizconfig-settings-manager python-compizconfig compiz-config-gnome taskbar-compiz compizconfig-plugin compiz-freedesktop-dev compiz-fusion-plugins-unofficial compiz-bcop compiz-ccs-settings-manager libgnome-compiz-manager libcompizconfig0-dev compiztools compizconfig-settings-legacy compiz-fusion-plugins-extra compiz-compcomm-plugins-main compiz-fusion-plugins-unsupported compiz compiz-extra-plugins compiz-fusion-plugins-main libcompizconfig-backend-kconfig compiz-core compiz-decorator gnome-compiz-manager compiz-fusion-plugins-main compiz-gnome libcompizconfig-dev libgnome-compiz-manager0-dev libcompizconfig0 libcompizconfig-backend-gconf libcompizconfig0-dev libcompizconfig-backend-kconfig libcompizconfig-dev libdecoration0
[/code]

5a. Now, the final step;
[code]
cd ~
mkdir .CFgit
cd .CFgit
git clone git://anongit.compiz-fusion.org/users/omega/scripts
cd scripts
chmod a+x git-compiz
./git-compiz --purge
[/code]

5b. I didn't exactly lie... If you have;
>>> GNOME
[code]
./git-compiz --with-desktop=gnome
[/code]
>>> KDE
[code]
./git-compiz --with-desktop=kde
[/code]
>>> KDE4
[code]
./git-compiz --with-desktop=kde4
[/code]

And that's how to install.
To update your compiz from git - cd back to ~/.CFgit/scripts and execute;
[code]
cd ~/.CFgit/scripts
./git-compiz --rebuild=true
[/code]

A BIG thank you to all of you compiz, emerald, and plugin devs!
Special thanks to omega for his/her wonderful script.

Have fun with your shiny new desktops, assuming they haven't borked yet ;).

Post comments on any problems with my instructions!!!

[News] The First Post

Hello,

This is the first post on vglob - a blog mainly about (but definitely not restricted to) Linux and Programming.

Content on here may range from anywhere between how to create an unbeatable Connect4 application using Python or watching a video of Steve Ballmer getting egged in Budapest by an angry white guy.

Some of the language may seem mildly offensive, but I assure you, the phrase "angry white guy" is probably as bad as it's going to get - just out of politeness. You may, however, feel free to use any language you are comfortable with.

--- vsk

(P.S )


Vedant Kumar's Facebook profile