Skip to content

Instantly share code, notes, and snippets.

View bechhansen's full-sized avatar

Peer Bech Hansen bechhansen

  • Systematic
  • Århus, Denmark
View GitHub Profile
@bechhansen
bechhansen / nginxproxy.md
Created November 1, 2016 21:11 — forked from soheilhy/nginxproxy.md
How to proxy web apps using nginx?

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers

@bechhansen
bechhansen / gist:b64a0174ac5b24d68e7a
Created July 8, 2015 10:46
Java possible DateFormat styles
package com.pbha.localization;
import java.io.BufferedWriter;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.UnsupportedEncodingException;
import java.io.Writer;
import java.text.DateFormat;
@bechhansen
bechhansen / gist:5161065
Created March 14, 2013 12:50
JMS Durable unsubstribe
@Test
public void unsubscribeContact() throws NamingException, JMSException {
System.setProperty("org.jboss.invocation.pooled.Legacy", "true");
Connection conn;
Session session;
Properties properties = new Properties();
properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
@bechhansen
bechhansen / gist:2366853
Created April 12, 2012 12:09
JBoss remote service invocation
try {
Hashtable<String, String> environment = new Hashtable<String, String>();
environment.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
environment.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
environment.put(Context.PROVIDER_URL, "jnp://localhost:1099");
InitialContext context = new InitialContext(environment);
StatelessBeanRemote bean = (StatelessBeanRemote) context.lookup("CertEAR/StatelessBean/remote-com.monzware.javacert.StatelessBeanRemote");
@bechhansen
bechhansen / JMSAdd.java
Created January 24, 2012 21:35
JMS Queue add
Hashtable<String, String> environment = new Hashtable<String, String>();
environment.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
environment.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
environment.put(Context.PROVIDER_URL, "jnp://localhost:1099");
InitialContext context = new InitialContext(environment);
ConnectionFactory connectionFactory = (ConnectionFactory)ctx.lookup("ConnectionFactory");
Queue queue = (Queue)ctx.lookup("queue/test");