Skip to content

Instantly share code, notes, and snippets.

View vacax's full-sized avatar

Carlos Camacho vacax

View GitHub Profile
@mlecoutre
mlecoutre / gist:4088178
Created November 16, 2012 15:25
JPA on Heroku without Spring

When creating a DEV instance of postgreSQL on heroku, heroku create an environment variable named "DATABASE_URL" that contains url, user and password. As we are in a cloud environment, your persistence.xml file should not contain any reference to a specific host, port or user/password account. It can change without any warning.

Unfortunately, this variable is not compliant with the JDBC format because HEROKU is not done just for the JAVA. So we need to translate this generic URL into a valid JDBC URL and extract user password You can found on the web a good example with Spring, but i've not found anything without it.

So here is a snippet of code that you can use in a ServletContextListener to initialize the EntityManagerFactory. (you will found it in org.mat.nounou.servlets.EntityManagerLoaderListener in this application).

@michaellihs
michaellihs / twisted.md
Last active April 7, 2024 17:47
Write your own ssh Server with the Python Twisted library

SSH Server with the Python Twisted Library

Installing the library

Assuming you have Python installed on your system:

pip install twisted
pip install pyOpenSSL
pip install service_identity
@rponte
rponte / SignedXml.java
Last active February 2, 2024 11:35
How to sign a XML with private key certificate in Java (using Java Key Store)
package br.com.mdias.rponte.signature;
import java.util.Base64;
/**
* Represents a signed XML
*/
public class SignedXml {
private String content;