Posts

Showing posts from 2014

Couple of quick 'diff' examples

For files list only: diff -qr Source1 Source2  > ~/diff_files Actual contents diff; Can be opened with Kompare: diff -Naur Source1 Source2 > ~/diff_contents

Adventures in Threading

Link to source So after stumbling for a while I managed to crack Qt's moveToThread(). Source at above link. Its has working code for big file copy in thread. We have only left one small problem, and that is if the function we are calling on thread start has any arguments to pass, then we won't be able to directly connect it to thread's started() signal. So in this case we should subclass thread and pass the arguments to the custom thread object and then inside it emit an appropriate signal to call the main class's function. It seems like such a complex way to do such a simple task like "run this function on a separate thread!" :D

Xiaomi Redmi 1S

So I was itching to get a new cell phone. My three year old Samsung was just not cutting it. And the temporary zte was too slow. So I needed a powerful and at the same time cheap phone. So after considering a no of smart phones I finally decided that what I'm trying to achieve is difficult and only a Chinese vendor can get me such a handset. Going for Micromax/Karbon/Xolo etc Indian vendors was out of the question because of service woes and poor hardware quality. E.g. I remember the Karbon S1 phone I bought for my sister. Back in 2013 it cost me INR 7.5k. Came with JellyBean and 1GB ram. But the phone had slightly faulty touchscreen. But I didn't want to face Karbonns poor service so I showed my sister how to work around to that. Thankfully the phone has not died and its been a year. Anyway, finally I decided to take a chance with Xiaomi. The price was right and the hardware quality of xiaomi's handsets has been great. So I registered for the flipkart sale and dutifull

AMD Radeon official driver experience

For the Radeon 8330 GPU inside Lenovo g405 powered by AMD A4-5000 APU, I tried out the official driver on Ubuntu 14.04. The situation is somewhat obscure. The official driver listed on AMD support page doesn't support Ubuntu 14.04. So I had to drop it. There is one beta driver that supports Ubuntu 14.04 though. So I downloaded it and thought to try it. Took me some efforts to install it though, it just would not install in GUI Mode, problem shown as missing language packs. Anyway I went ahead with text mode install. After rebooting though, no desktop. Only background with mouse cursor. So I reverted to open source driver. Later I had another idea, so I went ahead and tried out the official driver available in jocky ( proprietary drivers) tool. And after installing that one, I did get a desktop, but the brightness handles were gone. After searching for a while and not finding anything anywhere, I again reverted to open source driver. Thankfully that one works okay with my brightness

Script for maintaining brightness on Lenovo G405

I observed that the this AMD A4 powered laptop has two backlight classes names idepad and radeon-bl0. Pressing the brightness keys changes brightness values in idepad class while values in radeon-bl0 needs to be changed. So I wrote a script which will keep the two files in sync and help me get the brightness working. syncBrightness.sh #!/bin/bash # Script to sync brightness from sys/classes/idepad to /sys/classes/radeon-bl0 # Task: run in a loop executed every second,  modify radeon  brightness acccording to ideapad brightness # ideapad brightness from 1 to 16 in steps of 1; # Radeon brightness 1 to 255 in steps of 1; while [ 1 -eq 1 ] do IBRIGHTNESS=`cat /sys/class/backlight/ideapad/brightness` if [ $IBRIGHTNESS -le 1 ] then IBRIGHTNESS=1 fi echo "Ideapad Brightness: $IBRIGHTNESS" let RBRIGHTNESS=$IBRIGHTNESS*16-1 echo "Radeon Brightness to be set: $RBRIGHTNESS" echo $RBRIGHTNESS>/sys/class/backlight/radeon_bl0/brightness sleep 1 done

Enum to String and vice versa - Enum.Parse alternative for C++

Image
Original Article Link: http://www.codeproject.com/Articles/42035/Enum-to-String-and-Vice-Versa-in-C Update: Link to Source . Introduction   While adding Serialization support to my project, I realized that I would require some way to convert a string to an enumerator and vice versa. So I did a Google search for the same, and found a lot of information; different ways in which people implemented this functionality. However, all the solutions I found suffered from one or more of the following: No support for enumerators with non-contiguous values No support (not even partial support) for enumerators with duplicate values No support for existing enumerations (without modifying their source code) Requires one or more extra files per enumeration Requires source-code to be pre-processed (by a custom binary) before compilation Difficult to use or maintain Highly susceptible to typos Is platform/compiler specific (not portable) So (the rip-off that I am), I borrowed th

