22 January 2015

Bit Manipulation & Recursion: Dreadful combination?, Probably not...

You are probably interested in this post because it touches two complicated areas of programming, Bit Manipulations &Recursion. Indeed it does. I will dig deep into these. Bear with my speed and be patient, you will get it. The best way would be to take a problem and follow through it. There are chances that you might have already heard about this problem but I will try to follow an approach which hopefully will highlight some new things about the problem.

So first the problem. Lets say your friend comes to you and puts a challenge across, Programming Interviews: Implement adding two unsigned numbers without using "+" or "++"?. You being a problem solver, accept the challenge & try to work on a solution. You think, Is there a possibility that by using any in-built operators other then '+', you will be able to solve this? Probably. So you try various operator '-', '*', '%' etc. You put all your effort into it but solution remains elusive. You think that there is no harm in asking for help to get some pointers. Absolutely, no harm. You approach another nerdy friend to get some help on the problem. After seeing the problem, what do you think would be his first response? Think... Well, it is highly likely (if he is a nerd) that he will ask you this question, "Can you try bit operators?". It looks like your friend has taken quite a journey. He asked you this question because he thinks that if a in-built language operator is not an option, can we do what computer itself would be doing? Use bit operators.
So you get a cue. You have some basic idea about bit manipulation. You start working on the program using bit operations. You look at bit array associated with two numbers which need to be added & do some mental wrestling:

19 = 10011
29 = 11101

Since you are aware of bit operations, what is the first thing which crosses your mind? Take a moment & think. May be, you look at the whole binary representation of each number & think that adding bits is simple but how to handle carry from right to left? If you considered the ENTIRE string and thought about moving carry across, there is a problem. The issue is that you are not breaking problem into smaller sub problems. What instead you should have done is this (the last one is important):

21 March 2014

Turkey can block Twitter, but it can’t stop users tweeting

image
Users lash out against Turkish government's block on Twitter

Update: Turkish President Abdullah Gul has tweeted to denounce the government’s ban on Twitter, joining thousands of other Turkish citizens in protest, which have now well and truly taken over Twitter.



Ever since allegations of corruption in the Prime Minister Recep Tayyip Erdogan-led Turkey government creeped up on Twitter, the country has been in a bit of a turmoil, especially given that elections were around the corner. There has been a lot of brouhaha after the PM decided to publicly voice his dislike of the micro-blogging social network.



Then today, a Turkish court ordered that access to Twitter be blocked in the country, after Erdogan threatened to wipe-out the service in an election rally. Erdogan has been in the centre of a string of corruption allegations, that along with a sex scandal and accusations of clamping down on media, have rocked Turkey. Twitter was the primary source of these revelations as two supposedly whistleblower accounts started leaking videos, photos and documents against the current government and many high-level politicians. The Turkish government claims that despite repeated requests, Twitter refused to take down links which were deemed objectionable. So the court issues a ban.



But despite the block, those involved in the leaks say they are not about to stop releasing more information. This morning, Haramzadeler333, who has been one of the main sources for the leaks, published all the documents in a Google Drive folder, anticipating the ban. The folder includes transcripts, videos and images that supposedly reveal the corruption in the government. The user has also posted videos on YouTube, as well as used other file-hosting services to keep the documents alive.




Secondly, even as the ban takes effect, Twitter has asked those from Turkey to rely on SMS-based tweeting to keep the world informed about developments.Thousands of Turkish citizens are tweeting in protest. Many have resorted to using the SMS service, which allows them to tweet with just a simple text message to a phone number.


A lot of on-ground activity has also been seen so those in the country can avert the block, such as the below graffiti that shows users how to access Twitter using the Google Public DNS. So it’s not like one cannot use Twitter at all in the country.


Turkey’s Information Technology and Telecommunications Board said the service had to be blocked after “complaints from our citizens” about violations of rights and privacy. “Twitter has ignored decisions made by the courts of the Republic of Turkey,” the board said in a statement on its website. “Left with no other choice to prevent the incompensable victimization of our citizens, a preventive measure blocking access to Twitter has been imposed in line with court decisions.”



The news comes on a day when Twitter is celebrating its eighth anniversary. While it has memorialised your first tweet, for many Turkish Twitter users, the anniversary would be a starkly different reminder.

Google makes Gmail slightly more secure with encrypted HTTPS connection

image
Google turns on HTTPS for all Gmail messages

After Edward Snowden revealed the massive scaled of the NSA secret surveillance programmes, many tech companies were said to have helped the security agency with their spying. However, soon there were to be denials and outrage.



Remember Google employees and bigwigs lashing out against the NSA and its allies after it was revealed that they can secretly access all your Gmail communication? Google had vowed to fight back by making Gmail use an encrypted HTTPS connection in the future. Starting today, Google has flicked the switch on to make the move final.



“Your email is important to you, and making sure it stays safe and always available is important to us. As you go about your day reading, writing, and checking messages, there are tons of security measures running behind the scenes to keep your email safe, secure, and there whenever you need it,” Nicolas Lidzborski, Gmail Security Engineering Lead, wrote in a blog post on the official Gmail blog.



