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 http://yourblog.com/ghost/debug 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 Engine:appcfg.py 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.https://cloud.google.com/logging/docs/install/logs_export And second alternative you can analyze logs by piping them into BigQuery.https://console.developers.google.com/project/_/logs

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:http://imgur.com/a/1hAKSBtw, 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...

Oneplus One screen replacement tips


After disassembling and assembling my opo like 30 times, I feel competent to write this post.I bought the screen from AliExpress and chose DHL and it arrived in less than 1 week. There is also a small toolkit for screen replacement operation. I don’t like the idea of heating up the screen and separating it from the mid frame, I bought the screen with the middle frame. Slightly more expensive but definitely recommended. Plus be careful about the earpiece grill. Some of the screens on sale on aliexpress don’t have earpiece speaker grill.I’m no...

Small Google App Engine gotchas


Working with GAE is sometimes tough in the beginning. GQL queries must not have “ in it. Instead ‘ single quotation must be used. GQL does not have LIKE You can not put the fields which are not indexed into the WHERE statement.Adding the field into index.yaml is not enough, you need to explicitly say it in the Model definition:class Event(ndb.Model):title = ndb.TextProperty()date = ndb.DateTimeProperty(auto_now_add=True)event_date = ndb.TextProperty(indexed=True) Plus it still may not work, the index needs to be built. In local just rewr...

Scraping web with python and selenium


A couple of weeks ago, I had a need to parse some parts of some web page. It was a page whose main content is loaded after finishing the GET request to the page. This means that python’s urllib, urllib2 and requests packages will fail to download the exact same source as your Chrome renders when you reach the site via browser (not programmatically). Because url libraries usually return the content after GET request finishes, they don’t wait until all of the ajax calls finish. This causes discrepancy between fetched code and rendered code. In...

Some handy Android code snippets


Email Validationpublic static boolean validateEmail(String email) { return android.util.Patterns.EMAIL_ADDRESS.matcher(email).matches();}Share ButtonIntent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);sharingIntent.setType("text/plain");Resources res = activity.getResources();String shareSubject = res.getString(R.string.share_subject);String shareVia = res.getString(R.string.share_via);String shareBody = res.getString(R.string.share_body) + shareAdditional;sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, ...

How to update nodejs on Ubuntu (Debian)


Thanks StackOverflow!First method: Through NPM sudo npm cache clean -f sudo npm install -g n sudo n stable node -vSecond method: Through NVM curl https://raw.github.com/creationix/nvm/master/install.sh | sh source ~/.profile nvm install 0.10.26 nvm use v0.10.26 which node node -v install node globally (ie, into /usr/local)n=$(which node);n=${n%/bin/node}; chmod -R 755 $n/bin/*; sudo cp -r $n/{bin,lib,share} /usr/local


subscribe via RSS