Skip to content

Instantly share code, notes, and snippets.

View manzke's full-sized avatar

Daniel Manzke manzke

View GitHub Profile
@manzke
manzke / Guice-based Parser
Created December 6, 2010 09:37
Proof-of-Concept for a Guice-based Parser
import java.io.BufferedReader;
import java.io.IOException;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.List;
import com.google.inject.AbstractModule;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.Module;
@manzke
manzke / Renamer.java
Created December 28, 2010 15:24
Replace special characters of File and Folder names with new ones.
import java.io.File;
public class Renamer {
private boolean dryRun = true;
private String in = "&";
private String out = "-";
private File root;
private void init(String[] args){
@manzke
manzke / ServiceFactory.java
Created February 5, 2011 22:32
This ServiceFactory is an Example how to ignore SSL-Certificates and Hostnames. This can be used, if you always trusted the endpoint or if you just want to give it a try!
package com.saperion.webservice;
import java.io.IOException;
import java.net.URL;
import java.security.cert.X509Certificate;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
@manzke
manzke / ByteBufferedOutputStream.java
Last active August 21, 2019 12:16
Self expanding OutputStream with an underlying ByteBuffer
/**
The MIT License (MIT)
Copyright (c) 2015 Daniel Manzke
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
@manzke
manzke / TailorWebSocketServlet.java
Created June 12, 2011 21:04
Jetty 7+8 Web Socket Example
package de.devsurf.html.tail;
import java.io.IOException;
import java.util.Date;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArraySet;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
@manzke
manzke / CopyInputStream.java
Created June 17, 2011 08:10
InputStream which copies your available Data
import java.io.ByteArrayOutputStream;
import java.io.FilterInputStream;
import java.io.IOException;
import java.io.InputStream;
public class CopyInputStream extends FilterInputStream {
private final ByteArrayOutputStream _copyTo = new ByteArrayOutputStream();
public CopyInputStream(InputStream in) {
@manzke
manzke / PublicKeyGenerator.java
Created July 6, 2011 21:54
How to generate the PublicKey from a RSA PrivateKey
import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.security.KeyFactory;
import java.security.PrivateKey;
import java.security.PublicKey;
import java.security.spec.PKCS8EncodedKeySpec;
import java.security.spec.RSAPublicKeySpec;
import sun.security.rsa.RSAPrivateCrtKeyImpl;
@manzke
manzke / CrxWriter.java
Created July 7, 2011 14:08
Creating Chrome Extensions (.crx) without Chrome and with Java - crxmake for Java
package de.devsurf.chrome.extensions;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.PrivateKey;
import java.security.PublicKey;
import java.security.Signature;
@manzke
manzke / Extract.java
Created August 9, 2012 09:13
Extract text of DOCX with Apache POI
XWPFDocument doc = new XWPFDocument(in);
XWPFWordExtractor ex = new XWPFWordExtractor(doc);
String text = ex.getText();
@manzke
manzke / TwilioTests.java
Created February 3, 2013 23:26
Twilio Tests
public class TwilioTests {
public static final String ACCOUNT_SID = "accountid";
public static final String AUTH_TOKEN = "token";
public static void main(final String[] args) throws TwilioRestException,
TwiMLException {
// Create a rest client
final TwilioRestClient client = new TwilioRestClient(ACCOUNT_SID,
AUTH_TOKEN);