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 throws:"Some application" can not be installed. Try again, and if the problem continues, get help troubleshooting. (Error code: -505)Troubleshooting did not help me, in product forums they only recommended cleaning up cache of google play store app etc. But this problem is not related to neither your phone nor your play store application. It persists in different operating systems and different phone models. What you need to do is simple, follow...

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="text/rocketscript"> var disqus_shortname = 'YOUR_USERNAME'; var disqus_identifier = '/jekyll/2015/08/24/jekyll-disqus-same-comment-everywhere/'; var disqus_url = '\{\{ site.url \}\}\{\{ page.url \}\}'; var disqus_title = '\{\{ page.title \}\}'; var disqus_category_id = '\{\{ post.category \}\}';Trick is assigning a unique identifier to the disqus_identifier javascript variable. In our case page.url is pretty unique. And also we are not s...

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 Crashes with Appcompat v7 on API 19 and lower] Apps with Over 65K Methods am I still getting java.lang.NoClassDefFoundError:

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 will create _posts folder and _draft folder.Play with the settings vim _config.yml permalink: pretty paginate: 10 paginate_path: "/page/page:num/"Add paginationI have ~400 posts so need to paginate in order to show in the main page.Used this recepi: To create a new post you can use github’s UI and preview mode which is cool but not as cool as Ghost of course.

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 & upgrade packagessudo apt-get updatesudo apt-get upgradeClean up packages for saving up disk spacesudo apt-get cleanScan the local network for connected devices with IPs.sudo apt-get install nmapsudo nmap -sP setup toolssudo apt-get install python-setuptoolssudo easy_install web.pySSH into a remote computerssh [email protected] both standart output and error into a fileUseful for logs./some_binary >> logs.txt 2>...

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 :-/Uses bluetooth 4.0 which is Bluetooth Low Energy(LE).It has smart alarm which is based on your sleep pattern. Haven’t tried it yet.ConsI don’t like the design of the app but it just works, shows the stats, doesn’t crash.I don’t like lack of integration with other apps like Google Fit, Fitbit, Withings etc. Maybe in the future?It has 3-led indicator which shows if you reached your daily target (one led means 1/3 of your target, obviously). However, t...

subscribe via RSS