It must be noted that HTTPS is not a new technology for Gmail and has existed since its launch. In 2010, Google made HTTPS default, but users could still opt to communicate over insecure lines. But now that’s no longer an option. “Today’s change means that no one can listen in on your messages as they go back and forth between you and Gmail’s servers—no matter if you’re using public WiFi or logging in from your computer, phone or tablet.”



Having said that all’s not well just yet. If, for example, you have a lot of communication with non-Gmail users, there’s no guarantee that your emails to them will be encrypted too. It’s still wiser to use an encryption service for your emails as that’s far more effective. And even if Google says all emails on their servers and in their data centres are encrypted, that doesn’t mean they cannot be intercepted in the middle through different means such as tapping into undersea cables, which the NSA has been known to have used from time to time, as an earlier report points out. All this means is that your Gmail is a little more secure than it was before.



Google also taken additional steps to ensure greater transparency in the light of accusations of scanning through your inbox for purposes other than tailored ads. Now emails will be encrypted even while moving internally within Google’s data centres. “This ensures that your messages are safe not only when they move between you and Gmail’s servers, but also as they move between Google’s data centers—something we made a top priority after last summer’s revelations.”



Lidzborski is referring to the revelations made by Edward Snowden last year, which shone the light on a number of US government secret surveillance programmes. NSA and its allies reportedly had access to all of Google’s servers, but the company has maintained that it has never colluded with authorities for mass surveillance programmes and only hands over data after court orders. At TED 2014, Google co-founder Larry Page railed against the NSA tactics and called their methods a threat to democracy. The company is one of the many tech giants who have teamed up to force the US government make reforms in how the NSA obtains data.

Moto X, Moto G users can now click pictures using volume keys with Motorola Camera update

image
New Update is here

Motorola has tried to offer as pure Google Android experience as possible, ever since it was acquired by Google. However, it does have a bunch of software add-ons that hope to improve the stock experience, such as in terms of Voiceless Control or quick camera access. Motorola has rolled out a new update to the Motorola Camera app that allows users to click photos using volume keys.



Michelle Gattuso of Motorola revealed in a Google+ post, “In addition to touch anywhere on screen, now you can also take photos using the volume keys.” The new version 3.2.14.4 has been pushed out for Motorola Camera on the Moto X and Moto G as well.



The ability to take pictures using volume keys is also made available for headsets attached to your smartphones. However, the updated application will be compatible only for devices running Android 4.2.2 KitKat. One can also expect some bug fixes with the new update. The Motorola Camera app is compatible with only select devices. Those who have the app can get the update here.



Recently we also got a glimpse of Motorola’s first smartwatch that runs Android Wear, Google’s new OS designed for smartwatches. It hosted a live Hangout session for the Moto 360 smartwatch.

16 March 2014

Post iOS 7.1 update, Apple’s iPhone 4 is finally running faster

image
Fewer headaches now

It was the first iPhone to bring the now-familiar industrial design to the fore, so there’s a bit of ‘technoholic’ nostalgia for the iPhone 4 in our minds. But with iOS 7, that was replaced with mockery and complaints as the phone refused to function as an Apple device is expected to. So we were really eager to see how Apple would fix the major bugs with the iOS 7.1 update and looks like the Cupertino company has delivered.



According to Ars Technica’s review, there are slight improvements in application loading times, while some animations have been trimmed to enhance performance. The website said that Apple has revitalised the iPhone 4 and worked its magic once more when it comes to hardware and software optimisation.



But we decided to wait on delivering a verdict before we could see how things are first-hand. Firstpost’s Arun George has been struggling with an iPhone 4 running iOS 7 since the update came out, but is looking a bit more chipper since the 7.1 update hit his phone. Here’s his account:




It was difficult to avoid the temptation of iOS 7 despite being advised against it. An iPhone 4 was never the ideal device to receive the update to iOS 7, and complaints began hitting the web about how some units had begun to malfunction after the update. I ignored every one of them to get the new operating system and apart from giving the phone a new appearance, it did little beyond slowing it down.



Applications slowed, and in some cases even crashed. Switching between applications became a task and opening an application often took its own sweet time. Subsequent updates didn’t help either. Until yesterday, when I downloaded the iOS 7.1 update.



There are visible improvements now in the speed of the phone. Applications open faster, shut faster and so far I haven’t experienced any time lag in switching between two of them. The phone screen which had been rather unresponsive since I upgraded to iOS 7, is now working like it did before I downloaded the latest version of iOS.



But the biggest difference for me is in the operation of games. FIFA 14, which often slowed down and hung, is now functioning smoothly. For the first time since I downloaded iOS7, I could play a game without it slowing down, hanging or crashing.



So it looks like Apple has managed to make the iPhone 4 a little more appealing to those who were looking to buy one, but were afraid of the bad user experience. Of course, with Apple typically having supporting devices for three years, the iPhone 4 will in all likelihood not see the next version of the OS.