Showing posts with label tips. Show all posts
Showing posts with label tips. Show all posts

Wednesday, August 19, 2015

Tip: Elasticsearch OSX ConnectException

If you downloaded the latest Elasticsearch installation and you are getting the following exception:

org.elasticsearch.common.netty.channel.ConnectTimeoutException: connection timed out:/xyz.def.zzzz:9300
at org.elasticsearch.common.netty.channel.socket.nio.NioClientBoss.processConnectTimeout(NioClientBoss.java:139)
at org.elasticsearch.common.netty.channel.socket.nio.NioClientBoss.process(NioClientBoss.java:83)
at org.elasticsearch.common.netty.channel.socket.nio.AbstractNioSelector.run(AbstractNioSelector.java:337)
at org.elasticsearch.common.netty.channel.socket.nio.NioClientBoss.run(NioClientBoss.java:42)
at org.elasticsearch.common.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:108)
at org.elasticsearch.common.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProofWorker.java:42)



Solution

go to config/elasticsearch.yml

Uncomment the following line
discovery.zen.ping.multicast.enabled: false

Restart Elasticsearch

Tuesday, July 14, 2015

Git Tip: Repository not found

If you get any of the following errors:
GitLab: The project you were looking for could not be found.
Git The Repository not found
Please make sure you have the correct access rights

and the repository exists.

when you do operations such as git clone or git push,
it is possible that your ssh key has not been added with ssh-agent

$ ssh-add
Enter passphrase for /home/name/.ssh/id_rsa: [] Identity added: /home/name/.ssh/id_rsa 

After this, it should hopefully work

Monday, July 21, 2014

Tip: Apache Kafka

If you get the following exception:
$ ./zookeeper-server-start.sh  ../config/zookeeper.properties
Error: Could not find or load main class org.apache.zookeeper.server.quorum.QuorumPeerMain

then you will have to do the following:
$ ./gradlew  jar

to build the Kafka distribution and get the dependencies.

Friday, May 02, 2014

Tip: Linux Determine File Sizes in your home directory


anil@localhost:~$ du -sh * > largefiles

You can then look inside the file largefiles.

Wednesday, April 30, 2014

Tip: IntelliJ IDEA : Do not want unlimited whitespace at the end of each line

File menu -> Settings -> Editor -> Virtual Space and uncheck 'Allow placement of caret after end of line'. 

Also uncheck the other options in the Virtual Space panel.

If you want to remove trailing whitespaces, you can do
File menu-->Settings --> Editor --> Strip Whitespaces on Save   to either "All" or "ModifiedLines".

Tuesday, January 07, 2014

Clean Up Root Partition on Fedora

If you have the following problems:
  • Root partition / is using 100% of allocated disk space
  • Root partition / is close to using 100% of allocated disk space

Then,

$>  sudo yum install bleachbit
$>   su - -c "bleachbit"

Use bleachbit to clean up unwanted files.

Tuesday, December 24, 2013

Copy Video on iPhone without iTunes

If you are in need of copying a home video on to your iPhone and you have lost the computer which has the original iTunes sync, do not despair.

VLC app on ios is there for the rescue.

Official Documentation: https://wiki.videolan.org/Documentation:IOS

Steps


  1. Temporarily turn off the lock feature of your iPhone. You can bring it back after the video upload.
  2. Download VLC player from the App Store. Ensure that the vendor is VideoLan.
  3. Ensure your iphone and computer are connected to the same WIFI.
  4. Open VLC app.
  5. On the top left hand corner, is the hat symbol. Click on hat.
  6. Go to Wiki Upload. Enable the server.  Note down the IP address it provides.
  7. Go to your browser and type in the IP address:  something starting with http:
  8. You will see Fig 1
  9. Click upload files button and choose the video file.
  10. Once the file is uploaded, enjoy the home video. Remember VLC can play many formats : mp3, mp4, m4u etc.
  11. Remember to turn back the locking feature on your iphone.
  12. Fig1: Browser Interface

Friday, August 30, 2013

Tip: Mac OSX: Start IntelliJ with sudo permissions

