srik.in
user

srik.in

Srik.in is the personal website of Srikanth Eswaran who lives in Bangalore, India.


Featured

slow, browsers, loading

Simple fix for slow browsers

Posted on .

So if your browser is loading pages slowly, here is a fix that might help

  • Run Windows Command Prompt as administrator
  • (type ‘cmd’ in the Start menu search box, right click ‘Run as administrator)
  • then type in ‘netsh int ip reset’, pressed enter
  • Restart PC

Browsers are loading pages really quickly again.

Featured

restoring, apple, iphone, ringtones

Restoring Apple iPhone ringtones

Posted on .
  • Open Safari on your iPhone, iPad, or iPod touch.
  • Go to itunes.com/restore-tones
  • Sign in with your Apple ID.
  • Tap Restore. You’ll see a message that reads: “This may take a while. You can continue to use this device while we prepare your tones. You will be sent a push notification when they are ready to download.”
  • Tap Done.
  • When you receive the notification on your device, tap Download, or, if you receive the notification on your lock screen, swipe to download.* All of your tones will download, including any that are explicit.
  • Check to make sure that your tones are now on your device:
  • Ringtones: Tap Settings > Sounds > Ringtone.
  • Alert tones: Tap Settings > Sounds > Text Tone (or any other alert listed).
  • If you assigned purchased tones to your contacts, these will also be restored.
Featured

eclipse, ubuntu, chmod, file

Installing eclipse for Ubuntu

Posted on .

This is about installing eclipse for Ubuntu 9.x new desktop version. You can run any eclipse you want to this way! I have taken this content from here for easier and faster reference. I have also added my own stuff to it, which I found would make eclipse start up properly. So read on.

On ubuntu, remember this always:

Please download the x86_64 version of eclipse- and NOT the 32 bit version. That won’t work!

These instructions assume you’ve downloaded and extracted the above mentioned Eclipse tarball:

bash
sudo mv eclipse /opt/eclipse cd /opt sudo chown -R root:root eclipse
sudo mv eclipse /opt/eclipse cd /opt sudo chown -R root:root eclipse
sudo chmod -R +r eclipse
sudo chmod +x `sudo find eclipse -type d`

Then create an eclipse executable in your path

bash
sudo touch /usr/bin/eclipse
sudo chmod 777 /usr/bin/eclipse

sudoedit /usr/bin/eclipse

With these contents:

bash
#!/bin/sh
export ECLIPSE_HOME=/opt/eclipse
$ECLIPSE_HOME/eclipse $*

NOTE:

If you use, sudo chmod 755, it wont allow you to edit the /usr/bin/eclipse file in some systems, hence I have changed it to chmod 777 instead. you can change back to 755 after editing the file!

Also see that ECLIPSE_HOME is set to /opt/eclipse (WITHOUT QUOTES) Now you can execute Eclipse from anywhere in your bash shell by just typing ‘eclipse’.

Featured

eclipse, large, projects, java, memory

Starting eclipse with more memory for large projects

Posted on .

I had come across a situation where my Eclipse IDE used to crash or shutdown forcibly due to less memory being available. After searching around for a while, I came across a command that enables you to start this IDE with more memory. Here it is:

eclipse -vmargs -Xmx<memory size>

I have tried combinations of 512M and 1024M (0.5 GB and 1GB respectively) and the IDE worked fine without a crash since then. This is a useful command and I hope you can refer this site for starting up eclipse with more memory in future and avoid some precious time saving IDE crashes in future!

UPDATE: On this link, I also found six common errors one would make while starting up eclipse with virtual memory arguments. I reproduce here the excerpt of the six errors:

Two JVM options are often used to tune JVM heap size: -Xmx for maximum heap size, and -Xms for initial heap size. Here are some common mistakes I have seen when using them:

  • Missing m, M, g or G at the end (they are case insensitive). For example,

java -Xmx128 BigAppjava.lang.OutOfMemoryError: Java heap space

The correct command should be: java -Xmx128m BigApp. To be precise, -Xmx128 is a valid setting for very small apps, like HelloWorld. But in real life, I guess you really mean -Xmx128m

  • Extra space in JVM options, or incorrectly use =. For example,
    java -Xmx 128m BigAppInvalid maximum heap size: -XmxCould not create the Java virtual machine.
    java -Xmx=512m HelloWorldInvalid maximum heap size: -Xmx=512mCould not create the Java virtual machine.

