Daasurprise
Friday, August 5, 2011
Android EditText set to numeric
Android has a very simple solution for this. When implemented, the user will not even be able to type in any text in that field at all.
In the XML file where you create and set properties of the EditText field, add the following item:
android:numeric="decimal|signed"
This will let the user enter any number - integer, decimal as well as signed negative numbers but no text. The user will be able to enter only one '.' in the field which is the decimal. Pretty neat isn't it? Especially for the app that I am working on that has numerous fields that are need to be numeric only. As some of the fields in my app are created using codes, I had to set those properties in my code. The way to do that is:
textEntry.setInputType(InputType.TYPE_CLASS_NUMBER|InputType.TYPE_NUMBER_FLAG_DECIMAL|InputType.TYPE_NUMBER_FLAG_SIGNED);
Hope this is useful. Will post more ideas and tips in the next posts.
Wednesday, July 6, 2011
Haiku working great from hard drive
The instructions I typed in the grub prompt are:
set root=(hd0,7)
chainloader +1
boot
I set the same root in the 40_custom file and ran update-grub and it found Haiku in that partition upon update. Still, for some reason it would not boot.
I was surprised how less memory and processor Haiku was using. It was around 100 MB RAM...that was all it was taking!..and it was FAST and very responsive. It almost seemed unreal, especially because it wasn't using much processor capacity and it was still fast. I tested a few Haiku apps, they all worked great. I will start playing with it more and post what I find. So far I love it. I believe Haiku will make a mark in the OS arena. It may take some time before they come up with a stable version as well as more apps. It will be certainly interesting to see.
Tuesday, July 5, 2011
Windows 7 Vs Ubuntu Linux Vs Haiku
My new laptop came with Windows 7. I was excited, but not very, because it’s just another Windows operating system. I do like Windows 7, but I always wanted to try alternative operating systems. I have tried Ubuntu installed in a USB earlier, so this time I decided to install it on my hard drive.
I made a partition for Linux, it was pretty easy. I used Windows to make the partition. Once I made the partition, I used the Windows Ubuntu installer located here: http://www.ubuntu.com/download/ubuntu/windows-installer . This, I believe is the simplest way to install Ubuntu to run alongside Windows. It was pretty easy and upon reboot, the Windows menu was updated and it prompted me with two alternatives “Windows 7” and “Ubuntu”. One I select Ubuntu, it will take me to the Grub menu where it again lists both Ubuntu and Windows 7, as well as the Windows 7 recovery partition.
Ubuntu was fast, easy to use and came with the free Libre Office. I haven’t worked much with it yet, but from what I saw it was very similar to Open Office, and they both are very good alternatives to MS Office suite. And hey, they both are free!!!. So far I love Ubuntu and have been making it a point to choose the “Ubuntu” option at log in as often as I can. Now with two operating systems running in parallel I would not panic too much if my Windows starts acting up! I will have all my data in a drive dedicated only for data files, that way my data files are not at the mercy of Windows' reliability.
Another OS that I wanted to try recently was Haiku. I have tried it in the past installing it in a USB drive, but it did not work that great with my USB and I wanted to give it another chance. I followed the instructions and created a Live CD and using which I formatted another partition that I created for this, and installed Haiku in that partition. It seems after that I need to add Haiku to my Grub, if I am using Linux along with Haiku. I tried, following the instructions in the website but haven’t got much luck so far. I am currently working on it and may post this question on the Haiku forums. It still works great from the Live CD though, but I really want it working from the hard drive to get the full experience
For those who are not familiar with Haiku, I really recommend you read up on that. It’s a really cool operating system based on the BeOS. It’s fast, light weight and heavily multi-threaded. I was really excited as I was reading about Haiku. I hope they have good success with this and I am even considering contributing to some of the Haiku projects myself. It is really worth checking out. Their website is: http://haiku-os.org/
I will post more on these operating systems in the coming posts.
Saturday, April 30, 2011
What is orthorexia? A new dangerous disorder?
I am not sure if it’s just coincidence or if there’s something behind it, but the word ‘Orthorexia’ has been showing up in different forms in different articles lately in the online media. So, what is orthorexia? The word ‘Orthorexia’ is derived from two Greek words ‘ορθο’ (ortho meaning ‘correct’ or ‘right’) and ‘όρεξις’ (orexis meaning ‘appetite’). So it means something like ‘right-appetite’ or ‘correct diet’. Basically it seems orthorexia is an eating disorder where the sufferers avoid food with chemicals and pesticides and preservatives and eat only healthy food; they watch what they are eating. There is an innate desire in many of us to do things the right way. Whether it is doing our jobs, or dealing with relationships or writing a computer program or taking pictures or writing a blog or just about anything basic including keeping the house clean, wearing clean clothes, drinking clean water, breathing clean air, and…yes...eating the right food. Why is eating the right food suddenly a ‘mental disorder’?
The word itself is not a new word; it was formed in 1997 but has been given new life recently by the media. There was a time when people cared in great detail for the food they ate. They picked the right food items that would supply them with the nutrition that their bodies needed and prepared them with the right kind of ingredients to make the dishes tasty, natural and healthy. This was obvious and part of their lives, and part of their general knowledge. If you ask some ‘old timers’, especially from cultures that have not modernized very much they would go in detail about how certain food items may cause certain reactions and how certain food items can help deal with certain conditions in the body, etc.
As societies modernized and things became more and more complicated, there were other things that people increasingly started focusing on, including entertainment. People suddenly felt that preparing food, and understanding food is an onerous chore and that is when the processed food industry was born. It was so convenient to buy food from the shelves and eat it without doing anything to it, or at the minimum heat it up. Gradually people became less and less knowledgeable about food, and the various nutrients contained in various food items and food became something that is tasty, filling and easy to get and something that is eaten so that they don’t feel hungry to do the real things like entertaining themselves or focusing on work. How often have we heard things like “The game is about to start in 30 mins, I’m just gonna order pizza”, or “I have an important report that I need to finish, I’m just going to get a sandwich”.
The greatest problem to this is not the obvious health problems and decline in general health among the public but it is the decrease in general knowledge about food. If this trend continues, people may not even know what goodness is in tomatoes and how fish is good for us and what is the importance of eating raw vegetables. All they would care for is keeping their bellies filled with the tastiest food gotten the easiest way possible and repeating after whatever information the processed food industry keep feeding them; almost like the “The plants need electrolytes” scene from the movie “Idiocracy”.
The good thing is there has been an increase in awareness among the public and even a desire to know more about food, and consumption of more fresh and organic food items. People are increasingly starting to avoid processed food, and food that is devoid of nutrients and colored and flavored with numerous chemicals and kept preserved with preservatives. This is certainly not good news for the processed food industry. So why not call a return to ‘normality’ as something ‘abnormal’, a ‘mental disorder’? It may not suddenly “enlighten” people and cause them to return to processed food, but atleast it may slow down the trend, or make some ‘new converts’ or ‘undecided’ people think and wonder, if that is really a weird disorder. Even if it can give the processed food consumers some new point to debate against their own well-being, that itself is a huge help for the processed food industry. That I believe is the reason behind the “discovery” of this new “mental disorder”. Hopefully there are enough people who can think rationally and are knowledgeable and wise enough to decide what is good for them instead of buying theories from these “experts”.
Tuesday, April 12, 2011
Java Multiplication Table Program
int[][] multtable = new int[13][13];
for(int i=0; i<=12;i++){
for(int j=0; j<=12;j++){
//Print the first row (i==0) which is the column header. 4 spaces before the number if number <10 else 3 spaces
if((i==0)&(j>0)){
multtable[0][j] = j;
System.out.print((multtable[i][j] < 10? " ":" ") + multtable[i][j]);
continue;
}
//Print the first column (j==0) which is the numbers (i) itself. 4 spaces before the number if number < 10 else 3 spaces
if((i>0)&& (j==0)){
multtable[i][0] = i;
System.out.print((multtable[i][j] < 10? " ":" ") + multtable[i][j]);
continue;
}
//For other rows (>0) and columns(>0) multiply i & j to create the multiplication table
multtable[i][j] = i*j;
//For values < 10 print 4 spaces before the number
if (multtable[i][j]<10)
System.out.print(" "+multtable[i][j]); else
//For values <100 print 3 spaces before the number
if (multtable[i][j]<100)
System.out.print(" " + multtable[i][j]);else
//Other values (<10) print 2 spaces before the number
System.out.print(" " + multtable[i][j]);
}
//Print line for next row
System.out.println();
}
The output looks like this:
Sunday, April 10, 2011
Could Bloom Energy be the future of electricity production?
A brief explanation on what it actually is:
Bloom Energy uses hydrocarbon based fuel cells, which it calls 'Bloom Box' or 'Bloom Energy Server' that takes in hydrocarbon (eg. Natural gas) and passes it through plates coated with a special catalyst. One of the plates is the cathode and another the anode. The catalyst helps break down the hydrocarbon into CO2, H2O and electricity. We are not going to look into the details of the technology itself, but we are going to focus more on how a concept like this can revolutionize production and distribution of electricity.
Could Bloom Energy really deliver? It seems like a very good idea. By looking at the concept, it seems to solve two major inefficiencies in the current system:
1. Production inefficiencies
2. Distribution inefficiencies
1. Production inefficiencies:
Currently most electricity is produced by converting mechanical energy into electrical energy by driving an electric generator. The mechanical energy to drive the generator is derived from steam which in turn derives its energy from coal, sun or radioactive elements. Some are more direct, like wind energy farms for example, energy from the wind is converted to mechanical energy which is then converted to electricity, and natural gas and diesel power plants also involve fewer steps. The most direct do far has been using solar cells but they are very expensive and the technology is still young. But as we have seen in most cases multiple energy conversions are involved before we get the final product - electricity. The more the number of conversions, the higher the energy losses. In each step of the conversion process energy is lost A quick look at some of the popular processes of electricity generation:
Coal, Solar (Thermal energy based), Nuclear power plants:
Heat from Coal, Sun, Nuclear reaction -->Convert water to steam-->High temperature high pressure steam runs the turbine-->Turbine runs the generator-->Generator produces electricity.
Natural gas, diesel power plants:
Natural gas burns to run the turbine/Diesel burns in IC engine -->Runs the generator-->Generator produces electricity
Wind power plants:
Wind turns the turbine-->Turbine runs the generator-->Generator produces electricity
On the other hand, Bloombox or the Bloom Energy server as it is called directly converts chemical energy in fossil fuels into electricity, producing CO2 and H2O in the process. In short it would look like:
Natural Gas-->Electricity.
This makes the Bloom Energy server very efficient.
Is this the only fuel cell capable of converting chemical energy directly to electricity? No, there are several, especially ones based on Hydrogen. But that again poses serious problems, like production of Hydrogen, which again costs a lot of energy, and distribution and storage of Hydrogen, which is a highly explosive gas.
Most cities already have natural gas pipelines and several new gas wells have come up recently with urban gas drilling, and natural gas is so easy to extract and distribute. These factors give natural gas based fuel cells a definite advantage over Hydrogen fuel cells
Hence, considering production efficiencies of several power plants and technologies out there, the bloom box certainly seems to be a clear winner.
2. Distribution inefficiencies:
Most power plants are situated very far from major consumers. No one wants a coal or nuclear power plant in the suburb or downtown. Even clean energies like wind and solar need vast areas of land, which means they need to be located far away from civilization. The current model of electricity distribution is very inefficient. Eletricity is produced in power plants situated far from major cities and industries and is then supplied to the grids. The grids on the other hand are connected to several grids and switching stations that control the distribution of power based on load requirements. Then there are sub-stations that are connected to the grid that 'step-down' the high voltages for local distribution, which is then even stepped-down for household distribution using transformers.
In brief, the model is more of a 'centralized' model than 'localized'. Such a centralized model requires vast distribution networks that may run thousands of miles, multiple switching stations, multiple transformers performing multiple voltage conversions. Before the electricity reaches the consumer, it is switched from one grid to another, from one sub-station to another, the voltages 'stepped-up' and 'stepped-down' multiple times using transformers before finally reaching the consumer.
Similar to what we saw in the 'Production inefficiencies' section, the more the number of voltage conversions, the more the losses. The farther the electricity is transported the more the losses. Transmission and distribution losses are a major inefficiency in the current model of electricity production and distribution.
Moreover, such is model is very susceptible to natural disasters and is vulnerable to terrorist or military attacks.
Bloom Energy model is very localized. Energy is produced right where it is needed. No transmission or distribution, no need for voltage conversions (Unless a higher or lower voltage is desired). It could be right in your backyard, or in a neighborhood supplying for the whole community. Every office building may have one in its block. There no one sub-station to fail and plunge a whole suburb into darkness. There can even be mini grids within a city or a town with many bloom boxes backing each other up in case one fails or one is shut down for maintenance. Such mini grids may be much more efficient than transporting electricity half the way across the country.
When considering distribution, the Bloom Energy is again a clear winner.
Bloom Energy certainly has good prospects in the future. The model is very attractive and efficient. Even though it still uses fossil fuels, it makes the best use out of fossil fuels, and hence can still be considered 'green'. It is still far less polluting than other fossil fuel based plants. There may be exciting new turns in the near future in the energy field.
Monday, April 4, 2011
Fresh Beef Jerky
At the check out counter he stuck a conversation and asked the guy checking him out, how fresh the beef jerky was.
And he replied "I'm not really sure".
"Well, the package says they are fresh, don't you make them?"
"Oh, no we don't make them, that's the brand name "Fresh" beef jerky.