Skip to content

Instantly share code, notes, and snippets.

Johannes Thönes jthoenes

Block or report user

Report or block jthoenes

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View keybase.md

Keybase proof

I hereby claim:

  • I am jthoenes on github.
  • I am jthoenes (https://keybase.io/jthoenes) on keybase.
  • I have a public key ASBIR_vSjbR9LDgTFLo0QjlYNRCeUTfOXANacPlKejf5ogo

To claim this, I am signing this object:

@jthoenes
jthoenes / command.sh
Created Aug 20, 2018
Create list of AWS IP ranges (ec2, in Frankfurt) for OpenVPN config
View command.sh
curl -s https://ip-ranges.amazonaws.com/ip-ranges.json | jq -r '.prefixes[] | select(.service=="EC2") | select(.region=="eu-central-1") | .ip_prefix' | xargs -I {} ipcalc -nb {} | awk 'BEGIN {RS="";FS="\n"}{print $1, $2}' | awk '{print "route", $2, $4, "vpn_gateway"}'
View report.js
// http://www.highcharts.com/docs/export-module/render-charts-serverside
'use strict';
var PdfPrinter = require('pdfmake'),
printer,
moment = require('moment-timezone'),
path = require('path'),
fs = require('fs');
function resolvePath(relative) {
@jthoenes
jthoenes / imageStorage.js
Created Mar 13, 2014
API for image storage function of Redactor Feature Request
View imageStorage.js
var storeImageLocally = function(imageFile, callback){
// result of asynchronous call which will store the file
var result = {
localUrl: 'filesystem:http://localhost:9000/persistent/someImage.jpg',
imageId: 'generated uid'
}
// call the callback with html to insert into redactor
callback('<img src="'+result.localUrl+'" data-image-id="'result.imageId'">');
}
View Gemfile
group :test do
gem 'cucumber'
gem 'capybara'
gem 'poltergeist'
gem 'rspec'
end
@jthoenes
jthoenes / LambdaIntro.java
Created Aug 1, 2012
Testing the Lambda Water
View LambdaIntro.java
package net.jthoenes.blog.spike.lambda;
import java.util.Arrays;
import java.util.List;
public class LambdaIntro {
public static interface ItemWithIndexVisitor<E> {
public void visit(E item, int index);
View attempt_on_correct_error_handling.java
finally {
try {
if (resultSet != null) {
resultSet.close();
}
} catch (SQLException ex) {
logger.error("Error in Database", ex);
} finally {
try {
View heap_pollution_on_varargs.java
public static <l> L[] createHeapPollution(L... args) {
Object[] elements = args;
elements[0] = Arrays.asList(12, 12);
return args;
}
public static void main(String... args) {
List<string>[] polluted = createHeapPollution(Arrays.asList("a", "b", "c"));
// java.lang.Integer cannot be cast to java.lang.String
You can’t perform that action at this time.