The death of my Laptop

Sometimes things are going as usual and all of a sudden something fails. And as it happens usually the failure is unanticipated. And then starts thee scrambling phase where you start looking for alternatives. And ways to overcome this loss. And maybe if you are like me, you start to analyse the failure and try to understand where you failed. So to start with, my laptop died last week. It was working fine and as it happens with all electronics, it just stopped. It wouldn't start. So I sent it to a nearby repair guy, who told me that the power circuit is dead. He will try replacing the burnt IC's. Few days later I rang him up for updates and he said that the main board is dead. The replacement IC's also burned up. And so my laptop was gone to death, since I don't think there's any way to get a replacement board since the system was four year old. Anyway, coming back to the analysis, I assumed that the system will continue to work. So I never made any plans for fail

Current ROM on Zte Blade C

Image
Its names Rigor Stock. Its not as fast as SlimDroid ROM. But it works out well. I recently recalibrated the battery too. And have found it to be charging and discharging well. The app I used for battery calibration is BatteryCalibration available from Play store.

MIUI v5.2 ROM for ZTE Blade C (v807C)

Image
The MIUI ROM is heavy. I noticed severe slowing down in places. I did not use it for more than a few days though. So it could be that cleaning up the system a bit, might have helped. The MIUI looks great, is pleasure to use with great looks, features and a similarity everywhere. But its far too removed from the android experience. Sadly not my cup of tea right now! Link on needrom: http://www.needrom.com/download/miui-os-for-v889s-v807/

Slim Droid ROM on ZTE Blade C (v807c)

Image
This ROM is fastest of the few I tried out. Its really slimmed down, is fast and pleasant to use. The two main problem I noticed were lack of 3G and broken battery charge monitor. The lack of 3G was not much hindrance for me, but the broken battery monitor meant I could not use this ROM. Link to ROM on needrom.com:  http://www.needrom.com/download/slimdroid-mod-v889sv807/

Flashing TWRP recovery on zte blade c (v807)

Edit: Links to software added VRoot 1.7.3.4863 (ENG)(6.9MB) TWRP Recovery (IMG)(5.8MB) Scatter file for ZTE Blade C (V807C) (382B) SP Flash Tool 3.1304.0.119 (6.7MB) Misc.: MTK Droid Tools 2.5.3 (11.9MB) ZTE Blade C Root and Recovery Folder (34.2MB) ZTE Blade C TWRP Recovery Flashing Video (Russian) (41.9MB)  My readme file with experience using the above russian video STOCK Rom ZTE Blade C (V807C) - Flashable by SP Flash Tool (280.1MB)   Wanted to flash TWRP recovery on my ZTE Blade C (v807c). After looking here n there, I stumbled onto a video by a Russian guy who showed how to do it. I got the idea of it all. And so I proceeded. Following the video, I got familiar with the process which is as follows: 1. Get the device rooted: using vroot the zte v807c was easily rooted. 2. Then install twrp recovery: In the video the operator performs following steps: a. Install the zte usb drivers from ZTE v807\Drivers for ZTE. b. Install the mtk drivers from ZTE v807\Drive

A tryst with message queues Pt. 4

So far... I have installed RabbitMQ server on my development machine and using it to test my development code. I have STOMP_SEND working fine. Using the management web console for RabbitMQ I can see the messages being queued. Now I have to read the sent messages. And here I stumbled into a situation where libstomp's stomp_read function was failing. So now going ahead, I integrated the message sending code into the product. The requirement was simple. We had to send a fixed message to a queue with time stamp every two mins. So I put together a thread and put the message sending logic into it. After testing it, I started work on the read part. The requirement was simple. The product has to read some messages from a queue and display them to user. Thankfully one of the system guys fixed libstomp ( saving me some efforts :D ), and made the stomp_read working again. So after putting together a test application to read from the queue, I ended up with a no of problems. First o

A tryst with Message Queues Pt. 3

