Skip to content

Instantly share code, notes, and snippets.

@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 / productivity.md
Last active July 7, 2020 03:04
My notes on maintaining a low distraction environment and avoiding information overload
@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 / 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 / bash-loop.sh
Last active May 20, 2016 03:28
How to: Basic GNU Linux/Mac command line tools (Also mostly works with GOW on Windows)
#! /bin/bash
a=(user1 pass1 user2 pass2)
for ((i=0; i<${#a[@]}; i+=2)); do
echo "Loop 1: ${a[i]}: ${a[i+1]}"
done
a1=(user1 user2)
a2=(pass1 pass2)
for ((i=0; i<${#a1[@]}; i+=1)); do
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
@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 / 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 / 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 {