Solving Sqlite's python Unicode string problem with non UTF8 data

Error it throws:sqlite3.ProgrammingError: You must not use 8-bit bytestrings unless you use a text_factory that can interpret 8-bit bytestrings (like text_factory = str). It is highly recommended that you instead just switch your application to Unicode strings.Solution was easy; add this line for assigning text_factory. It converts strings into unicode objects.conn = GetSqliteConnection(db_path)conn.text_factory = lambda x: unicode(x, 'utf-8', 'ignore')Thanks to SO again. (PS that post is extremely useful for python encoding/decoding.)


Yet another problem that made me lose 3-4 hours. Well, I usually use the same code across my application, I have my basic scaffolding. It only gets better in time. However, sometimes I forget to change the package names, XML namespace definitions etc while copy/pasting. I thought this is also same problem. But I couldn’t find anything.Surprisingly, this occurs after you submit the application to the play store.While application X is installed, Google Play Store does not let another application with the same provider to get installed.Error it...

Solving Disqus comment problem on Jekyll - same comments everywhere

I have been using Disqus in order to handle blog comments for a long time. I was also using it when I was with Ghost. It’s a great and good looking way to handle comments. It makes your blog more mobile. It has one downside which is that the comment box is iframe so I don’t think it’s good for SEO.Disqus’s own help center: Why are the same comments showing up on multiple pages? JavaScript configuration variables With this light here is my disqus snippet in my jekyll code:<div id="disqus_thread"></div><script type=...

PgAdmin in my face - Ubuntu Bug (or maybe feature?)

Today, PgAdmin is frozen as usual. I’m not blaming it of course, it’s because my Rasberry Pis are so slow, they can not handle some broad SQL queries after some point they become responseless and PgAdmin becomes frozen.Today it happened again; so normal up until now; I went to the Task Manager of Ubuntu to kill that bad boy but see what I saw:IN YOUR FACE

Solving Android "java.lang.NoClassDefFoundError attr" for pre-Lollipop devices

This secret recipe makes your apps work on pre-lollipop devices. You may be developing on Android 5.0+ and you would not realize that your app is breaking at the start for other versions of Android which are lower than Lollipop.Trick is that Apps with lots of dependencies (well they don’t have to a lot but if you have google play services as dependency which is needed for admob, you should apply this method) need multidex enabled for building. Otherwise they work fine on L devices and fails at the startup for pre-L devices.[Android Twitter C...

Migrated my blog from Ghost to Github pages

Thanks to heroku beta pricing. mkdir blog cd blog git init sudo gem install jekyll sudo gem install github-pages sudo gem install bundlerFor development, live refresh etc sudo gem install pygments.rb sudo gem install listenCreate the project jekyll new . jekyll build --watch # Auto reload. Go to http://localhost:4000Import posts from self hosted Ghost blog Go to Export json file with all of your posts. sudo gem install jekyll_ghost_importer jekyll_ghost_importer GhostBackup.json # This w...

Export logs from Google App Engine

Use this command to fetch the application logs from Google App request_logs --num_days=210 --include_all Documents/path/to/your_gae_app/ mylogs.txt --oauth2 Alternatively you can write a handler by using logs API. And second alternative you can analyze logs by piping them into BigQuery.

Getting Geo Location of Web site visitor with javascript

It’s really short javascript code.You can test it in the js console of Chrome or your favorite browser:navigator.geolocation.getCurrentPosition(function(position){ console.log(position.coords.latitude + " | " + position.coords.longitude)});It will print the geo location coordinates in latitude and longitude format. Of course you need to allow when it’s prompted for location permission.

Small bash commands for linux administration

Mostly useful for Ubuntu or debian based operating system.Top 10 largest directoriesdu -a /var | sort -n -r | head -n 10Find largest files on Linuxfind / -size +10M -lsfind / -size +700M -lsTop 10 processes by memoryps aux --sort -rss | headBash check timing time measuretime ls /bintime mongo --eval "db.users.find({})"batch file extension renamer in bashfor file in *.png; do mv "$file" "basename $file .png.jpg"doneCreate bootable disk (usb) from imagesudo dd bs=4M if=/home/$USERNAME/path/to/2014-09-09-wheezy-raspbian.img of=/dev/sddUpdate...

Got a Xiaomi Mi Band

My best spent 15 euro.It’s not that ugly, counts my steps, tracks my sleep, 3 alarms with nice vibrate, solid battery (lasts 1 month), phone call notification, smart lock (my fave) etc etc.This little guy is pretty talented. Plus apparently so durable. One of the redditors made it driven over by multiple cars accidentally and it was still working:, it’s not water proof, it’s water resistant. So it’s ok to take shower with it but don’t do it, it’s rubber.Works with iOS as well. The app looks way better in iOS :-/Use...

subscribe via RSS