So once I have called it quits on the R&D, I started work on the integration thing. The problem has grown tenfold by now. The powers that be want to do a lot of messaging stuff and its become a list of at least half a dozen changes where messages are to be introduced. Now, there's another angle. I am serving notice period, the recruitment people are having hard time finding a replacement and its my last three weeks here. I should be doing the handover. Shouldn't be working on these new features - especially things as complex and less understood as this STOMP stuff. But what can you do when the powers that be want to push in code without worrying about the future of that code. So I sat silently on this wet and cold Monday morning, trying to figure out the integration strategy. Yeah, the code is all C code, so better to keep it all together. Means a single function which connects to server, sends the message and disconnects. What can I pass? We need to fetch in settings f

A tryst with Message Queues Pt. 2

So far... I'm sending data to a RabbitMQ broker as messages. These messages get queued up in a user configurable queue. Supposedly a consumer is going to process these. But the consumer is out of my view. Doesn't matter. Now there came a feature of receiving notifications from the consumer or some other system. So after some discussion, the powers to be decided that we are going to have a notification queue which the client has to read. And from it we get the notifications to be read. Now the shady part of business was I had no idea what the hell is going on the inside of libStomp. So I ask politely that I don't have any read code. And I get handed over a single stomp_read code snippet. (In whiny voice) They said it works!!! But it doesn't!!! I tried so hard!!! Damn!!! So I looked into the protocol to understand why the hell I am no getting anything. After reading the protocol, I came to know that the implementation is fucked up in ways more than a few. First

A tryst with Message Queues Pt. 1

I need to give some background for this situation. Its like this: we have a client server product. The server is written in .net and performs analysis on raw data collected from a number of clients and prepares various reports. The client software is written in c++/Qt and it interacts with various hardware controllers/ sensors to get the raw data. There is a sync program written in .net that runs on the server and it pulls data from all the clients. The data is saved in servers PostgreSQL database for later processing. Now, the powers to be decided that we need to remove this syncing program ( because it sunk the data into oblivion sometimes! :D ). So what's the replacement? Well, they decided on RabbitMQ as the queuing solution and decided that the clients would sync their own data to the queue and from there it will be fetched by the server. So we as clients needed to have this functionality in our application. But after looking at the complexity of our own client, we

Custom ROMs for ZTE Blade C (v807/889) and caution for flashers

www.needrom.com has a collection of ROMs for this phone. The things to remember are: 1. Always backup the existing stuff! 2. Ensure that phone battery is more than 70% and the computer laptop you are trying out the procedure from has sufficient backup power. 3. Ensure that whatever ROM files you get from the net are from reputed sources and are tested previously by multiple person. Flashing incompatible ROM will brick your phone. So big word of caution here. 4. Also don't forget to check MD5SUM/SHASUM of the file to ensure that your downloaded file is fine and not corrupted. Flashing a custom ROM is dangerous if you are not careful!

Rooting zte blade c

Image
Zte Blade c (v807/v889) can be rooted by using vroot application. This is a windows program, so you need a windows PC for this. You can follow this process: Enable USB debugging mode on phone and connect to PC. You need to install USB drivers. You can get these from the phone itself. When you connect the phone to PC, you get an option in notifications about connection type. Here if you select CD-Rom, then a mounted CD-Rom appears in your computer which contains the drivers. Otherwise you have to search on the internet to get the debug drivers. Once the drivers are installed, you will see a MT6513 device in system tray. Now start vroot, and wait for it to detect the phone. Once phone is detected, clicking on 'root' button will start the rooting procedure. After files are copied to the phone, it will restart the phone and rooting will continue. Afterwards phone will restart again and load android. You will see a Superuser app in app drawer. If you open root checke

Upgraded a Lenovo A1000-T tablet

Image
This tablet belonged to one of my relatives and I took it with me for updating the apps on my home WiFi. Once it was connected, I started updating the apps one by one. Then in between the updates, a notification popped. This was about a system update availability. I was frankly intrigued. Seeing an android update. So i stopped app updating and instead went for the update. It was ~92MB and took some time to download. Then another dialog popped up asking me if i wanted to update now or after some time like 30mins, 90mins. I selected to update now. The tablet rebooted and updated. After it was done, it rebooted. Once we were connected to WiFi, another update popped up. This one saying it was memory related and it will wipe out all user data. So I went through and checked the partitioning. So it had a 512 MB system partition and 2GB internal partition. Ok. So I went through that update. Now after some time in getting the user account set up, I'm running through so many apps install, bu

