Friday, October 17, 2014

Removing Messy Boot-load Entries in Windows 7

Sometimes when you install multiple copies of operating systems and then uninstall, you might face the problem that the bootloader entry doesn't get removed automatically. It starts getting weird when you have number of same operating system bootload entries. I had myself installed Ubuntu 12.04 inside Windows 7 and then, for some reason, had to switch to version 14.04.1. What I got was two Ubuntu's appearing at my boot screen.
The solution to this problem (in Windows 7) is:

1. Open cmd in Windows 7 as administrator
2. Write this command
3. Your area of interest in this output will be this line
4. Read carefully what entry you want to delete from here and copy the identifier of that entry into your clipboard. I couldn't do it from console also I don't run such long strings to avoid typing mistakes plus it requires you to look hard. What I did was
which is nothing but redirecting output to some file.
Now you can easily copy into clipboard by opening that file in notepad.
5. Paste this into command as follows
and then press "return" key.

Be careful manipulating with bsdedit as you're working as an administrator.
Good luck.

Wednesday, October 8, 2014

How to Check if the Number is Some Power of 2?

To check if some number is a power of two there many methods available but there is an efficient one to do this. First of all assure that the number is not (because zero is not some power of two). Then assure if the (number - 1) and number's logical and is zero. Let's take a look what is happening behind this logical and operator. You may run it for any power of two.

Sunday, September 28, 2014

Bookmarks - 1

