Sunday, March 30, 2014

Make Eclipse highlight every instance of the selected text

I love the way notepad++ highlights every instance of the selected keyword, something eclipse doesnt do it automatically, to make it do it first select the text then, ALT+SHIFT+O

Thursday, March 27, 2014

Final Array vs Final Variable in Java

Final in java means you can not change it after been initialized, but ever noticed , you can change values of a final array but not values of a final variable ?

public class UF {
private final int[] nodes;
private final int something=0;
public UF(int n) {
nodes = new int[n];  // perfectly fine
                nodes[0]=-1;     // perfectly fine
                nodes[0]=13;     // perfectly fine
                something=-1;  // ERRR IT IS NOT OKAY

Why java is okay with final int[] array to be changed but not final int ? the final for Array means , you can not change the reference of the array to another array, but the content of array could be anything, since arrays are passed by reference not by value.but for variable, it is passed by value and u can not change the value .

For example the following example for array will make the compiler yell at us :
public class UF {
private final int[] nodes;
public UF(int n) {
nodes = new int[n];
int[] test = new int [n];
nodes=test; // ERRRR compiler not happy !!! you are trying to change a final reference to another reference
but How to make the array values final ? the answer is using umodifiable collections of java
for example :
int[] arr= new arr[5];
List items = Collections.unmodifiableList(Arrays.asList(arr));

Thursday, March 20, 2014

Arbitrary Number of Arguments in Java

Today I learn a cool tip, three dots in java mean Arbitrary Number of Arguments
for example ,

public SchemeUser(String name, AccessPermission... permArgs) {

means any number of AccessPermission arguments could be passed.

Sunday, January 26, 2014

The weirdest dual boot problem ever ! booting to Ubuntu causes audio problem on Windows!

For the past few months I have been cursing myself for installing windows 8.1 (don't judge me, I had to install it to try out the new Visual Studio which apparently works only with windows 8)

I had lots of driver issues with windows 8, pretty much everything stopped working, wifi, Audio,keyboard (yes I had to use virtual keyboard to do anything) which is ... not surprising for me, that's pretty much what we expect from a windows but one problem surprised me the most !!!

The Audio jack for headphone on my realtek audio card would stop working randomly, and I kept doing what Microsoft support and Toshiba support said, (same old things we have been doing since windows 95, going to device manager and uninstalling the driver and installing it again, and if didn't work go to safe mode and do same thing)

None of those solutions solved my problem, till today I found out the reason !!! I noticed anytime I boot to Ubuntu and then restart to windows 8, the audio doesn't work,which is REALLY weird, cause they are the two different partitions, how could they possibility cause error on each other ?

The solution to my problem was pretty primitive too, I had to unplug my computer from the power for 1 minute and then restart back to windows 8.1 to have any audio,  I am still trying to figure out what is exactly going on with this weird problem, but my guesses are, the Audiocard has some flags on it which can be set, and it wont be cleared unless you shut down the computer and unplug it from the power !

Saturday, January 18, 2014

Easy way to find the path of VIMRC in Windows, Mac and Linux

Vim is favorite code editor for many, and vimrc is the config file for vim, I earlier posted about modifying vimrc to highlight syntaxs and show line numbers and auto indent for python and other languages,

if you are using linux you can always find your .vimrc file in the home folder (~) but what about in windows, command line or mac os ? it becomes more confusing when some windows filesystems dont like dot and you have to change it to _

Here is the solution, ask Vim itself where is the path, simply inside vim type :

if you are using graphical vim



computer (45) ubuntu (45) tutorial (19) linux (15) software overview (13) programming (11) terminal (10) troubleshooting (8) life (7) opinion (6) phpBB (4) suggestion (4) tips (4) 12.04 (3) extension and addons (3) firefox (3) java (3) personal (3) python (3) windows (3) 64bit (2) bash (2) bug (2) code (2) google (2) google chrome (2) monitor (2) php (2) phpBB3 (2) shell (2) vim (2) virtualbox (2) $_SERVER['REQUEST_URI'] (1) 2.7 (1) ALT+Backspace (1) AVR (1) Alt-Printscreen-K (1) CTRL+ALT+DELETE (1) Chicago (1) DRM (1) Debugging (1) Gimp (1) Gimp 2.8 (1) Microcontroler (1) Restart X (1) UML (1) Ventra (1) adsense (1) apple (1) audio (1) backup (1) bing (1) blank (1) boot (1) cd (1) chrome (1) computer kubuntu (1) cookie (1) date (1) display (1) domain name (1) download manager (1) dual boot (1) dual monitor (1) eclipse (1) extensions (1) feature request (1) file (1) folder (1) freeze (1) funny (1) gimp single window (1) gnome 3.10 (1) google docs (1) google plust (1) google+ (1) grep (1) icon (1) idea (1) install (1) iterator (1) linux links (1) list (1) literature (1) microsoft (1) moonlight (1) mysql (1) name (1) nautilus (1) netflix (1) notepad++ (1) photo (1) prompt (1) protest (1) read from file (1) realtek (1) resolution (1) roku (1) samsung (1) screenshot (1) server (1) shorter prompt (1) skype (1) space (1) spam (1) spambot (1) system monitor (1) tar (1) task manager (1) template design (1) th23 domain (1) thinking (1) ubuntu 13.10 (1) unity (1) vimrc (1) virtual machine (1) wget (1) with space (1) xorg (1) xrand (1)