Skip to content

Instantly share code, notes, and snippets.

View asela38's full-sized avatar

Asela Illayapparachchi asela38

  • Rakuten
  • Sri Lanka
View GitHub Profile
@asela38
asela38 / SplitTest.java
Last active March 5, 2018 03:31
If you have worked with flat files String.split should have been useful to you. One inconsistency, I found is change in behavior on cause of empty strings appeared in file with operator(",") and without separator.
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.util.Arrays;
import org.apache.commons.lang3.StringUtils;
import org.junit.Test;
public class SplitTest {
@asela38
asela38 / my-doskey.bat
Created March 5, 2018 03:28
my windows DOSKEYS
doskey 127=start c:\software\putty\putty.exe -ssh 10.20.172.XXX -l clstradm -pw XXXXXX
doskey 129=start c:\software\putty\putty.exe -ssh 10.20.172.XXX -l clstradm -pw XXXXXX
doskey wsedit=gvim ws.bat
doskey git=cd $1 $t C:\PROGRA~2\Git\bin\sh.exe --login -i
doskey eclipse=start c:\software\eclipse\eclipse.exe
doskey sqldeveloper=start C:\software\sqldeveloper\sqldeveloper.exe
doskey ldap=start "C:\software\ApacheDirectoryStudio-2.0.0.v20161101-M12-win32.win32.x86_64\ApacheDirectoryStudio\ApacheDirectoryStudio.exe"
doskey anypoint3.7=start C:\software\AnypointStudio\AnypointStudio.exe
doskey robomongo=start C:\software\robomongo-0.9.0-windows-x86_64-0786489\Robomongo.exe
doskey cpt127=\software\putty\pscp $1\$2 xxxxxxx@10.20.172.XXX:/data/logs/bpt/in/$2
"Leader Mapping
let mapleader="\<Space>"
set guifont=Consolas:h9:cANSI:qDRAFT
set mouse=c
colorscheme torte
set guioptions=egmL
set number
set relativenumber
@asela38
asela38 / DeadLockTest.java
Last active May 15, 2018 05:28
Java Code To Create Dead Lock
public class DeadLockTest {
private static Object o1 = "Lock 1" , o2 = "Lock 2";
public static void main(String[] args) {
new Thread() {
public void run(){
synchronized (o2) {
print();
@asela38
asela38 / sudoku.c
Created May 15, 2018 10:10
Code written sometime back in C to solve a sudoku
/*
* File : sudoku.c
* Using coding samples show in the Richard Buckland' lecture
* series on Higher computing (http://www.youtube.com/watch?v=Rxvv9krECNw)
* (lecture 22 and 21 )
* Created on: May 12, 2009
* Author: Asela
*/
#include
/*
* NumberReader.c
*
* Created on: May 5, 2009
* Author: Asela
*
* shows the way to read integers for integer values
* ( form INT_MIN+1 to INT_MAX )
*/
#include <stdio.h>
@asela38
asela38 / OneBillionIntegerFileGenerator.java
Last active May 16, 2018 05:01
Generate file with 1 Billion Integers between 0 and 1000
import java.io.BufferedWriter;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.util.concurrent.ThreadLocalRandom;
import java.util.stream.IntStream;
class OneBillionIntegerFileGenerator {
public static void main(String[] args) throws IOException {
@asela38
asela38 / OneBillionIntegerStatistics.java
Created May 16, 2018 04:56
Generate basic statistics for 1 Billion data set of Integers
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
class OneBillionIntegerStatistics {
public static void main(String[] args) throws IOException {
try (BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream("numbers_1B.in")))) {
@asela38
asela38 / TestStackSize.java
Last active May 17, 2018 02:59
Program to Check Stack Size Change
public class TestStackSize {
public static void main(String[] args) {
System.out.println(IntStream.generate(() -> {
AtomicInteger i = new AtomicInteger(0);
try {
new TestStackSize().call(i);
} catch (Throwable e) {
return i.get();
}
@asela38
asela38 / user_test_create_populate_proc.sql
Created May 18, 2018 04:20
Two procedures to create user_test table and populate it
DROP PROCEDURE create_tables;
DELIMITER $$
CREATE PROCEDURE create_tables ( )
BEGIN
DECLARE counter BIGINT DEFAULT 0;
DROP TABLE IF EXISTS `user_test`;
CREATE TABLE `user_test` (
`user_id` int(11) unsigned NOT NULL AUTO_INCREMENT,