Some of my recent searches over the internet are as follows,
  1. Introduction to Graphs: Definitions, Traversal, Depth-First Search - CodeChef Discuss
    A very conceptual topic that every programmer at least skim through once (although just skimming doesn't give you any fruits).
  2. NPTEL PHASE 2 - Courses
    Something that should be taken as a online course by every single data-structures learner.
  3. Computing Factorials of a huge number in C/C++: A tutorial - CodeChef Discuss
    Huge number case study for those who are curious how these BigInt and other number manipulation libraries are build.

Friday, September 26, 2014

Surfing Windows Like Webpages

From last few days, I'm trying to find the square hole for this square peg. Windows compatibility for its own development platforms is disgusting.
It all starts from here,
If you need to do little programming for evaluation purposes you need an express edition. Okay I see you got express edition there, it is free for use but please register it. Okay you've registered it too? Good.
If you need to do Windows 8/8.1 metro app development, you probably need higher versions of Visual Studio. Got higher version? Okay you can't do everything anymore on your Windows 8. Switch to Windows 8.1 it is really free, just install all the updates from Windows Updates. Got updates? Sorry for inconvenience but you really need to restart your PC. Back? You got a few more updates. Okaynowtellmewhatnext? It is "you need to install these updates to get your free update of Windows 8.1". Installed? Congratulations, you can download the free upgrade now. Downloading? Nope "unfortunately Windows Store app doesn't work very fine in Windows 8".
And if you even get the upgrade to Windows 8.1 (I don't know how). There are a lot of device issues in it and still filed as undocumented bugs in it.
The measure of last resort is always Windows 7 for me. But idon'tknow why I switch the operating system again, wait I tell why, I need to develop apps because that's what I am, a desperate app developer. (Windows 7 doesn't support Windows Phone development).

Saturday, September 13, 2014

C#: How to Save Image from a Canvas

So recently I've been working on this Windows Phone app so hard that I hardly get time for myself and blog some fishes here. But now I am talking with my blog I'm talking about the same thing I've been doing since 5 days (nights included too).
I was actually trying to save some image from the screen, more of a screenshot but in a programmers way. I was searching for a lot of XAML tags and studying about them like DrawingSurface and every frigging tag that looks like something that can be sixth sensed and categorized into something imagery (save an image I meant). In the meantime I find this life saver Canvas and now its all vanished. All my dark problems inside me pouncing upon each other to hike through my wind pipe out into the fresh air are now gone.
Here is the code.

Wednesday, August 27, 2014

Learning

So far I've learned so much from +Bob Tabor, I'm thankful to him for each and every series I watched (JS fundamentals, C# fundamentals, WP8 fundamentals). Feeling so enthusiastic after learning new technologies that I've cooked some basic applications in the fields. Looking forward to build something bigger. All I need is a little more time.
Happy learning!

Saturday, August 23, 2014

Summers

It's been a long time since I wrote something that is actually about me. Well, here I am spending my summer vacations quite in the way I planned in last semester (huh! what a bad time it was). I actually planned a lot of things to do in summers but I always plan more than I can do so that I do more and more. I am watching movies (a lot), television series, playing games, learning a few things. Recently a lot of people (mostly juniors) have asked me what to do best in summers so that at the end you don't regret that you wasted whole a lot of time doing nothing. I told all of them, "do what needs to be done." Really you should go with your heart. You want to play games? Play them like day and night (literally only stop to eat). You want to go on a tour to some northern areas? Go far away from north. But at the end you shouldn't regret. Regrets are something you keep regretting your whole life.
What I am doing right now?
Well, I am watching Game of Thrones (nearly ended), The Strain and I wish I could mention The Big Bang Theory (God, I miss that badly.)
I am learning C# from learnvisualstudio.net (a video lecture series compiled by Bob Tabor, really a good one for absolute beginners).
I am reading some books to cover the old topics from data structures course and discrete mathematics.
I plan to hit a game in future (in some days) before I leave for Karachi (still planning).

Thursday, August 7, 2014

The `override` Keyword in C++11

Since C++11 has been released, a lot of new things are added in newer versions of working draft (available at http://www.open-std.org/jtc1/sc22/wg21/). Recently I've come to know about the `override` keyword (which is not actually a `keyword` but an identifier with a special meaning).

A very good description with code example is given in this link below,
http://stackoverflow.com/questions/18198314/override-keyword-in-c

Key points are,
  1. Works with virtual functions.
  2. The identifier `override` makes sure that the base class has the same function signature if you write override specifier after some virtual function in derived class.
  3. Quoting working draft C++11 N3242 (published on 28-Feb-2011),
    If a virtual function is marked with the virt-specifier override and does not override a member function of a base class, the program is ill-formed.

Initializing a Constant Pointer

A little off-road but still something was whispering in my head, "can you initialize constant pointer pointing to constant pointer pointing to constant pointer pointing to an integer constant?". Well why not.
Trick was just to send initialized pointers into initializer of previous pointers.
Normally you don't need this scenario. Though creating constant pointers and putting a lot `const` specifiers in a pointer declaration makes the pointer `safe` to be manipulated.

What if you need to initialize an array if you've the same pointer declared. It can be way more tacky and might result into `impossible`.
You can simply declare a pointer and pass it to the function where the parameter is accomplishing all that safety you require from some critical section you want your pointer to stay safe in.
For example,

Saturday, June 21, 2014

Something Touchy

"Only as much as I dream, can I be."

Your mind is your steering and life is the road. It is like a joypad in the game of your life. Whenever you want to score good in this game, you've to concentrate on each and every detail surrounds you. You control your aims, choices made in life lead to them.

Think bigger than you can think!
There is much out there for you to learn. Don't stuck in some loop forever.

You're the product of your own imagination.

Monday, May 26, 2014

You Don't Own Islam

We live in an Islamic republic where media is run by Jews, government is the puppetry of Christians, culture is half Indian and religion is represented by the ones funded to diminish the scope of Islam.

Question arises, if we don't live in an Islamic country, what percent of us are Muslims and what if we are born Muslims, are we baptized to do sins and modify the meanings of worship according to the desire?

I think the answer to this question is well-known by each and every Muslim. Close your eyes and ask yourselves where you stand yourself before criticizing beliefs of some other person. Again, the meaning of this post wasn't to list myself in transgressors. I just don't want to interfere in the beliefs of others. What I know and to which extent I know is my own headache and if I'm wrong at something I should be the one to make it right not you, you "half-baked mullah".

Saturday, May 10, 2014

One More Day To Go

What a hectic week it was, hardly slept for 3-4 hours daily.
According to my point of view students should be given some break to do things. All at once and that much “all”? Phew. Well it is all over now.
Got a weekend to do fun. Make all those wishes come true, I was waiting for, each and every damn second. First thing to do on the list, “get a really long sleep”. Sleep like I’ll get up when I want. Secondly, what? I didn't think for second one. So all I have to do is to go and get some sleep. Good night.
And yeah after getting this sleep, my plan is to make a dictionary software by reading the large data file I have in Java. Good luck to me.

Saturday, April 19, 2014

Imagination

Another thing from my diary. Hope you like it.
"A person who can count the leaves of a tree out of some seed that needs to be planted yet, is far better than the one who needs ages to find the right seed to plant a tree."

Wednesday, April 16, 2014

Object Size Tweak

Someone asked me a few days ago about an interview question. Make a function that returns the integer containing the size allocated to that object passed in that function as a parameter. In simple language, put same functionality as sizeof operator present in C++.

So I answered him to use character pointer to look through the number of bytes allocated.
This function simply does pointer arithmetic, and then simply subtracting the starting address of object from one-block-ahead pointer gives the exact number of bytes.

Happy learning!

Monday, April 14, 2014

Fun With Mathematics

Found some mathematical tricks from an awesome mobile application. Happy learning.

Square a two-digit number ending in 5:
For this example I will elaborate using 45. Try doing it with the numbers ranging from 15 to 95 all. You’ll have fun if you’re into mathematics. At some point in life you might be the smartest sheep in herd.
Let’s see the trick.
  1. Take the tens part of the number (in our case it is 4 from “4”5).
  2. Add one to it (that makes it 5 = 4 + 1).
  3. Multiply the result with the tens part (original tens part, that’s 4, so 4 x 5 = 20).
  4. Append 25 at the right of the resultant (20 25 = 2,025).
  5. Use your calculator and compare result.
Will keep posting more, I hope you learned something new.