Skip to content

Instantly share code, notes, and snippets.

@bsandhu
bsandhu / UpdateDDLCreator.kt
Last active May 27, 2018 16:00
Run Hibernate Schema update from command line
package com.bsandhu.server.db
import org.hibernate.boot.MetadataSources
import org.hibernate.boot.model.naming.ImplicitNamingStrategyJpaCompliantImpl
import org.hibernate.boot.registry.BootstrapServiceRegistryBuilder
import org.hibernate.boot.registry.StandardServiceRegistryBuilder
import org.hibernate.boot.spi.MetadataImplementor
import org.hibernate.tool.hbm2ddl.SchemaUpdate
@bsandhu
bsandhu / gist:1f95ec14efaabef85a63611c09fb857d
Created December 29, 2017 21:34
Tomcat Servlet with blocking op
public class Main {
public static void main(String[] args) throws Exception {
String webappDirLocation = "src/main/webapp/";
Tomcat tomcat = new Tomcat();
tomcat.setPort(8080);
StandardContext ctx = (StandardContext) tomcat.addWebapp("/", new File(webappDirLocation).getAbsolutePath());
Executor[] executors = tomcat.getEngine().getService().findExecutors();
@bsandhu
bsandhu / gist:f42888a46940ad232ec2c20d3883c3b4
Created December 29, 2017 21:32
Two Verticles with Event Bus
public class MainVerticle extends AbstractVerticle {
@Override
public void start() throws Exception {
ObjectMapper mapper = new ObjectMapper();
vertx.createHttpServer().requestHandler(req -> {
vertx.eventBus().send("db.read", "Test", res -> {
req.response()
.setStatusCode(200)
@bsandhu
bsandhu / gist:2342d17f057e526c78ac48ec1997af2d
Created December 29, 2017 16:34
Vert.x verticle with executeBlocking
public class MainVerticle extends AbstractVerticle {
@Override
public void start() throws Exception {
ObjectMapper objectMapper = new ObjectMapper();
vertx.createHttpServer().requestHandler(req -> {
vertx.executeBlocking(future -> {
try {
@bsandhu
bsandhu / protractor.common.conf.js
Last active October 12, 2017 00:45
Protractor config with BrowserStackLocal via Proxy
const path = require('path');
exports.props = {
capabilities: {
browserName: 'chrome',
chromeOptions: {
args: ["show-fps-counter=true"]
}
},
@bsandhu
bsandhu / ComponentsRegistry.js
Last active November 13, 2016 22:20
Register Knockout React components together
define(['log',
'knockout',
'modules/loans/ironBank/components/myReactComponent',
'modules/loans/commons/utils/knockoutReactBinding'],
function (log,
ko,
_myReactComponent) {
'use strict';
function ComponentsRegistry() {
@bsandhu
bsandhu / KnockoutReactBinding.js
Created November 13, 2016 21:42
Using Knockout and React together. Hook React component into Knockout.
define(
['log', 'knockout', 'react', 'react-dom'],
function (log, ko, React, ReactDOM) {
"use strict";
function KnockoutReactBinding() {
log.info('Loading KO binding for React');
this.init();
}