Eclipse Helios settings are gone everytime I restart it

May 20th, 2012 Admin

Everytime I restart my eclipse helios I see it having lost all its views, perspective and all its setting. And as I have a maven eclipse installed on it, it starts updating nexus-maven-repository-index central which seem to a decade to do its thing.

I was very happy with Galilio but I needed to work on a project that asked me to use helios or above. And I’ve been feeling burnt ever since I switched to Galileo.

Does eclipse helios has any incompatibilities with any of Java 6 versions. I am using jdk1.6.0_32.

Could someone please help me with these problems.

Thanks

What is ConcurrentQueue<StrongBox<T>>? How do I implement a StrongBox?

May 20th, 2012 Admin

How would I implement a StrongBox as described on this MSDN blog?

snip

If the elements are small, you’ll probably never notice this [memory leak]. If,
however, the elements hold on to large resources (e.g. each element is
a huge image bitmap), it’s possible you could see the impact of this
(one workaround is to queue a wrapper object, e.g. have a
ConcurrentQueue<StrongBox<T>> rather than a ConcurrentQueue<T>, and
null out the wrapper’s reference to the T value after the wrapper has
been dequeued).

table-cell layout — force nested anonymous table to be as tall as its parent

May 20th, 2012 Admin

I am attempting to do an equal-height-columns layout in HTML with ‘display:table-cell‘, as suggested e.g. in this article; the wrinkle is that, depending on media-query-detected viewport width, there should be either two or three columns. The closest I’ve managed to get, boils down to this test case (with a JS pushbutton replacing the media queries): it almost works, but as you can see by pushing the button, in three-column state the two right-hand columns do not go all the way to the bottom of the ‘page’; they are being balanced with each other, but not with the left-hand column.

How can I fix this? Note: IE<8 compatibility is not a concern, and a CSS-only solution (no JS) is strongly preferred.

<!doctype html>
<style>
#main, #sidebars { display: table-cell; width: 120px }
#main { background-color: #bbb }
#sidebars { background-color: #bcc }
.wide #sb-one { display: table-cell; background-color: #bcc }
.wide #sb-two { display: table-cell; background-color: #bdd }
.wide #sidebars { background-color: red; width: 240px }
</style>
<div id="main">
text text text text text text text text text text text text
text text text text text text text text text text text text
</div>
<div id="sidebars">
<div id="sb-one">
text text text text text text text text text text text text text text text
</div>
<div id="sb-two">
text text text text text text text text text text text text
</div>
</div>
<p><button>Push</button></p>
<p>Under no circumstances should there be any red.</p>
<script>
window.onload = function() {
  document.getElementsByTagName("button")[0].onclick = function() {
    if (document.documentElement.className === "wide") {
      document.documentElement.className = "";
    } else {
      document.documentElement.className = "wide";
    }
  }
}
</script>

Using Redis to Scale Web Services

May 20th, 2012 Admin

In my latest project, I have to write a web service API to return data from a database.

Techs are
– SQL Server 08 R2
– WCF

The data is mainly key-value pairs, e.g. for get user X’s favourite colour.

The load isn’t massive, but not small-fry either – about 1,000 requests / sec at peak.

My initial thoughts are to use Redis as the cache, meaning we don’t hit SQL Server as often. However I’ve been trying to get some benchmarks etc out of this configuration, and it’s not great, making me wonder if Redis will really offer any benefit for my problem!

Architecture is
– separate db server
– WCF App Server – IIS
– Linux Redis server

When playing around on my desktop, the Redis benchmarks at ~ 20K ops / sec. Great stuff.

However, given that each call will go through a web service, when I put a WCF layer I can only get 300 ops / sec. Not great. Admittedly, web service client, web service and database are all on the same machine, so that might skew the results!

Also, when moving to the real environment, network latency will be a major factor.

I can’t batch these requests up in any way.

So – my question – I’m all for using Redis as a cache – I know I should use a cache in this situation – but given that I can’t have Redis on the same box as my Web Services then won’t network latency kill performance?

Any advice greatly appreciated!

Duncan

external allocation error for BitmapFactory.decode with sampleSize

May 20th, 2012 Admin

In my android app I need to display images from resources. So, I want to display in ListView or GridView images thumbnail and some information. After start main activity, I load tried load thumbnails in AsyncTask. Here the code for loading:

            int scale = 1;
            BitmapFactory.Options o = new BitmapFactory.Options();
            o.inJustDecodeBounds = true;
            BitmapFactory.decodeResource(resources, resId, o);
            while (o.outWidth / scale / 2 >= 70 && o.outHeight / scale / 2 >= 70)
                scale *= 2;
            BitmapFactory.Options o2 = new BitmapFactory.Options();
            o2.inSampleSize = scale;
            bitmap = BitmapFactory.decodeResource(resources, resId,o2);

I know that loading bitmap consuming height*width*4 bytes in memory, so I use BitmapFactory.decodeResource with inSampleSize option. In my device (u8230) it works perfectly, but on emulator or other android devices that i had, it fails on decodeResource with “external allocation too large for this process”. On my device I set VM heap size to 12 mb, and it still work (maybe this because cyanogenmod installed).