Monday, February 23, 2015

How to apply patch in git

check logs
git log --pretty=oneline -3

git format-patch <patch number > master

git format-patch commitStart^..commitLatest --stdout > test.patch

git format-patch HEAD~


git apply --check <patch name>

git apply --reject --ignore-whitespace <patch name>


Saturday, February 21, 2015

enabling moto g for ubuntu debugging

1. tap 7 time on build number

2. use sudo to start adb sever

use android rules

  1. Log in as root and create this file: /etc/udev/rules.d/51-android.rules.
    Use this format to add each vendor to the file:
    SUBSYSTEM=="usb", ATTR{idVendor}=="0bb4", MODE="0666", GROUP="plugdev"

    In this example, the vendor ID is for HTC. The MODE assignment specifies read/write permissions, and GROUPdefines which Unix group owns the device node.
    Note: The rule syntax may vary slightly depending on your environment. Consult the udev documentation for your system as needed. For an overview of rule syntax, see this guide to writing udev rules.
  2. Now execute:
    chmod a+r /etc/udev/rules.d/51-android.rules

Wednesday, February 18, 2015

handling back on notification activities

below is right thing to do:
You need to add the parent stack for the activity you're launching, not the parent of it.
Replace:
stackBuilder.addParentStack(MainActivity.class);
with:
stackBuilder.addParentStack( MatchActivity.class );
This assumes that you've defined the parent in your Manifest (API 16+):
<activity android:name=".MatchActivity"
    android:parentActivityName=".MainActivity"
    ... />

Saturday, February 14, 2015

Nodejs and async handling

below is great blog about it:

http://www.sebastianseilund.com/nodejs-async-in-practice


gearman and node.js

install

npm install node-gearman

https://www.npmjs.com/package/gearmanode

worker code example:


var nodejspath='/var/www/node_js/node_modules';
var gearmanode = require(nodejspath+'/gearmanode');
var worker = gearmanode.worker();

worker.addFunction('gcm_ca_nodejs', function (job) {
    console.log("got input as "+job.payload.toString());
    job.workComplete("done");
});


learn node.js

http://nodeschool.io/#workshoppers

install globally:

npm -g install <>


export NODE_PATH='/usr/loca/lib/node_modules'


including other javascript files

module.exports = {
  foo: function () {
    // whatever
  },
  bar: function () {
    // whatever
  }
};

using sqlite as gearman persistent queue

create sqlite db
sqlite3 gear-queue.db

CREATE TABLE gearman_queue(unique_key TEXT PRIMARY KEY,function_name TEXT,when_to_run INTEGER,priority INTEGER,data BLOB);

vi /etc/default/gearman-job-server

params="gearmand -q libsqlite3 --libsqlite3-db=/tmp/xx.sqlite"

setup gearman monitor

install https://github.com/yugene/Gearman-Monitor

2. install pear package

sudo pear install Net_Gearman-0.2.3

Thursday, February 12, 2015

Wednesday, February 11, 2015

Getting started with Windows Azure tools on Ubuntu

1. install npm

sudo apt-get install nodejs-legacy


2, install azure cli tools through

sudo npm install azure-cli -g

Tuesday, February 10, 2015

enable ssl on apache2

sudo a2ensite default-ssl
sudo a2enmod ssl

create below dir:
/etc/apach2/ssl.crt
/etc/apache2/ssl.key
/etc/apache2/ca-bundle

ssl.key should be from CSR


remove pass phrase


/path/to/openssl rsa -in /path/to/originalkeywithpass.key -out /path/to/newkeywithnopass.key

write way to handle non-www to www migration in apache

add below lines in vhost conf:

  RewriteEngine on
        RewriteCond %{HTTP_HOST} !^www\.
        RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

Friday, February 6, 2015

running amazon cli cron jobs

SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
AWS_CONFIG_FILE="/home/ubuntu/.aws/config"
36 7 * * * sh /var/www//scripts/amz-stop.sh >/home/ubuntu/logs/amz-stop.log 2>&1
5 7 * * * sh /var/www//scripts/amz-launch.sh >/home/ubuntu/logs/amz-start.log
2>&1

Hosting s3 files

use CNAME to host s3.

Name of bucket should be same as CNAME

http://download.onlinetyari.com ==> http://download.onlinetyari.com.s3.amazonaws.com 

Wednesday, February 4, 2015

S3FS and git together

use below to forcefully write in git

git fetch 
git reset --hard origin/master

Tuesday, February 3, 2015

Useful mysql debugging commands

Total tables:
SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE='BASE TABLE';
show global status  like 'open%';
SHOW VARIABLES LIKE '%max%'