Bi-directional Map in Java

by Deepak Dhakal 28. July 2017 06:10

Yes, 

You can use the Google Collections API for that, recently renamed to Guava, specifically a BiMap

A bimap (or "bidirectional map") is a map that preserves the uniqueness of its values as well as that of its keys. This constraint enables bimaps to support an "inverse view", which is another bimap containing the same entries as this bimap but with reversed keys and values.

 

 

import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;

public class BiMapTest {

  public static void main(String[] args) {

    BiMap<String, String> biMap = HashBiMap.create();

    biMap.put("k1", "v1");
    biMap.put("k2", "v2");

    System.out.println("k1 = " + biMap.get("k1"));
    System.out.println("v2 = " + biMap.inverse().get("v2"));
  }
}

Tags:

java

Validate Request in .net 4.0 returning 500 error

by Deepak Dhakal 28. July 2017 06:06

Soln:

Make sure you don't have < httpRuntime> tag already in web.config

if it is already there, put the setting inside it.

Tags:

Stock to watch for 2013

by Deepak Dhakal 2. January 2013 10:26

http://www.advicetrade.com/chartsoftheday/Top-Stocks-for-201212311046.html

Tags:

Stock

How to add unsupported device on windows for android development

by Deepak Dhakal 2. July 2012 17:21

 

For my case, I had HTC inspire which was not working for usb debugging.. 

 

So if you have HTC inspire phone and want to enable debugging

 

The Product ID for the Inspire is probably not in the android_winusb.inf file you have.

I was able to get the ADB installed by opening the android_winusb.inf in notepad and added the Vender and Product ID to it..

here's how it would look:

; HTC Dream

%SingleAdbInterface%        = USB_Install, USB\VID_0BB4&PID_0C01

%CompositeAdbInterface%     = USB_Install, USB\VID_0BB4&PID_0C02&MI_01

%SingleBootLoaderInterface% = USB_Install, USB\VID_0BB4&PID_0FFF

; HTC Magic

%CompositeAdbInterface%     = USB_Install, USB\VID_0BB4&PID_0C03&MI_01

; HTC Inspire

%SingleAdbInterface%        = USB_Install, USB\VID_0BB4&PID_0CA2

%CompositeAdbInterface%     = USB_Install, USB\VID_0BB4&PID_0CA2&MI_01

;

I just added in the HTC Inspire after the HTC Magic device.

I was able to install it after I did that.

 

Tags:

android

Increase CTR for iAD

by Deepak Dhakal 22. May 2012 10:24

FOR THE IOS PLATFORM:

Not pausing an ad request when your view disappears

When your view goes off screen, you should pause the ad refresh timer, otherwise your ad will run in the background.  You do this by calling pauseAdAutoRefresh (see below). If you don’t pause ads when your view goes off screen, you will not only lower your earnings, you will impact your apps’ overall performance.

- (void)viewWillDisappear:(BOOL)animated {

! [super viewWillDisappear:animated];

! [self.adView pauseAdAutoRefresh];

}
Read more at http://blog.mobclix.com/2011/02/24/how-to-increase-your-click-through-rate/#UiI6yqLyE9OEZBMx.99

Tags:

iPhone

Timeout while reading counters in VS 2010 load testing

by Deepak Dhakal 16. April 2012 06:59

Did you see an error like below while running a load test in Visual studio 2010 ? There is an easy solution, I know you already checked the firewall issue, permission issue and service issue but do not know where to change the Timout setting...

The performance counter category 'Network Interface' cannot be accessed on computer 'ComputerName' (Access is denied) ; check that the category and computer names are correct

    Timeout Issue: Timeout may happen if you are collecting counters from remote / slow box e.g. remote web server. We can increase the timeout by adding this key in controller config file Controller.exe.config:

<appSettings> 
<add key="LoadTestCounterCategoryReadTimeout" value="60000"/> 
<add key="LoadTestCounterCategoryExistsTimeout" value="60000"/> 
< /appSettings> 

You’ll find Controller.exe.config inside %ProgramFiles%\Microsoft Visual Studio 10.0\Common7\IDEat your test controller box. In case you are not using test controller and doing a local run then please add above mentioned key in devenv.exe.config which you’ll find inside%ProgramFiles%\Microsoft Visual Studio 10.0\Common7\IDE at your client (VS Ultimate) box.


 


Tags:

.Net

Powered by BlogEngine.NET 1.5.0.7 - Old School Theme by n3o Web Designers