Skip to content

Instantly share code, notes, and snippets.

View rschumm's full-sized avatar

Rémy Schumm rschumm

  • zhaw InIT
  • Winterthur, Switzerland
  • 05:45 (UTC -12:00)
View GitHub Profile
@rschumm
rschumm / Exception.cs
Created February 20, 2015 09:00
Exceptions
int SafeDivision(int x, int y)
{
try
{
return (x / y);
}
catch (System.DivideByZeroException dbz)
{
System.Console.WriteLine("Division by zero attempted!");
return 0;
@rschumm
rschumm / POSTClient.java
Created September 9, 2014 12:37
HttpClient POST File
import org.apache.commons.httpclient.HttpClient;
...
File csvFile = new File (this.getClass().getResource("/data.csv").getFile());
PostMethod filePost = new PostMethod("http://localhost:8080/api/admin/uploadUsers");
Part[] parts = {new FilePart("users", csvFile)};
filePost.setRequestEntity(new MultipartRequestEntity(parts, filePost.getParams()));
filePost.addRequestHeader("Authorization", "Bearer " + IntTestAuthUtil.computeAuthorisationToken());
HttpClient client = new HttpClient();
int status = client.executeMethod(filePost);
@rschumm
rschumm / Connection in Container.java
Created August 7, 2014 17:33
Connection in Container.java
@Resource(mappedName="jdbc:/OracleDefaultDS") DataSource datasource;
@rschumm
rschumm / commands.cli
Last active August 29, 2015 13:57
maven as plug-in -> JBoss APi command line
batch
# this file is only meant as an example
# it is not commented out completeley!
# Add System Property (must be verified if it works)
# /system-property=foo:add(value=bar)
# Add Extension
# /extension=org.jboss.as.messaging:add
@rschumm
rschumm / app.html
Created February 28, 2014 14:30
iPhone Web App
<head>
<link rel="apple-touch-icon-precomposed" href="bla.png">
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="bla4.png">
<link rel="apple-touch-startup-image" href="startup.png">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
...
</head>
@rschumm
rschumm / IntTest.java
Last active August 29, 2015 13:56
Ganz einfacher DB Integrations-Test
package com.axa.ch.apc.util;
import static org.junit.Assert.assertEquals;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
@rschumm
rschumm / changelog.xml
Created February 10, 2014 09:28
DB udpate mit liquibase
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.0.xsd
http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">
<include file="db/testdaten.sql" />
@rschumm
rschumm / pom-default.xml
Last active August 29, 2015 13:56
Integration-Test maven
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.16</version>
<executions>
<execution>
<id>default-test</id>
<configuration>
<excludes>
<exclude>**/*Rest*</exclude>
@rschumm
rschumm / ExcelParserMain.java
Last active January 2, 2016 16:39
Einfaches Auslesen eines Excel mit Apach POI
public static Katalog extractKatalog(Workbook excel) {
// System.out.println(excel.getNumberOfSheets());
Sheet sheet = excel.getSheetAt(0);
Katalog katalog = new Katalog("der erste Katalog");
for (Row zeile : sheet) {
Cell zelle = zeile.getCell(4);
@rschumm
rschumm / ExcelParserMain.java
Last active January 2, 2016 16:39
Marshallen einer Objektstruktur mit JAXB zu json.
private static void marshallToFile(Katalog katalog, File jsonFile) throws JAXBException, PropertyException {
// Marshalling...
JAXBContext context = JAXBContext.newInstance(PoGeVoKatalog.class);
Marshaller m = context.createMarshaller();
m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
m.setProperty(Marshaller.JAXB_ENCODING, "utf-8");
m.setProperty(MarshallerProperties.MEDIA_TYPE, "application/json");
m.setProperty(MarshallerProperties.JSON_INCLUDE_ROOT, true);