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

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 flatteni...

Deploy web.py applications with pip requirements on Heroku


Running and deploying python apps on Heroku is pretty easy. I usually use web.py and Jinja2 templates for a typical web server. Install heroku toolbet Login to heroku heroku login Set the environment variablesheroku config:set PORT=8080 Heroku clone the app from created path.heroku git:clone -a myapp Create Procfile to tell heroku how to run the appgedit Procfile Put this into the Procfile: (Heroku assigns some random port every time it restarts the job so don’t hardcode the port here. It is highly like that heroku will fail...

How I store server logs in Google Spreadsheets


Disclaimer: I’m not an expert in this field. I just want to share my experiences with logs, you are welcome to give some feedback on my method.I like logs, I hate logs. I like analyzing them but I don’t like dealing with backups and everything.I have small sized projects like isimibul (job search engine for Turkey), Football Video Highlights. They have 3k-4k page views (API hits) per day. I would like to analyze some usage statistics like how many msecs it takes to handle a request or which job term is searched the most.At first I was using ...


subscribe via RSS