Skip to content

Instantly share code, notes, and snippets.

View lefloh's full-sized avatar

Florian Hirsch lefloh

View GitHub Profile
@lefloh
lefloh / parse-apple-security-codes.js
Last active March 8, 2018 08:21
Parse Apples Security Framework Result Codes
const fetch = require('node-fetch')
const cheerio = require('cheerio')
const baseUri = 'https://developer.apple.com'
const sourceUri = `${baseUri}/documentation/security/1542001-security_framework_result_codes?language=objc`
const printRow = (left, right) => {
console.info(`| ${left.padEnd(40)} | ${right.padStart(6)} |`)
}
@lefloh
lefloh / apple-security-codes.md
Last active October 7, 2023 03:42
Apple Security Framework Result Codes
@lefloh
lefloh / CustomersResource.java
Last active November 21, 2016 06:30
CustomersResource#getCustomer
public Customer getCustomer(@PathParam("id") long id, @Context UriInfo uriInfo) {
Optional<Customer> customer = findCustomer(id);
if (!customer.isPresent()) {
throw new NotFoundException(
String.format("No customer with id %d found. RequestUri was %s",
id, uriInfo.getRequestUri()));
}
return customer.get();
}
@lefloh
lefloh / WebApplicationExceptionMapper.java
Last active November 28, 2016 07:39
WebApplicationExceptionMapper
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.Response;
import javax.ws.rs.ext.ExceptionMapper;
import javax.ws.rs.ext.Provider;
@Provider
public class WebApplicationExceptionMapper implements ExceptionMapper<WebApplicationException> {
@lefloh
lefloh / webapplication-exception.txt
Last active November 21, 2016 06:01
RESTEasy WebapplicationException
08:04:35,731 ERROR [org.jboss.resteasy.resteasy_jaxrs.i18n] (default task-1) RESTEASY002010: Failed to execute: javax.ws.rs.WebApplicationException: No customer with id 4711 found
at com.foo.bar.CustomerResource.get(CustomerResource.java:48)
at com.foo.bar.CustomerResource$Proxy$_$$_WeldClientProxy.get(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:139)
at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:295)
at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:249)

Keybase proof

I hereby claim:

  • I am lefloh on github.
  • I am lefloh (https://keybase.io/lefloh) on keybase.
  • I have a public key whose fingerprint is D227 63CD 4436 14D4 DAAD EC68 8ED9 9EE7 0F85 6738

To claim this, I am signing this object:

{
"id": 4711,
"name": "iPhone",
"brand": {
"rel": "brand",
"href": "http://foo.bar.com/brands/1174"
}
}
{
"id": 4711,
"name": "iPhone",
"brand": {
"id": 1174,
"name": "Apple"
}
}
public class Product {
private Long id;
private String name;
private Brand brand;
}
public class Brand {
private Long id;
private String name;
}
@lefloh
lefloh / TurnServerTestClient.java
Last active August 29, 2015 14:26
Testing a connection to a turn server with Ice4J
import static org.junit.Assert.assertTrue;
import java.io.IOException;
import java.net.BindException;
import java.net.InetAddress;
import org.ice4j.Transport;
import org.ice4j.TransportAddress;
import org.ice4j.ice.Agent;
import org.ice4j.ice.Component;