Skip to content

Instantly share code, notes, and snippets.

View MoriTanosuke's full-sized avatar

Carsten MoriTanosuke

View GitHub Profile
@MoriTanosuke
MoriTanosuke / Dockerfile
Last active August 29, 2015 14:15 — forked from jerodsanto/Rakefile
Create HTML files from your Trello boards. - http://thechangelog.com/trello-as-a-cms/
FROM ubuntu
RUN DEBIAN_FRONTEND=noninteractive apt-get update -y && apt-get install rake
RUN mkdir -p /data
COPY . /data
@MoriTanosuke
MoriTanosuke / Dockerfile
Created December 12, 2014 12:47
Simple docker file to install and run IntelliJ Upsource
FROM debian:stable
EXPOSE 8080
RUN apt-get -y update && apt-get -y upgrade && apt-get -y install unzip wget openjdk-7-jdk
RUN wget -q http://download.jetbrains.com/upsource/upsource-1.0.12551.zip && unzip upsource-1.0.12551.zip
RUN cd Upsource && ./bin/upsource.sh start
@MoriTanosuke
MoriTanosuke / ConvertXmlToRouteDefinitionTest.java
Last active August 29, 2015 14:09
Simple JUnit test to demonstrate how to get a RouteDefinition object from XML for Apache Camel.
import org.apache.camel.impl.DefaultCamelContext;
import org.apache.camel.model.RouteDefinition;
import org.apache.camel.model.RoutesDefinition;
import org.junit.Test;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
@MoriTanosuke
MoriTanosuke / GreenApplesTest.java
Last active August 29, 2015 14:05
A simple junit test with language elements of the Java 8 Stream API.
import org.junit.Before;
import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import static org.junit.Assert.assertEquals;
public class SortApplesTest {
@MoriTanosuke
MoriTanosuke / StoneWall.java
Created June 29, 2014 12:27
Minecraft Mod Snippets
package net.kaldarin.compilation;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.BlockFence;
import net.minecraft.block.BlockWall;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
@MoriTanosuke
MoriTanosuke / index.hbs
Created April 10, 2014 10:06
Featuring posts with Ghost 0.4.x
{{! Display featured posts at the top }}
{{#foreach posts}}
{{#if featured}}
<article class="{{post_class}} .featured">
<header class="post-header">
<span class="post-meta"><time datetime="{{date format='YYYY-MM-DD'}}">{{date format="DD MMM YYYY"}}</time> {{#if tags}}on {{tags}}{{/if}}</span>
<h2 class="post-title"><img src="/assets/images/emoji/star.png" class="featured" title="featured post" alt="featured post" /><a href="{{url}}">{{{title}}}</a></h2>
</header>
<section class="post-social">
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# All Vagrant configuration is done here. The most common configuration
# options are documented and commented below. For a complete reference,
# please see the online documentation at vagrantup.com.
@MoriTanosuke
MoriTanosuke / Login.java
Last active December 30, 2015 13:59
Example code for my blog post on Fitbit webapp example
get(new Route("/login") {
@Override
public Object handle(Request request, Response response) {
if (request.queryParams("completeAuthorization") != null) {
// Get temporary token and verifier returned by Fitbit from query string
String tempTokenReceived = request.queryParams("oauth_token");
String tempTokenVerifier = request.queryParams("oauth_verifier");
// Fetch user credentials from cache by temporary token from query string
APIResourceCredentials resourceCredentials = fitbit.getResourceCredentialsByTempToken(tempTokenReceived);
// Call method of Fitbit4J to get token credentials only if necessary (they haven't been cached yet)
@MoriTanosuke
MoriTanosuke / Base64OutputStreamTest.java
Created October 24, 2013 01:37
Simple unit test showing kind of surprising behavior of Base64OutputStream. Basically, you *have* to call #close() on the OutputStream to get valid base64. After stumbling upon this I switched to Base64InputStream, because I can not close the Input/OutputStreams in my original code as I have to write additional non-base64 bytes into them too.
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import org.apache.commons.codec.binary.Base64InputStream;
@MoriTanosuke
MoriTanosuke / jekyll.groovy
Last active January 11, 2020 22:56
This is a simple post-receive-hook Groovy script for gitblit.
import com.gitblit.GitBlit
import com.gitblit.Keys
import com.gitblit.models.RepositoryModel
import com.gitblit.models.TeamModel
import com.gitblit.models.UserModel
import com.gitblit.utils.JGitUtils
import com.gitblit.utils.StringUtils
import java.text.SimpleDateFormat
import org.eclipse.jgit.api.CloneCommand
import org.eclipse.jgit.api.Git