Skip to content

Instantly share code, notes, and snippets.

@AshwinJay
AshwinJay / 1) jpmp.sh
Created March 2, 2011 23:05
JPMP (Java's Poor Man's Profiler) [corrected]
# Original version: http://blog.tsunanet.net/2010/08/jpmp-javas-poor-mans-profiler.html
# Usage: ./jpmp.sh <pid> <num-samples> <sleep-time-between-samples>
#!/bin/bash
pid=$1
nsamples=$2
sleeptime=$3
for x in $(seq 1 $nsamples)
@AshwinJay
AshwinJay / readme.md
Last active August 7, 2020 03:10
Tech reading list to help people get started with programming, design and Java etc.
@AshwinJay
AshwinJay / productivity.md
Last active July 7, 2020 03:04
My notes on maintaining a low distraction environment and avoiding information overload
@AshwinJay
AshwinJay / seed.md
Last active July 7, 2020 03:03
Tech reading list to help people get started with programming, design and Java etc.
@AshwinJay
AshwinJay / Simple Java keytool key pair and trust store
Last active August 15, 2018 23:24
OpenSSL and Java import/export
Create self signed key pair and add to new key store:
keytool -genkey -alias mykey -keyalg RSA -keystore keystore.jks -keysize 2048
Export public key and import into new trust store:
keytool -keystore keystore.jks -export -alias mykey -file my.cer
keytool -import -alias mypub -file my.cer -keystore truststore.jks
(Alternate way) Manually import certificate from HTTPS server to trust store:
Firefox: Add Exception -> Get Certificat -> View -> Details -> Export as "a.der"
keytool -importcert -keystore truststore.jks -file a.der
@AshwinJay
AshwinJay / Log4J programmatic
Last active August 6, 2018 18:17
Log4J settings
BasicConfigurator.configure();
org.apache.log4j.Logger.getRootLogger().setLevel(Level.INFO);
@AshwinJay
AshwinJay / LambdaCapture.java
Last active August 27, 2017 18:28
Simple Java lambda tests
package com.foo;
import java.util.LinkedList;
import java.util.List;
public class LambdaCapture {
public static void main(String[] args) {
List<String> strings = new LinkedList<>();
strings.add("one");
strings.add("two");
@AshwinJay
AshwinJay / LogInvocationStyleBenchmark.java
Last active August 27, 2017 18:28
Java logger invocation style benchmark
package com.foo;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.runner.Runner;
import org.openjdk.jmh.runner.RunnerException;
import org.openjdk.jmh.runner.options.Options;
import org.openjdk.jmh.runner.options.OptionsBuilder;
import java.util.Random;
import java.util.function.Supplier;
@AshwinJay
AshwinJay / RedisJavaDemo.java
Created March 3, 2012 08:05
Redis Java demo
import redis.clients.jedis.Jedis;
import redis.clients.jedis.PipelineBlock;
/**
* Author: Ashwin Jayaprakash
* <p/>
* Email: ashwin.jayaprakash@gmail.com Web: http://www.ashwinjayaprakash.com
*/
public class RedisJavaDemo {
public static void main(String[] args) throws InterruptedException {
package com.javaforu.rsync;
import com.javaforu.rsync.Sync.CharRingBuffer.Visitor;
import rollinghash.RabinKarpHash;
import java.util.*;
import java.util.zip.CRC32;
/**
* Author: Ashwin Jayaprakash / ashwin.jayaprakash@gmail.com / http://www.ashwinjayaprakash.com