The correct command should be java -Xmx128m BigApp, with no whitespace nor =. -X options are different than -Dkey=value system properties, where = is used.

  • Only setting -Xms JVM option and its value is greater than the default maximum heap size, which is 64m. The default minimum heap size seems to be 0. For example,

java -Xms128m BigAppError occurred during initialization of VMIncompatible initial and maximum heap sizes specified

The correct command should be java -Xms128m -Xmx128m BigApp. It’s a good idea to set the minimum and maximum heap size to the same value. In any case, don’t let the minimum heap size exceed the maximum heap size.

  • Heap size is larger than your computer’s physical memory. For example,

java -Xmx2g BigAppError occurred during initialization of VMCould not reserve enough space for object heapCould not create the Java virtual machine.

The fix is to make it lower than the physical memory: java -Xmx1g BigApp

  • Incorrectly use mb as the unit, where m or M should be used instead.

java -Xms256mb -Xmx256mb BigAppInvalid initial heap size: -Xms256mbCould not create the Java virtual machine.

The heap size is larger than JVM thinks you would ever need. For example, java -Xmx256g BigAppInvalid maximum heap size: -Xmx256gThe specified size exceeds the maximum representable size.Could not create the Java virtual machine. The fix is to lower it to a reasonable value: java -Xmx256m BigApp

  • The value is not expressed in whole number. For example,

java -Xmx0.9g BigAppInvalid maximum heap size: -Xmx0.9gCould not create the Java virtual machine.

The correct command should be java -Xmx928m BigApp

Featured

map, c++, stl

Understanding MAP STL’s

Posted on .

So you might have wondered what a MAP is? I am tyring to demystify it a bit, so pardon my technical way of putting it if its not so perfect! Its always best to think of any C++ related concept by taking an example from the real world. I have found that it always benefits me that way.

So lets take an office full of employees. Further more also lets assume that the employee ID is a unique number by which that employee is identifiable in that office. Now also lets have the following information about the employee

Age, Sex ,Address, First name, Last name – as parameters for identifying the employee in a more detailed fashion, and Gross Salary, Net Salary and Tax per annum – as parameters for identifying the finances related to the employee. Bear in mind that both these sets of data, are primarily associated with the employee ID. So now we can construct two sets of tables which have this data.

Table 1:

Employee ID Identification information
1094 32, Male ,771, Koramangala Layout, Bangalore City, Srikanth Eswaran
2056 35, Male, HSR Layout, Apartment 101, Bangalore City ,Kiran Vinayababu

Table 2:

Employee ID Salary information
1094 $60000 (gross), $48000 (net), $10375 (tax)
2056 $120000 (gross), $70000 (net), $25000 (tax)

So now what is it we can do to effectively not only store, BUT ALSO cross reference this information? We can use maps, not one, but two of them to put ease into the information access!

MAP1: This is a map between a number and Identification information MAP2: This is a map between a number and Salary information

typedef map<int  , identity> Id2Identity; 
typedef map<int  , salaryinfo> Id2SalaryInfo;

So what is Identity? Its just a structure having column 2 of table 1.

And what about salaryInfo? Its just a structure having column 2 of table 2. Lets write it here:

struct Identity
{
  unsigned int age;
  enum type
  {
    MALE, FEMALE
  }
  const char* address;
  const char* firstName;
  const char* lastName;
};

struct salaryInfo
{
  unsigned float grossSalary;
  unsigned float netSalary;
  unsigned float tax;
};

Having these two maps, its easy now to switch between the information from both these maps, based on the unique employee id associated with the data! We shall see how in a short while.

the “.first” and “.second” operators (if i may call them so) maybe used to access the values in the first and second column of the map respectively. So for eg., in the first map above,

Id2Identity::iterator it;

it->first or (*it).first will give the employee ID

and it->second or (*it).second will give the structure containing identity details. for eg if we need the last name of the employee, then we say

it->second.lastName on the first record will be = “Eswaran”.

Having said this, now its easy to access the second column, if we have the first, by doing a find operation using the first column value. For eg., it->find(1094) on the first map will yield the structure having this data. So I can say it->find(1094).lastName and it will still return “Eswaran”

- 32
- Male
- 771, Koramangala Layout, Bangalore City
- Srikanth
- Eswaran

Remember that the find operation is a O(log2(n)) operation compared to iterating through all the entries in the map on our own using an iterator, which is O(N).

So now it wont be difficult to find the tax of a person having an ID which you need to get if I would say that person’s last name is “Eswaran”. Try it, and you will soon feel maps are powerful and easy to use! More later!