There may be instances where the code you are developing is binding to a particular port that is lower than 1024. So you will not be able to bind to that port.

You will see something like a SocketException : permission denied.

If you are sure that this is temporary and you are developing on your Apple laptop, then do the following in a terminal window:

$>cd IntelliJ\ IDEA\ 12\ CE.app/Contents/MacOS/
$> sudo ./idea

Now IntelliJ is running with sudo permissions.

WARNING: This is a sensitive operation. Do not try it on Apple based servers or production environments.

Thursday, February 07, 2013

Tip: Hibernate PersistenceException :

If you are seeing the following error "No Persistence provider for EntityManager named" and scratching your brains, ensure that the hibernate-entitymanager.jar is on the classpath.

Also you should have a META-INF/persistence.xml in your jars someplace.

Monday, February 04, 2013

Monday, March 26, 2012

Android Tip: android.view.WindowManager$BadTokenException

If you are using an ActivityGroup to display a series of activities, then you may encounter the infamous BadTokenException.

The location where you are getting the exception, will have a "this" usage for the context.

To get over this error, use "this.getParent()".

Eg:  final ProgressDialog pbarDialog = new ProgressDialog( this.getParent() );
 

Android Tip: Dealing with Droid Spinner Background

Droid seems to have an issue where in the spinner background is white and none of the elements are displayed even though they are available in the spinner.

This error has a workaround at http://stackoverflow.com/questions/4361604/how-to-change-the-spinner-font-color

Wednesday, April 06, 2011

org.jboss.ws.core.jaxws.handler.SOAPMessageContextJAXWS

If you see the following exception:
javax.xml.ws.soap.SOAPFaultException: org.jboss.ws.core.jaxws.handler.SOAPMessageContextJAXWS cannot be cast to javax.xml.rpc.handler.soap.SOAPMessageContext

it means that in your handler class, you are using javax.xml.rpc.handler.soap.SOAPMessageContext
rather than
import javax.xml.ws.handler.soap.SOAPMessageContext

Sunday, March 27, 2011

HttpClient4 FORM authentication example

import org.apache.http.Header;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.StatusLine;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.cookie.Cookie;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.protocol.HTTP;

String URL = "http://localhost:8080/web/secured";


DefaultHttpClient httpclient = new DefaultHttpClient();
try {
HttpGet httpget = new HttpGet(URL);

HttpResponse response = httpclient.execute(httpget);

HttpEntity entity = response.getEntity();
if (entity != null)
entity.consumeContent();

// We should get the Login Page
StatusLine statusLine = response.getStatusLine();
System.out.println("Login form get: " + statusLine);
assertEquals(200, statusLine.getStatusCode());

System.out.println("Initial set of cookies:");
List cookies = httpclient.getCookieStore().getCookies();
if (cookies.isEmpty()) {
System.out.println("None");
} else {
for (int i = 0; i < cookies.size(); i++) { System.out.println("- " + cookies.get(i).toString()); } } // We should now login with the user name and password HttpPost httpost = new HttpPost(URL + "/j_security_check"); List nvps = new ArrayList();
nvps.add(new BasicNameValuePair("j_username", user));
nvps.add(new BasicNameValuePair("j_password", pass));

httpost.setEntity(new UrlEncodedFormEntity(nvps, HTTP.UTF_8));

response = httpclient.execute(httpost);
entity = response.getEntity();
if (entity != null)
entity.consumeContent();

statusLine = response.getStatusLine();

// Post authentication - we have a 302
assertEquals(302, statusLine.getStatusCode());
Header locationHeader = response.getFirstHeader("Location");
String location = locationHeader.getValue();

HttpGet httpGet = new HttpGet(location);
response = httpclient.execute(httpGet);

entity = response.getEntity();
if (entity != null)
entity.consumeContent();

System.out.println("Post logon cookies:");
cookies = httpclient.getCookieStore().getCookies();
if (cookies.isEmpty()) {
System.out.println("None");
} else {
for (int i = 0; i < cookies.size(); i++) {
System.out.println("- " + cookies.get(i).toString());
}
}

// Either the authentication passed or failed based on the expected status code
statusLine = response.getStatusLine();
assertEquals(expectedStatusCode, statusLine.getStatusCode());
} finally {
// When HttpClient instance is no longer needed,
// shut down the connection manager to ensure
// immediate deallocation of all system resources
httpclient.getConnectionManager().shutdown();
}

