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 & 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 192.168.0.0/24Python 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: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 :-/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...

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 not going to walk through how to disassemble opo because there are enough posts about it. My favorite one is iFixit’s teardownProblems with Cellular signalI first replaced everything, well I thought I replaced everything to the new body, my phone was working great, touch screen was working, my ghost swipes were gone; however, the cellular signal was so bad. It was coming and going. Especially inside the buildings it was totally lost. I opened the p...

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 rewrite the data. Otherwise it’s not gonna work. While mapping the urls don’t put get parameters in the url structure. Only put the parameters by / - get params might be unlimited and their order can change. It’s fine to map them in variations. To save bandwidth use infinite expiration date for css by defining in app.yaml create an endpoint for pinging the app to prevent idle sleeps of machine in order to save up bandwidth. down notifier is good ...

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 my case, I needed the rendered code. After long investigation and asking out in StackOverflow (nobody replied and question is deleted), I ended up using Selenium to emulate normal browser behaviour. It was kinda hard for me because I need async flash content and firefox driver (default driver) of Selenium is not capable of rendering flash content. I switched to Chrome driver. This step just made things harder.Prereqs Install PhantomJS sudo eas...

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, shareSubject);sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareBody); activity.startActivity(Intent.createChooser(sharingIntent, shareVia));Show Simple Popup - AlertDialogprivate void showPopup() { AlertDialog alertDialog = new AlertDialog.Builder(getActivity()).create(); alertDialog.setTitle("Title"); alertDialog.setMessage("Message"); alertDialog.setButton("OK", new DialogInterface.OnClickListener() { ...

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

Use Google App Engine Applications with Custom Domains for free


I like free. Looked for a good resource to achieve this. However, most of them are outdated and they say that to be able to use GAE apps with custom domain, you need a Google Apps account no you don’t. Plus, if you add your appid.appspot.com to your clouflare connected domain, app engine does not authorize the connection and redirects domain to google.com’s main page. It’s pretty weird but expected. In heroku, it’s really easy to allow custom domains and point them to your appid.herokuapp.com address from cloudflare by using its DNS flattening feature.Ok here are the steps to do that on app engine. Buy a domain, here is my fave Finish your app from Google App Engine Go to new Google Cloud Console, not old app engine console. Choose project and Compute -> App Engine -> Settings -> Custom domains (Yes it’s kinda secret). You will be able to see all of your domains you own from Google Webmaster Tools If your desired domain is already in Google Webmaster Tools, choose the...


subscribe via RSS