Skip to content

Instantly share code, notes, and snippets.

Avatar

Johannes Brodwall jhannes

View GitHub Profile
@jhannes
jhannes / GoogleForms-to-Trello.gs
Last active Aug 27, 2019
Google Forms to Trello
View GoogleForms-to-Trello.gs
var authentication = "key=a...&token=9...";
var idBoard = "592....";
var inboxList = "592...";
var updatedLabel = "592....";
function getField(itemResponses, fieldName) {
var titles = [];
for (var i in itemResponses) {
if (itemResponses[i].getItem().getTitle() === fieldName && itemResponses[i].getResponse().length > 0) {
@jhannes
jhannes / AnnotationScanner.java
Created Jan 16, 2015
Jetty 9 embedded Servlet 3.0 annotations without war file
View AnnotationScanner.java
public class AnnotationScanner {
protected void scanForAnnotations(final String javaPackage, WebAppContext webapp) throws Exception {
Set<AnnotationParser.Handler> handlers = new HashSet<>();
handlers.add(new WebServletAnnotationHandler(webapp));
handlers.add(new WebFilterAnnotationHandler(webapp));
handlers.add(new WebListenerAnnotationHandler(webapp));
AnnotationParser annotationParser = new AnnotationParser();
for (URL url : ((URLClassLoader) getClass().getClassLoader()).getURLs()) {
@jhannes
jhannes / package.json
Last active Aug 29, 2015
Promises you can trust
View package.json
{
"name": "promises",
"scripts": {
"test": "node node_modules/mocha/bin/mocha --watch --growl"
},
"devDependencies": {
"chai": "^1.10.0",
"mocha": "^2.0.1"
},
"dependencies": {
@jhannes
jhannes / AppConfiguration.java
Last active Oct 19, 2016
Dead simple configuration
View AppConfiguration.java
package com.johannesbrodwall.infrastructure;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;
View AdditionSolver.java
package no.something.ftas.solvers;
import no.something.ftas.QuestionSolver;
public class AdditionSolver extends QuestionSolver {
public AdditionSolver() {
super("Addition");
}
@jhannes
jhannes / CurrencyPublisherTest.java
Created Jul 16, 2012
Test driving external dependencies
View CurrencyPublisherTest.java
public class CurrencyPublisherTest {
private SubscriptionRepository subscriptionRepository = mock(SubscriptionRepository.class);
private EmailService emailService = mock(EmailService.class);
private CurrencyPublisher publisher = new CurrencyPublisher();
private CurrencyService currencyService = mock(CurrencyService.class);
private GeolocationService geolocationService = mock(GeolocationService.class);
@Test
public void shouldPublishCurrency() throws Exception {
@jhannes
jhannes / Xmldemo.java
Created Jun 26, 2012
Syntax proof-of-concept for XML library
View Xmldemo.java
public class Demo {
private static Object baseUrl;
public static void main(String[] args) {
Namespace SOAP_NS = new Namespace("http://soap.com", "SOAP");
Namespace MSG_NS = new Namespace("http://msg.com", "msg");
TagName envelopeTag = SOAP_NS.tag("Envelope");
Element envelope = envelopeTag.create(
View shopping.coffee
class ShoppingCart
constructor: (@items)->
@counts = (count for item,count of @items).sort().reverse()
totalPrice: -> @subTotal() - @discount()
subTotal: ->
result = 0
result += count*8 for item,count of @items
result
discount: ->
@discountForSetOfSize(2, 5) +
@jhannes
jhannes / Separate Solar and Bounce
Created Mar 18, 2012
Mikado "tree" for "space" exercise 2
View Separate Solar and Bounce
v Separate Solar system and bouncing ball logic
v Delete IS_BOUNCING_BALL flagg
v Move main method of Space to subclasses
v Create subclasses of "Space"
v Remove IS_BOUNCING_BALLS if-test in main
v Extract main method logic to non-static method
v Make IS_BOUNCING_BALLS into an argument
v Convert if statements into polymorphism
v Convert IS_BOUNCING_BALLS into non-static field in Space
v Move IS_BOUNCING_BALLS to Space
@jhannes
jhannes / minefield.coffee
Created Jan 26, 2012
CoffeeScript from irb.no 26th january
View minefield.coffee
class exports.Minefield
constructor: (@cells)->
hints: ->
((@hint(row,col) for col in @cols()).join("") for row in @rows())
rows: -> [0...@cells.length]
cols: -> [0...@cells[0].length]
hint: (row,col) ->
You can’t perform that action at this time.