Skip to content

Instantly share code, notes, and snippets.

@sangramanand
sangramanand / gist:3183604
Created July 26, 2012 18:15
Java Time difference using JODA
Java Time difference using JODA
DateTime beforeCall = new DateTime();
Map<String, Map<String, String>> info = Maps.newHashMap();
Interval interval = new Interval(beforeCall, new Instant());
System.out.println("new call difference = "+interval.toDurationMillis());
DateTime beforeCall1 = new DateTime();
allAdmins = adminDAO.getAll();
@sangramanand
sangramanand / gist:3187774
Created July 27, 2012 12:54
Amazon Linux machine - sun jdk 1.7 & memcached installation
// remove open jdk by looking into its rpm
#rpm -qa
# rpm -e --nodeps java-1.6.0-openjdk-1.6.0.0-52.1.9.10.40.amzn1.x86_64
// install sun jdk 7 rpm - for updated java jdk checkout @ http://ivan-site.com/2012/05/download-oracle-java-jre-jdk-using-a-script/#more-39
# wget --no-cookies --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F" "http://download.oracle.com/otn-pub/java/jdk/7u5-b05/jdk-7u5-linux-x64.rpm"
# rpm -ivh jdk-7u5-linux-x64.rpm
//after jdk is installed successfully, install memcached.
package com.generalsentiment.action;
public class RedirectToBlog {
private String externalUrl;
public String getExternalUrl() {
return externalUrl;
}
<%--
Document : manageHomePageFeeds
Created on : 26 Oct, 2012, 3:39:31 PM
Author : anand
--%>
<%@ taglib prefix="gs" uri="/struts-tags" %>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
REST API Concepts
-----------------
HTTP methods - GET, POST, PUT, DELETE
SOAP has WSDL as service definition
REST has no standard
200 - OK
500 - Error on the server while processing the request
404 - Page not found error
@sangramanand
sangramanand / Elastic BeanStalk settings for Live Env
Created January 12, 2012 04:07
Elastic BeanStalk settings for Live Env
Live Environment Configuration on Elastic Beanstalk
Ec2-instance type - c1.medium
Ec2 Security Groups - elasticbeanstalk-default, default, GSUI-Base
Monitor Interval - 1 minute
Http Listener port -80
Https Listen ort -443
SSL Certificate ID - rn:aws:iam::228576831886:server-certificate/GeneralSentiment-SSL
Application Health Check URL - /
Health Check Interval (seconds) - 30
@sangramanand
sangramanand / ValidatePhoneNumber
Created February 23, 2012 11:46
Validating phone number using Java
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
*
* @author anand
*/
public class ValidatePhoneNumber {
public static void main(String[] argv) {
package com.tut.jgit;
import java.io.File;
import org.eclipse.jgit.api.CloneCommand;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider;
public class GitTester {