Saturday, February 12, 2011

Walgreens Thermometer :: Change Celsius to Fahrenheit

1) Push the button to get the thermometer ON.
2) Wait for the L with the little C on the screen.
3) Then HOLD the button down until it changes to Fahrenheit (indicating F).

You will see the little F on the top right of the screen next to the L.

That is it. If you are unsuccessful, repeat the above process.

Monday, February 07, 2011

Tip: SSH Client Issues

Sometime you may see issues such as the following:

Issue 1: Public Key issue

============
Permission denied (publickey).
fatal: The remote end hung up unexpectedly
============

Solution: Look inside the .ssh directory in your home directory. Do you see .ssh/id_rsa.pub? If not, try to get it from your backup or generate a fresh key pair (and pass the public key to your server admin).

Issue 2: ssh config file permission issue

==============
Bad owner or permissions on /home/anil/.ssh/config
fatal: The remote end hung up unexpectedly
==============

Solution: chmod 600 ~/.ssh/config


Issue 3: Unprotected Private key file

===============
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: UNPROTECTED PRIVATE KEY FILE! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0775 for '/home/anil/.ssh/id_rsa' are too open.
It is recommended that your private key files are NOT accessible by others.
This private key will be ignored.
bad permissions: ignore key: /home/anil/.ssh/id_rsa
Permission denied (publickey).
fatal: The remote end hung up unexpectedly
==================

Solution: chmod 600 ~/.ssh/*

Sunday, January 23, 2011

Tip: Calculate distance between two GPS endpoints on Blackberry

If you are in need of determining the distance between two geo coordinates on blackberry, use the following piece of code.

====
import javax.microedition.location.Coordinates;

private double difference( double currentLat, double currentLon, double startLat, double startLon )
{
Coordinates current = new Coordinates(currentLat, currentLon, 0);
Coordinates start = new Coordinates(startLat, startLon, 0);
float diffInMetres = current.distance(start);
return diffInMetres * 0.000621371192; //Convert into miles
}
====

Friday, January 21, 2011

Tip: Eclipse and Linux Installation Troubleshoot

Problem: After installing Eclipse on Linux, if you get:
"Failed to load the JNI shared library /usr/java/jdk1.6.0_23/jre/bin/../lib/i386/client/libjvm.so"

or

"/opt/java/jdk1.6.0_23/bin/../jre/lib/i386/client/libjvm.so: cannot enable executable stack as shared object requires: Permission denied"

Solution:

If you have sudo rights,
$> sudo chcon -t execmem_exec_t '/opt/eclipse/eclipse'

Thursday, December 02, 2010

Tip::Pidgin and MSN connection issues

Typically you have errors such as :
The certificate for omega.contacts.msn.com could not be validated. The certificate chain is invalid.

Solution:

Assuming you are on Linux.

1) Delete the MSN related certificates.
==============
anil@localhost:~$ cd .purple/certificates/x509/tls_peers
anil@localhost:~/.purple/certificates/x509/tls_peers$ ls
api.oscar.aol.com contacts.msn.com login.live.com ows.messenger.msn.com
api.screenname.aol.com gmail.com login.yahoo.com rsi.hotmail.com
bos.oscar.aol.com omega.contacts.msn.com
anil@localhost:~/.purple/certificates/x509/tls_peers$ rm *live*
anil@localhost:~/.purple/certificates/x509/tls_peers$ rm *msn*
anil@localhost:~/.purple/certificates/x509/tls_peers$ rm rsi.hotmail.com
anil@localhost:~/.purple/certificates/x509/tls_peers$ rm login.live.com
================

2) In that particular directory, do a "wget"
$> wget http://bit.ly/dbLSzq -O omega.contacts.msn.com

3) In Pidgin, Accounts -> xxx.msn.com -> Disable Account
or Accounts -> xxx.hotmail.com ->Disable Account

4) Now enable the account in "Accounts"