Riven :: code </> brain :: dump
share more code + it makes life hilarious
2012-06-21
HotSpot bug in Java 7u4, 7u5, 7u6(rc) with StringBuilder optimisation
›
I found an odd bug that seems to be related with the new Java7 optimisations regarding StringBuilder concatenation. The following code works...
2 comments:
2012-02-10
Bash script for simple port-knocking in iptables
›
This is a simple bash script that allows you to add (multiple) port-knocking rules into iptables. Usage is explained below. KNOCK_NAME =$1 ...
1 comment:
Reverse SSH tunnel in plain english...
›
Those tutorials explaining reverse SSH tunnels are ambiguous at best in their examples, often using the same port number twice, making it un...
2010-11-30
Java Continuations and Green Threads at native speeds
›
Continuations, or green threads, are a concept mostly seen in scripting languages. Green threads are just like native threads, but you can r...
1 comment:
2010-11-24
Lost four words...
(pro nouns)
›
It got cold while she called for juice from , not awaiting the tide and tied a tight knot. A scene never seen again, maybe missed due to th...
3 comments:
2010-08-19
Calculate PerlinNoise faster with an optimization to grad()
›
A simple optimization to the gradient function makes the noise function twice as fast. PerlinNoise.grad() inline float grad(int hash, flo...
8 comments:
2010-07-23
Rhino ClassShutter replacement: SandboxShutter
›
Because the ClassShutter in Rhino doesn't usually provide enough information to make decisions on whether or not certain Java objects, ...
9 comments:
2010-07-20
Functions on Iterables :: Consume
›
public class Functional { /** * Consumes (removes) all items while iterating */ public static <T> Iterable<T> ...
1 comment:
Functions on Iterables :: Event Hooks
›
public interface Operator { public void operate(T item); } public class Functional { /** * Performs a callback on each element-...
2 comments:
Functions on Iterables :: Transformer
›
public interface Transformer <I, O> { public O transform(I item); } public class Functional { /** * Transforms Iterable...
Functions on Iterables :: Filter
›
Functional programming has its strengths when iterating over data. If you want a view on a subset data, you can make a filter, and iterate ...
2010-04-29
Histogram :: array based
›
For any reasonably sized Histogram, you probably want to look at this Histogram class based on a HashMap . However, if your histograms are t...
Slicing direct buffers to workaround 4K overhead
›
Direct ByteBuffers can have an unexpected massive overhead. For every allocation, a number of bytes equal to the system pagesize (typically...
2010-02-23
Delaying security dialogs in Java until you need them
›
Delaying security dialogs in Java until you need them, is a bit harder than it should be. By default, the dialog appears before the first li...
1 comment:
2010-02-04
Image :: Java Animated GIFs (with transparant pixel disposal modes)
›
It's a nightmare to find the code to create animated GIFs in Java. Once you found it, you notice you can't set the frame disposal, a...
8 comments:
Image :: read/write TGA
›
public static BufferedImage readTGA (File file) throws IOException { if (!file.exists()) throw new FileNotFoundException(f...
6 comments:
FastMath :: fast floor + ceil
›
Calling Math.floor() simply takes too long. The problem with optimizing is that you can't simply cast the floatingpoint number to an int...
2 comments:
2009-10-26
Image :: read size of JPG/PNG/BMP/GIF
›
If you would believe Google, everybody is searching for code that reads the dimensions of an image,without loading all those colorful pixels...
2009-08-30
Graycode :: for analog stuff!
›
THIS WAS FUN. Proved the math teacher wrong. public class Graycode { public static int normalToGray (int orig) { int gray =...
Set :: binary operations
›
Everybody should have these. It's just a drag to rewrite it time and time again. public class SetUtil { public static <T> Se...
2 comments:
ArraySorter :: in-place, pre-calc
›
The point of this class is to pre-calculate the sort-order in advance, so that we're not comparing objects all the time, and then do a p...
Histogram :: map-based
›
public class Histogram <T> { private final Map<T, Integer> map; public Histogram () { this.map = new HashMap<...
Unsafe :: Pointers
›
private final static Unsafe unsafe; private static long addressOffset; private static long positionOffset; ...
2009-08-25
Thread :: monitor CPU usage
›
If you want to monitor CPU usage, per thread, things couldn't get easier! ThreadGroupMonitor gmonitor = new ThreadGroupMonitor(); whi...
Swappable Jar ClassLoader
›
So you have this pluggable stuff, and you want to support realtime loading of new classes. That's not so hard, but what if old classes t...
›
Home
View web version