Skip to content

Instantly share code, notes, and snippets.

@danielkec
danielkec / Marshallable.java
Created August 7, 2013 10:27
Utility for marshalling and unmarshalling JAXB objects
/*
* Copyright 2013 Syntea software group a.s.
*
* This file may be used, copied, modified and distributed only in accordance
* with the terms of the limited licence contained in the accompanying
* file LICENSE.TXT.
*
* Tento soubor muze byt pouzit, kopirovan, modifikovan a siren pouze v souladu
* s licencnimi podminkami uvedenymi v prilozenem souboru LICENSE.TXT.
*/
@danielkec
danielkec / DCDiscovery.java
Created August 22, 2013 16:07
Querying DNS to find all ActiveDirectory it knows about
package cz.syntea.common.apmsvr.jtalk2ad;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.naming.Context;
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
@danielkec
danielkec / LafMenu.java
Last active December 22, 2015 01:39
JMenu for changing LaF of a Swing app
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.HashMap;
import javax.swing.ButtonGroup;
import javax.swing.JMenu;
import javax.swing.JRadioButtonMenuItem;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.UIManager.LookAndFeelInfo;
#!/bin/bash
# sudo apt-get install libnss3-tools
# To trust a root CA certificate for issuing SSL server certificates, use
certutil -d sql:$HOME/.pki/nssdb -A -t "C,," -n isdn.syntea.cz -i isdn.syntea.cz.pem
# To import an intermediate CA certificate, use
certutil -d sql:$HOME/.pki/nssdb -A -t ",," -n isdn.syntea.cz -i isdn.syntea.cz.pem
# To trust a self-signed server certificate, we should use
Authenticator myAuth = new Authenticator(){
@Override
protected PasswordAuthentication getPasswordAuthentication(){
return new PasswordAuthentication("jmeno", "heslo".toCharArray());
}
};
Authenticator.setDefault(myAuth);
SELECT verze.IDVERZE,
zosoba.zranena
FROM DN.DN_VERZE verze
LEFT JOIN DN.DN_DN dn ON verze.IDDN = dn.IDDN
LEFT JOIN cc.cc_ndnZaznamPlatSchval dnPlat ON dn.idNdnZaznamPlatSchval = dnPlat.idNdnZaznamPlatSchval
LEFT JOIN cc.cc_ndnKvalUdalost dnUdalost ON verze.idNdnKvalUdalost = dnUdalost.idNdnKvalUdalost
FULL JOIN OR.OR_VERZEEXPORTDAVKA verzeExportDavka ON verze.IDVERZE = verzeExportDavka.IDVERZE
LEFT JOIN (
SELECT
osoba.idVerze,
SELECT verze.IDVERZE,
zosoba.zranena
FROM DN.DN_VERZE verze
LEFT JOIN DN.DN_DN dn ON verze.IDDN = dn.IDDN
LEFT JOIN cc.cc_ndnZaznamPlatSchval dnPlat ON dn.idNdnZaznamPlatSchval = dnPlat.idNdnZaznamPlatSchval
LEFT JOIN cc.cc_ndnKvalUdalost dnUdalost ON verze.idNdnKvalUdalost = dnUdalost.idNdnKvalUdalost
LEFT JOIN (
SELECT
osoba.idVerze,
--osoba
package cz.syntea.dn.web2.server;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
package xmldiff;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
@danielkec
danielkec / ExceptionUtils.java
Created January 9, 2020 09:24
throwUncheckedException
public class ExceptionUtils {
public static void throwUncheckedException(Throwable t) {
ExceptionUtils.<RuntimeException>throwWithTypeErasure(t);
}
@SuppressWarnings("unchecked")
private static <T extends Throwable> void throwWithTypeErasure(Throwable t) throws T {
throw (T) t;
}