Wednesday, February 19, 2020

.htaccess display error pages on http errors


In your htaccess file add the below lines and save to show error pages on Http errors (404, 403 etc)
ErrorDocument 403 /errors/404.html
ErrorDocument 404 /errors/404.html

Here, errors is the folder where you can keep your Http error pages .

If the requested resource doesn't exist, default to index.html
RewriteRule ^ /index.html

Monday, October 1, 2018

Useful Git commands


To reset your master branch
git reset --hard origin/master
To remove directory
git clean -d -f
To know the repository url
git remote show origin
To remove unused branch from local
git remote prune origin prunes tracking branches not on the remote.
git branch --merged // lists branches that have been merged into the current branch.
xargs git branch -d //Deletes branches listed on standard input.
##Be careful deleting branches listed by git branch --merged. The list could include master or other branches you'd prefer not to delete.
To give yourself the opportunity to edit the list before deleting branches, you could do the following in one line:
git branch --merged >/tmp/merged-branches && vi /tmp/merged-branches && xargs git branch -d

Monday, July 9, 2018

Resolve Git bash Error: Could not fork child process: There are no available terminals (-1)


This can be a result of the GIt bash not been terminated properly in most of the cases node.exe is the culprit.
The solution would be to run the below command in cmd. taskkill /F /IM node.exe

Friday, January 19, 2018

How to kill a process listening to a port say "8080"


I have often encountered this issue while trying to run tomcat on port 8080. I get an error saying that the port is already being used by another process.
Below is the command that I used to kill that process:-
Step 1 : Find the process that is using this port.
netstat -ano | find "8080"
This command searches for the process listening to the port 8080.
Step 2 : Kill the process
I found that in my case the process with PID 22300 is listening to the 8080 port.
To kill this process use taskkill /PID 22300 /F

Tuesday, June 16, 2015

Android Face detection using FaceDetector


FaceDetector is a class provided by the android sdk.
It identifies the faces of people in a Bitmap graphic object.
For reference view Android Devloper.

Here I will be showing how to use this using the below code snippet.

/* img_btmp is the bitmap with or without faces. Note the width of the img_btmp should be even*/
FaceDetector detector = new FaceDetector(img_btmp.getWidth(), img_btmp.getHeight(), 10);

Face[] faces =  new Face[10];

// faces is the array where the detected faces will be stores
int face_detected_count=detector.findFaces(img_btmp, faces);

This doesn't seems to work well but still it can be used .It still needs further more development


Python: INSTALL pycharm in ubuntu

pycharm is a good editor tool for python.It comes in 2 edition

1.Community edition (Free!!)
2.Professional edition (that you can purchase).

STEPS TO INSTALL:

Step1: First of all pycharm needs JVM (Which is obvious) .You can check this as follows

ab@Boxx:~$ java –version

If you are not able to find any java versions just run the below command

sudo apt-get update
sudo apt-get install openjdk-6-jre-headless

Step 2: Now lets install pycharm

//create a folder in opt
mkdir -p ~/opt/packages/pycharm 
//Navigate to that folder
cd ~/opt/packages/pycharm
//Download the archive file of pycharm
wget http://download.jetbrains.com/python/pycharm-community-4.0.4.tar.gz
//Extract the file
gzip -dc pycharm-community-4.0.4.tar.gz | tar xf -
//Install
ln -s ~/opt/packages/pycharm/pycharm-community-4.0.4 ~/opt/pycharm
DONE! Now open pycharm using
~/opt/pycharm/bin/pycharm.sh

Thursday, June 27, 2013

Android: Send SMS tutorial

Step 1: Add permission
<uses-permission android:name="android.permission.SEND_SMS" />
 
Step2: Import the package
import android.telephony.SmsManager;
Step3: code
String phoneNumber = "1234567890";
    String message = "SMS content not more that 160!";
    SmsManager smsManager = SmsManager.getDefault();
    smsManager.sendTextMessage(phoneNumber, null, message, null, null);
           

.htaccess display error pages on http errors

In your htaccess file add the below lines and save to show error pages on Http errors (404, 403 etc) ErrorDocument 403 /errors/404.html ...