Thoughts on ZTE Blade C after a fortnight

So I am using the ZTE Blade C as my daily driver now. It's almost a fortnight since I started using it. The main point for me to go for this one instead the latest crop of cheap chinese kitkat phones from Micromax/Karbonn/Xolo etc or Moto E was the price it was offered. The price was INR4000 i.e. ~$68. Thats dirt cheap. And whatever features it provided are more than enough for me. When compared to my previous android phone - Karbonn S1 Titanium - INR7600 /~$127, the blade c actually shines. The Karbonn handset had following shortcomings: 1. It's touch response was sub par. The capacitive keys were terrible. Plus it's touchscreen used to go crazy when it was charging. Also there was a bad touch spot which made typing slightly painful. 2. The 5MP/720p camera was average, even though it was touted as a main feature. 3. It's chipset is Qualcomm S4 play - not the best when it comes to power consumption. And it's couple generations old by the time I got the phone.

[Benchmark] zte blade c scores (antutu, real pi and CPU prime)

Image
Here are some more benchmark scores

[Benchmark] Zte blade c benchmark scores (nenamark2 and geekbench3)

Image
These are scores in nenamark 2 and geekbench

[Android] Finally shifting to Android from WP7.8

Image
I have been a WP user for last two and half years. The samsung omnia was my first smartphone and it has been wonderful hardware so far. Even after so many years of rough use the phone still feels solid in hands. And the software has been great too. But all software ages. And so has the old WP7. Mind you, its still has the performance. The UI smoothness is there, the OS is responsive as ever. The hardware is solid, the phone has not rebooted of its own accord. And whatever features it provides it excels at them. For me though the first blow was losing gmail support after upgrading to WP7.8. And recently Whatsapp outage was something else I could say was most significant for me to start considering something else. But the problem was I had sunk almost INR16,000 in this one back then. Thats about $320 back then. And right now I am weary of sinking so much hard earned dough into a smartphone. But thankfully the smartphone prices have also come down dramatically. I was looking for a kil

[Apache] Setting up virtual hosts on Apache for Linux

Doing this by following official documentation is more confusing.  I looked up many places and tried many combinations and finally foll. worked for me.  Task: Keep your current apache localhost server alive and add a new site1.local server that has DocumentRoot at /home/vaibhav/mysite 1. Edit /etc/apache2/httpd.conf and add foll lines:  NameVirtualHost 127.0.0.1    DocumentRoot "/var/www"    ServerName localhost    DocumentRoot "/home/vaibhav/mysite"    ServerName site1.local 2. Next edit /etc/hosts file and add foll line:  127.0.0.1    site1.local 3. Now restart apache server as :  sudo /etc/init.d/apache2 restart 4. Check out your virtual site as :  http://site1.local/

[Qt] Random background color palette

this->setPalette(QPalette(QColor(rand()%255,rand()%255,rand()%255)));

[Remembrance] Samsung Omnia W Battery model no

samsung omnia battery model EB484659VU 1500mAh - Gives about eight hour backup for average use scenario.

Qt app porting to Android

Part 1 development environment 1. Get MinGW gcc, android SDK, android NDK, jdk, ant, Qt android 5.2(latest at the time of writing this) Add paths to android sdk/bin, sdk/tools, ndk/bin, jdk/bin, ant main dir to PATH. Also define JAVA_HOME to jdk dir. 2. Run android SDK manager, get revision 16, with arm image. 3.  Install Qt android, 4. Create AVD's, check if abi is shown as default/something. This default/ was added in latest revision of sdk, this causes built apps to not run in created AVD. on the net there are tools v22.3 available which will let us create AVD with plain armeabi without default/ prefix. There was a patch for Qt creator which should be available in qt-andrroid 5.3 onwards. 5. Start porting. Open pro file. And go to projects. Disable shadow build. Use correct kit. Try to build/ run it. 6. If your project links against any external lib, you are needed to do following steps. A. Build that lib using Qt-android's provided toolchain for arm. Next use Add library op

[Windows][Drivers] Install unsigned device drivers on Windows 8

