Skip to content

Instantly share code, notes, and snippets.

View ehsanullahjan's full-sized avatar

Ehsan J. ehsanullahjan

  • Twitter, Inc.
  • Michigan, USA
  • 01:35 (UTC -05:00)
  • X @null_ptrz
View GitHub Profile
{
"keyboard": "kinesis/stapelberg",
"keymap": "kinesis-ehsanj",
"layout": "LAYOUT",
"layers": [
["KC_ESC", "KC_F1", "KC_F2", "KC_F3", "KC_F4", "KC_F5", "KC_F6", "KC_F7", "KC_F8", "TG(2)", "KC_1", "KC_2", "KC_3", "KC_4", "KC_5", "KC_EQL", "KC_Q", "KC_W", "KC_F", "KC_P", "KC_G", "KC_GRV", "KC_A", "KC_R", "KC_S", "KC_T", "KC_D", "LSFT_T(KC_CAPS)", "KC_Z", "KC_X", "KC_C", "KC_V", "KC_B", "ANY(LSFT(LGUI(KC_LBRC)))", "ANY(LSFT(LGUI(KC_RBRC)))", "LALT_T(KC_LEFT)", "LGUI_T(KC_RGHT)", "LGUI_T(KC_DEL)", "LALT_T(KC_F11)", "LCTL_T(KC_HOME)", "LSFT_T(KC_BSPC)", "LT(4,KC_TAB)", "LT(5,KC_END)", "KC_F9", "KC_F10", "KC_F11", "KC_F12", "KC_PSCR", "KC_SLCK", "KC_PAUS", "TG(4)", "MO(6)", "KC_6", "KC_7", "KC_8", "KC_9", "KC_0", "TG(3)", "KC_J", "KC_L", "KC_U", "KC_Y", "KC_SCLN", "KC_MINS", "KC_H", "KC_N", "KC_E", "KC_I", "KC_O", "KC_QUOT", "KC_K", "KC_M", "KC_COMM", "KC_DOT", "KC_SLSH", "RSFT_T(KC_BSLS)", "RGUI_T(KC_UP)", "RALT_T(KC_DOWN)", "KC_LBRC", "KC_RBRC", "RALT_T(KC_F12)", "RGUI_T(KC_ESC)", "RCTL_T(KC_PGUP)", "
{
"keyboard": "atreus62",
"keymap": "atreus62-ehsanj",
"layout": "LAYOUT",
"layers": [
[ "KC_GRV", "KC_1", "KC_2", "KC_3", "KC_4", "KC_5", "KC_6", "KC_7", "KC_8", "KC_9", "KC_0", "KC_MINS", "KC_TAB", "KC_Q", "KC_W", "KC_F", "KC_P", "KC_G", "KC_J", "KC_L", "KC_U", "KC_Y", "KC_SCLN", "KC_EQL", "LT(3,KC_DEL)", "KC_A", "KC_R", "KC_S", "KC_T", "KC_D", "KC_H", "KC_N", "KC_E", "KC_I", "KC_O", "LT(2,KC_QUOT)", "KC_LSPO", "KC_Z", "KC_X", "KC_C", "KC_V", "KC_B", "KC_K", "KC_M", "KC_COMM", "KC_DOT", "KC_SLSH", "KC_RSPC", "MEH_T(KC_CAPS)", "TO(1)", "KC_BSLS", "KC_LEFT", "LCTL_T(KC_RGHT)", "LALT_T(KC_BSPC)", "LGUI_T(KC_ESC)", "RGUI_T(KC_ENT)", "RALT_T(KC_SPC)", "RCTL_T(KC_UP)", "KC_DOWN", "KC_LCBR", "KC_RCBR", "ALL_T(KC_SLCK)" ],
[ "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_E", "KC_R", "KC_T", "KC_Y", "KC_U", "KC_I", "KC_O", "KC_P", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_S", "KC_D", "
# PostgreSQL
module add --name=org.postgres.jdbc --dependencies=javax.api,javax.transaction.api --resources={/path/to/jdbc/driver.jar}
# SQL Server
module add --name=org.jtds.jdbc --dependencies=javax.api,javax.transaction.api --resources={/path/to/jdbc/driver.jar}
# Oracle
module add --name=com.oracle.jdbc --dependencies=javax.api,javax.transaction.api --resources={/path/to/jdbc/driver.jar}
# MySQL
# PostgreSQL
xa-data-source add --name={{data-source-name}} --jndi-name={{jndi-name}} --driver-name=postgres --user-name={{username}} --password={{password}} --use-java-context=true --min-pool-size=1 --max-pool-size=10 --idle-timeout-minutes=3 --background-validation=false --validate-on-match=true --valid-connection-checker-class-name="org.jboss.jca.adapters.jdbc.extensions.postgres.PostgreSQLValidConnectionChecker" --exception-sorter-class-name="org.jboss.jca.adapters.jdbc.extensions.postgres.PostgreSQLExceptionSorter" --xa-datasource-properties={ServerName={{host}},PortNumber=5432,DatabaseName={{database}}}
/subsystem=resource-adapters/resource-adapter=file/connection-definitions={{data-source-name}}:add(enabled=false,jndi-name="{{jndi-name}}",class-name="org.teiid.resource.adapter.file.FileManagedConnectionFactory",min-pool-size=1,max-pool-size=10,flush-strategy=FailingConnectionOnly)
/subsystem=resource-adapters/resource-adapter=file/connection-definitions={{data-source-name}}/config-properties=ParentDirectory:add(value={{directory-pathname}})
/subsystem=resource-adapters/resource-adapter=file/connection-definitions={{data-source-name}}:write-attribute(name=enabled,value=true)
@ehsanullahjan
ehsanullahjan / datasource-template.cli
Last active May 4, 2016 14:35
Templates for creating PostgreSQL, SQL Server, Oracle and MySQL datasources in JBoss / WildFly using JBoss CLI
# PostgreSQL
/subsystem=datasources/data-source={{data-source-name}}:add(jndi-name="{{jndi-name}}",driver-name="postgres",connection-url="{{jdbc-uri}}",user-name={{username}},password={{password}},enabled=true,use-java-context=true,background-validation=false,validate-on-match=true,valid-connection-checker-class-name="org.jboss.jca.adapters.jdbc.extensions.postgres.PostgreSQLValidConnectionChecker",exception-sorter-class-name="org.jboss.jca.adapters.jdbc.extensions.postgres.PostgreSQLExceptionSorter",min-pool-size=1,max-pool-size=10,idle-timeout-minutes=3)
# SQL Server
/subsystem=datasources/data-source={{data-source-name}}:add(jndi-name="{{jndi-name}}",driver-name="sqlserver",connection-url="{{jdbc-uri}}",user-name={{username}},password={{password}},enabled=true,use-java-context=true,background-validation=false,validate-on-match=true,valid-connection-checker-class-name="org.jboss.jca.adapters.jdbc.extensions.mssql.MSSQLValidConnectionChecker",min-pool-size=1,max-pool-size=10,idle-timeout-minutes=3)
# Oracl
@ehsanullahjan
ehsanullahjan / register-jdbc-drivers.cli
Last active October 24, 2016 18:40
Snippets for enabling JDBC drivers, deployed as modules, in JBoss / Wildfly using JBoss CLI
# PostgreSQL
if (outcome != success) of /subsystem=datasources/jdbc-driver=postgres:read-resource
/subsystem=datasources/jdbc-driver=postgres:add(driver-name=postgres,jdbc-compliant=true,driver-module-name=org.postgres.jdbc,driver-class-name=org.postgresql.Driver,driver-datasource-class-name=org.postgresql.ds.PGPoolingDataSource,xa-datasource-class=org.postgresql.xa.PGXADataSource)
end-if
# SQL Server
if (outcome != success) of /subsystem=datasources/jdbc-driver=sqlserver:read-resource
/subsystem=datasources/jdbc-driver=sqlserver:add(driver-name=sqlserver,jdbc-compliant=true,driver-module-name=org.jtds.jdbc,driver-class-name=net.sourceforge.jtds.jdbc.Driver,driver-datasource-class-name=net.sourceforge.jtds.jdbcx.JtdsDataSource,xa-datasource-class=net.sourceforge.jtds.jdbcx.JtdsDataSource)
end-if
@ehsanullahjan
ehsanullahjan / BinarySearch.java
Last active July 27, 2016 20:53
Tail recursive implementation of Binary Search in Java
public static <T extends Comparable<? super T>> int rank(T[] seq, T key) {
return rank(seq, key, 0, seq.length - 1);
}
public static <T extends Comparable<? super T>> int rank(T[] seq, T key, int lo, int hi) {
if (lo > hi)
return -1;
int mid = lo + (hi - lo) / 2;
int rel = key.compareTo(seq[mid]);
@ehsanullahjan
ehsanullahjan / fibonacci.scala
Last active August 29, 2015 14:23
Fibonacci using tail recursion
def fib(n: Long): Long = {
@annotation.tailrec
def go(n: Long, x: Long, y: Long): Long =
n match {
case 0 => x
case 1 => y
case _ => go(n - 1, y, x + y)
}
go(n, 0, 1)
"use strict";
// Base Girl object.
function Girl() {
this.name = '';
this.traits = {};
}
// Scout `is a` Girl
function Scout() {