AWS cli cheatsheet

To describe specific AMI $ aws ec2 describe-images –image-ids ami-5731123e To describe instance $ aws ec2 describe-instances –instance-ids i-1234567890abcdef0 To describe VPCs $ aws ec2 describe-vpcs To describe route tables $ aws ec2 describe-route-tables

Configure php-fpm and nginx to run in low memory server

It was pain in the ass to have php-fpm and nginx together to serve php app, especially when you’re running on low-memory server, especially when you’re running cms like wordpress which basically heavy duty. I had a Centos server running with memory only 1024Mb (1Gb).

My web kept crushed every single time. And the problem stil remains, memory leak.

I don’t know what the root cause was. I still don’t know what that is but I think it’s something to do with php-fpm configuration or even nginx.

Just several days ago I had my blog up and running with wordpress in the same type of server, same OS (Centos) with the same memory (1Gb) and since I didn’t want to use apache for some reason, guess I had to get my nginx and php-fpm working together again.

I thought my web would be running very smoothly since the blog was still unlikely to receive much traffic. But I was wrong, somehow the memory was leaked again. My server only running with 1024Mb, but I thought It didn’t matter. The only way to get this problem mitigated is to tune up both the php-fpm and nginx configurations which I never liked this. But I need this, so let’s get this done.

Read more

Setup Ruby On Rails on Ubuntu 14.04 Trusty Tahr

I’m sick of people who write tutorials which is not clear to install the Rails, too long, too much multiple choice, rambling. This is tutorial that actually works for me. Hope it would work for you too. Install some dependencies first $ sudo apt-get update $ sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev … Read more

How to set static file in django with templateview

Sometimes I got confused whether to set my static file with nginx or just inside the Django. This is how I do it inside urls.py in django app directory. from django.views.generic import TemplateView urlpatterns = { …. url(r’^static\.txt$’, TemplateView.as_view(template_name=’files/static.txt’, content_type=’text/plain’)), …. } and navigate to https://myurl.com/static.txt

Unfollow all your friends on twitter with this simple code

You go to twitter, and select your following and scroll all the way down until it reaches the bottom, you can hold on the Page Down button to be more efficient. If it reaches the bottom of the page, open up the console or if you use chrome, press Ctrl+Shift+J, select console tab, and paste this code: [].slice.call(document.querySelectorAll(‘.unfollow-text’)).forEach(function(button) … Read more

Fix google gms services version conflict

So, this error showed up when I tried to update gms google services for push notifications. Error:Execution failed for task ‘:app:processDebugGoogleServices’. > Please fix the version conflict either by updating the version of the google-services plugin (information about the latest version is available at https://bintray.com/android/android-tools/com.google.gms.google-services/) or updating the version of com.google.android.gms to 9.0.0. Currently, I … Read more

How to check connection in android

This is how to check connection in android whether your phone is connected to the internet or not. put this function inside your public class. private boolean isConnected() { ConnectivityManager connMgr = (ConnectivityManager) getSystemService(Activity.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = connMgr.getActiveNetworkInfo(); if (networkInfo != null && networkInfo.isConnected()) return true; else return false; }  

Git cheatsheet

Ignore permissions git config core.fileMode false list branch git branch rename branch git branch -m <newname> move to another branch git checkout your-branch hard reset branch git reset –hard origin/master create new branch git checkout -b new-branch delete local branch git branch -D your-branch merge from develop to master git merge develop init on existed … Read more