Win8 enforces driver signatures by default. If you have a Win7 driver that worked OK, I suggest the following to disable driver signature enforcement: From the Metro or Desktop Bring up Charms by mouseing over to the right of the screen Go to Settings More PC Settings General Advanced Startup > Restart Now Trouble shoot Advanced options Windows startup options Restart Click on 'Disable driver signature enforcement Reboot Install the relevant driver, allowing the non signed driver to install. This has worked OK for me installing various old printer drivers. Just make sure you know the provenance of the driver being installed, as always.

[Qt][Android] In my wildest dreams...(Qt Application on Android)

Yeah! I never thought I would professionally develop for Android! But the powers that pay me, have decided to port our product on to Android and so being the sole person available as of this moment I have been tasked with this enormous task! Hell, I have even got a time line for this! 15 Days! Now, I did visited the washroom afterwards and laughed my arse off!!! Some statistics for the task: Approx 17000 LoC C++ STL/Qt 4-5 shared libraries being used by the project Cross-platform code (Written for Win/Lin as main platforms) PostgreSQL database being used To top it all, the code has never been reviewed, forget about a proper audit. I have worked on parts and I have done my best to clean up about 4000LoC but remaining all is three-four year old crap that would give me nightmares if I dipped my toes in it... Suddenly life has become a war for survival...:D

[Qt] Compiling Qt5.2.1 on Windows 8/VS 2013

Qt5. It's a miasma. It's a beast for me. It's something mysterious. I don't know if I should love Qt5 or hate it. And I think that summarizes my thoughts about Qt5. I first stumbled across the fifth iteration when some functionality in the product I was working on couldn't be done in existing Qt version (4.5.3 btw). So after looking around for the Oracle, I came to know that the functionality can be achieved by moving to Qt5. Now our development platform (WinXP/CentOS 5.3/ Qt 4.5.3) was getting a bit too old. And it was all quite buggy to boot. So we decided to embark on the adventure of upgrading the base. Took us two months to upgrade the Linux side to CentOS6.3/ Qt5.0.1 and port the product to new Qt. But after that other high priority work kept us busy and we never got to get the Windows side up to speed. But then came the fateful day two weeks ago when our IT Manager announced the upgradation of all our faithful old XP systems into Windows 8. And th

[Thoughts] Senn HD 439 vs Panasonic ht515

Songs tested against on Samsung Omnia W Bezuban from abcd gangnam style Sun raha hain - female  from Aashiqui 2 Saajna from I, me aur main Teri jhuki nazar - murder 3 Let me call Panasonic p and sennheiser s. P sounds good, but not excellent. It had reasonable amount of bass and the soundstage is good. The sound is on the warmer side. And if you haven't heard s then you might think p is great. Yeah its that good. Now when you plug in s, the first thing you notice id that the highs are much more perfected on s. The bells and thrums of guitar sound fuller. The bass gets punchier. The sound experience becomes better by about 35%. And that's that straight forward difference you hear. P are not bad headphones. In fact these used to retail at about 30% price of s's. And so these are excellent value for money. The pair I have is about five years old and even though it looks totally plasticky it has held through rough use. The cable is strong and doesn't have slightest cable no

[Qt] Compiling ICU with MSVC (Microsoft Visual Studio)

Link to original article: http://qt-project.org/wiki/Compiling-ICU-with-MSVC Text highlighted and notes added Compiling ICU with MSVC (Microsoft Visual Studio)     Qt 5 / QtWebkit requires ICU.         Pre-built packages     The ICU Project site [ site.icu-project.org ] provides pre-built packages for MSVC 2010, which should work with compilers too. Anyhow, you have to compile your own version if you want to avoid the MSVC 2010 runtime dependency (because you’re using another MSVC version), or want to tailor the ICU configuration.     download.qt-project.org [ download.qt-project.org ] also hosts packages for MSVC 2012 .        

[PostgreSQL] Server fails to start on Windows 8

Recently stumbled on this problem. We have just upgraded all systems to Windows 8 in my office. The newly installed PostgreSQL was not starting. In PGAdminIII it would ask for password. But fail to proceed further. On going through logs I came to see this error: 2014-04-08 15:00:10 IST FATAL:  no pg_hba.conf entry for host "::1", user "postgres", database "postgres", SSL off So after un-commenting the line for IPv6 in pg_hba.conf, and restarting the server, it all started working fine. The line is : host     all     all     ::1/128     md5 Interesting point is it used to work fine on Win XP. Maybe Windows 8 has some special handling for IPv6. Don't know.

