Skip to content

Instantly share code, notes, and snippets.

Avatar

Simon Schmidt maxymania

View GitHub Profile
@maxymania
maxymania / PDF_Units.java
Created Apr 14, 2020
The units for Unit to Inch Conversion
View PDF_Units.java
// https://stackoverflow.com/questions/21520015/pdfbox-converting-inches-or-centimeters-into-the-coordinate-system
private static final int DEFAULT_USER_SPACE_UNIT_DPI = 72;
private static final float MM_TO_UNITS = 1/(10*2.54f)*DEFAULT_USER_SPACE_UNIT_DPI;
@maxymania
maxymania / hyperswitch.js
Last active Dec 10, 2019
NodeJS Hyperswarm utility.
View hyperswitch.js
/*
Copyright (C) 2019 Simon Schmidt
Usage of the works is permitted provided that this instrument is retained with
the works, so that any entity that uses the works is notified of this instrument.
DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
*/
const hyperswarm = require('hyperswarm');
@maxymania
maxymania / liner.js
Last active Dec 11, 2019
NodeJS Line Reader using async/await
View liner.js
/*
Copyright (C) 2019 Simon Schmidt
Usage of the works is permitted provided that this instrument is retained with
the works, so that any entity that uses the works is notified of this instrument.
DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
*/
const EventEmitter = require('events');
@maxymania
maxymania / SplitterLib.java
Created Sep 23, 2019
Unicode-Splitter in java.
View SplitterLib.java
// Public Domain!
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.IntFunction;
import java.util.function.IntPredicate;
import org.jparsec.Parser;
import org.jparsec.Parsers;
import org.jparsec.pattern.CharPredicate;
import org.jparsec.pattern.Pattern;
import org.jparsec.pattern.Patterns;
@maxymania
maxymania / NioTransport.java
Last active Nov 27, 2019
Netty Bootstrap/Server Bootstrap abstraction
View NioTransport.java
// Public Domain!
import io.netty.bootstrap.Bootstrap;
import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandler;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.ServerChannel;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioServerSocketChannel;
import io.netty.channel.socket.nio.NioSocketChannel;
@maxymania
maxymania / OggDecoder.java
Last active Jan 23, 2019
Ogg Stream segmenter for netty (4.1.32)
View OggDecoder.java
/*
Copyright (c) 2019 Simon Schmidt
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
View osmselect.go
package main
import "context"
import "github.com/paulmach/osm"
import "github.com/paulmach/osm/osmpbf"
import "github.com/paulmach/osm/osmxml"
import "encoding/xml"
import "fmt"
@maxymania
maxymania / Logarithm.go
Last active Nov 4, 2018
Logarithm of 2 (Algorithm)
View Logarithm.go
package main
import "fmt"
import "math"
func log2(f float64) (float64) {
frac, exp := math.Frexp(f)
exp--
frac*=2
log := float64(0)
@maxymania
maxymania / A.md
Last active Sep 28, 2018
Invokedynamic
View A.md
@maxymania
maxymania / MethodSelector.java
Last active Sep 28, 2018
Reflection, Method selector like the java compiler
View MethodSelector.java
// TODO: insert your package name here!
package your.packag.e.name.here;
/*
* The ZLIB license (with two restrictions removed).
*
* Copyright 2018 Simon Schmidt.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
You can’t perform that action at this time.