Skip to content

Instantly share code, notes, and snippets.

View lillesand's full-sized avatar

Jøran Vagnby Lillesand lillesand

  • Bekk Consulting
View GitHub Profile
package no.posten.dpost.signering;
import org.springframework.xml.transform.StringSource;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamReader;
public class LedConfigTester {
public static void runEternally() throws InterruptedException {
GpioController gpioController = GpioFactory.getInstance();
List<Pin> pins = asList(RaspiPin.GPIO_00, RaspiPin.GPIO_01, RaspiPin.GPIO_02, RaspiPin.GPIO_03, RaspiPin.GPIO_04);
List<GpioPinDigitalOutput> digitalPins = new ArrayList<GpioPinDigitalOutput>();
for (Pin pin : pins) {
GpioPinDigitalOutput gpioPinDigitalOutput = gpioController.provisionDigitalOutputPin(pin, PinState.LOW);
digitalPins.add(gpioPinDigitalOutput);
@lillesand
lillesand / CsrfProtectionFilter.java
Last active December 19, 2015 07:19
Jersey sin Csrf protection
/**
*
* Også kan jeg kommentere her.
*
* Simple server-side request filter that implements CSRF protection as per the
* <a href="http://www.nsa.gov/ia/_files/support/guidelines_implementation_rest.pdf">Guidelines for Implementation of REST</a>
* by NSA (section IV.F) and
* section 4.3 of <a href="http://seclab.stanford.edu/websec/csrf/csrf.pdf">this paper</a>.
* If you add it to the request filters of your application, it will check for X-Requested-By header in each
* request except for those that don't change state (GET, OPTIONS, HEAD). If the header is not found,
window.onerror = function(errorMsg, url, lineNumber) {
alert('noobface, plz');
};
@lillesand
lillesand / current_DefaultConstrettoConfiguration.java
Created October 25, 2011 14:58
Constretto concurrency issue
private <T> void injectConfiguration(T objectToConfigure) {
injectFields(objectToConfigure);
injectMethods(objectToConfigure);
boolean found = false;
for (WeakReference<Object> configuredObject : configuredObjects) {
if (configuredObject.get() == objectToConfigure) {
found = true;
break;
}
}