Using QML with C++

Source code  here Original article:  http://www.ics.com/blog/integrating-c-qml Recently I stumbled onto an example where the front end of a small application was written in QML and the backend was done in C++. That was the exact thing I was searching for and it provided a great example of how to get QML and C++ working together. Lets start with the qml:  //-------------------------------------------------------------------------- // SSH key generator UI import QtQuick 2.1 import QtQuick.Controls 1.0 import QtQuick.Layouts 1.0 import QtQuick.Dialogs 1.0 import com.ics.demo 1.0

Moto G USB OTG

Image
Works with USB drive

Retired

Image
Sent from my Windows Phone

Doesn't work

Image

A tale of specificity

Image
I try to be perfect. And I don't feel right till I have finished something completely. So this following tale relates to the relation of specificity and perfection.  The current project I am working on has a list of lineEdits that I have put into a scrollarea.    This image shows what I was out to achieve.  First task was to get the scrollarea right. There I encountered first hurdle. See, the thing is the scrolled widget has a fixed size but here the size changes depending on the no of lineEdits added to the scroll Area. At first I settled on a fixed size and put in a spacer. But it wasn't perfect. There were some edge cases where that failed. So after a lot of thinking I settled on a minimum size, and set size constraint to SetMinimumSize. Later when I added one widget I would increase minimum size and this proved to be a good solution. Next step was to increase scrollbar width for use on touch screen. I hunted some CSS on net that let me increase the scrollbar width and

Another QScrollBar style

Image
Stumbled onto this nice QScrollBar style: QString styleString="QScrollBar:vertical {"     "    border: 1px solid #999999;"     "    background:white;"     "    width:30px;    "     "    margin: 0px 0px 0px 0px;"     "}"     "QScrollBar::handle:vertical {"     "    background: qlineargradient(x1:0, y1:0, x2:1, y2:0,"     "    stop: 0  rgb(32, 47, 130), stop: 0.5 rgb(32, 47, 130),  stop:1 rgb(32, 47, 130));"     "    min-height: 0px;"     ""     "}"     "QScrollBar::add-line:vertical {"     "    background: qlineargradient(x1:0, y1:0, x2:1, y2:0,"     "    stop: 0  rgb(32, 47, 130), stop: 0.5 rgb(32, 47, 130),  stop:1 rgb(32, 47, 130));"     "    height: 0px;"     "    subcontrol-position: bottom;"     "    subcontrol-origin: margin;"     "}"     "QScrollBar::sub-line:vertical {"  

Building Qt5 on CentOS 6.3

I am using following method to build Qt5 on CentOS6.3. Make two dir's. Extract Qt source in source dir. Keep following script in home dir. Execute it from there. Also go through configure, make and make install phases one-by-one. #!/bin/sh export QTBUILD=/home/user/qtsource/qt-everywhere-opensource-build-5.0.2 export QTSOURCE=/home/user/qtsource/qt-everywhere-opensource-src-5.0.2 cd $QTBUILD $QTSOURCE/configure -opensource -confirm-license -qt-sql-psql -platform linux-g++ -prefix /opt/Qt-5.0.2 -nomake examples -nomake tests -no-gtkstyle #make -j4 all #make install cd -

A tangle with shared memory

Code: https://drive.google.com/file/d/0BxorjNRCBW61Ri1ib3ZLa2t6Tk0/edit?usp=sharing Recently I was thinking about inter-process communication and especially how to pass/ share data/ information between two running applications. The thing was, I wanted to check out inter-process communication interfaces and see if there was anything Qt provided that I could use.  My requirement is not finalized or anything. The rough idea is to have a channel of communication between two apps. Here my thoughts diverge a bit in that, I am yet not sure of the method of communication. There are two approaches:  1. The message system should be a message board where many processes post messages for each other and periodically access the boards to check out their messages. 2. The message system should be P2P. One process sends a message to another and that message (preferably named) makes other process do something like maybe send an acknowledgement.  Now after digging through the various approaches,