Skip to content

Instantly share code, notes, and snippets.

View arunpjohny's full-sized avatar

Arun P Johny arunpjohny

  • Greytip Software Pvt Ltd
  • Bangalore
View GitHub Profile
@arunpjohny
arunpjohny / postgres-dead-tuples-example.sql
Last active August 5, 2020 22:40
Postgres Dead Tuples
set search_path to testschema;
--drop table employee cascade
create table employee(
cid serial primary key,
employeeno character varying(100) not null unique,
name character varying(100),
doj date,
resigned boolean default false not null
)

Keybase proof

I hereby claim:

  • I am arunpjohny on github.
  • I am arunpjohny (https://keybase.io/arunpjohny) on keybase.
  • I have a public key ASCHSsvvz-afS4tJ7TCQyhYM2CsvNPzUvSxvtt_q5tLNSAo

To claim this, I am signing this object:

@arunpjohny
arunpjohny / GenerateSignatureForString.java
Last active September 5, 2015 09:43
Methods to Create and Verify signatures for a given string
private static String sign(String string, PrivateKey privateKey) throws NoSuchAlgorithmException, InvalidKeyException, SignatureException {
Signature dsa = Signature.getInstance("SHA1withRSA");
dsa.initSign(privateKey);
byte[] bytes = string.getBytes();
dsa.update(bytes, 0, bytes.length);
byte[] signature = dsa.sign();
return Base64.encodeBase64String(signature);
}
@arunpjohny
arunpjohny / GenerateKeyPair.java
Last active September 5, 2015 09:45
Methods to create a KeyPair dynamically and to convert to string and back to private/public keys
protected static void generateKeyPair() throws NoSuchAlgorithmException {
KeyPairGenerator keyGen = KeyPairGenerator.getInstance("RSA");
keyGen.initialize(512);
KeyPair genKeyPair = keyGen.genKeyPair();
String publicKey = Base64.encodeBase64String(genKeyPair.getPublic().getEncoded());
String privateKey = Base64.encodeBase64String(genKeyPair.getPrivate().getEncoded());
System.out.println(publicKey);
System.out.println(privateKey);
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.js"></script>
</head>
<body>
<h1>Framed</h1>
<input type="button" value="click"/>
</body>
<script>
$(document).ready(function(){
/*
* jQuery Related Selects plug-in 1.1
*
* http://www.erichynds.com/jquery/jquery-related-dependent-selects-plugin/
* http://github.com/ehynds/jquery-related-selects
*
* Copyright (c) 2009 Eric Hynds
*
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
/*
* jQuery Related Selects plug-in 1.1
*
* http://www.erichynds.com/jquery/jquery-related-dependent-selects-plugin/
* http://github.com/ehynds/jquery-related-selects
*
* Copyright (c) 2009 Eric Hynds
*
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
<html>
<head>
<link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.1/themes/redmond/jquery-ui.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.10.1/jquery-ui.js"></script>
</head>
<body>
<input id="Name" onblur="checkname()" /><label id="lbl"/>
</body>
<script>
@arunpjohny
arunpjohny / UI Component
Created October 5, 2012 09:39
Eclipse Code Templates - GT
${:import(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse,org.springframework.security.access.annotation.Secured, org.springframework.web.bind.annotation.RequestMapping,org.springframework.web.servlet.ModelAndView, java.util.Map, java.util.HashMap, com.greytip.common.utils.RequestUtils)}
@RequestMapping(${mapping})
@Secured("ROLE_${FEATURE}")
public ModelAndView ${method}(HttpServletRequest request, HttpServletResponse response) {
Map<String, Object> model = new HashMap<String, Object>();
return new ModelAndView(${view}, model);
}
@arunpjohny
arunpjohny / SLF4J Logger
Created October 5, 2012 07:51
Eclipse Code Templates
${:import(org.slf4j.Logger,org.slf4j.LoggerFactory)}
private static final Logger logger = LoggerFactory.getLogger(${enclosing_type}.class);