Skip to content

Instantly share code, notes, and snippets.

View toomasr's full-sized avatar

Toomas Romer toomasr

View GitHub Profile
@toomasr
toomasr / ZipUtilPackMd5.java
Created July 23, 2018 07:56
Packing the same bytes twice
import java.io.File;
import java.math.BigInteger;
import java.nio.file.Files;
import java.security.MessageDigest;
import org.zeroturnaround.zip.ZipUtil;
public class ZipUtilPackMd5 {
public static void main(String[] args) throws Exception {
String fileName = "target/classes/ZipUtilPackMd5.class";
@toomasr
toomasr / Main.java
Created December 7, 2015 08:54
Shows how to generate a CLI progress bar for a zt-zip
package com.toomasr.zip.progressbar;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.HashSet;
import java.util.Random;
import java.util.Set;
@toomasr
toomasr / gist:837306d7dd232fb49b2b
Created July 24, 2014 19:18
Slow Version Hotspot Log
This file has been truncated, but you can view the full file.
<?xml version='1.0' encoding='UTF-8'?>
<hotspot_log version='160 1' process='36101' time_ms='1406227677585'>
<vm_version>
<name>
Java HotSpot(TM) 64-Bit Server VM
</name>
<release>
25.5-b02
</release>
<info>
@toomasr
toomasr / gist:14cbc5de0ef24417f728
Created July 24, 2014 19:16
Fast Version Assembly
<task_queued compile_id='50' compile_kind='osr' method='ProjectEuler14 main ([Ljava/lang/String;)V' bytes='164' count='1' backedge_count='60416' iicount='1' osr_bci='28' level='3' stamp='0.550' comment='tiered' hot_count='60416'/>
<writer thread='19459'/>
Decoding compiled method 0x0000000104ae5210:
Code:
[Constants]
0x0000000104ae5620 (offset: 0): 0x00000000 0x408f400000000000
0x0000000104ae5624 (offset: 4): 0x408f4000
0x0000000104ae5628 (offset: 8): 0xf4f4f4f4 0xf4f4f4f4f4f4f4f4
0x0000000104ae562c (offset: 12): 0xf4f4f4f4
0x0000000104ae5630 (offset: 16): 0xf4f4f4f4 0xf4f4f4f4f4f4f4f4
This file has been truncated, but you can view the full file.
<?xml version='1.0' encoding='UTF-8'?>
<hotspot_log version='160 1' process='35933' time_ms='1406226948773'>
<vm_version>
<name>
Java HotSpot(TM) 64-Bit Server VM
</name>
<release>
25.5-b02
</release>
<info>
import java.io.File;
import org.zeroturnaround.zip.NameMapper;
import org.zeroturnaround.zip.ZipUtil;
public class ZipUtilTest {
public static void main(String[] args) {
// file to unpack
File input = new File("/Users/toomasr/tmp/zipTest.zip");
// folder to store the unpacked files
@toomasr
toomasr / nginx.conf
Created January 4, 2013 12:20
nginx configuration for the Wordpress blog post
upstream servers-frontend {
ip_hash;
server 10.10.137.100:80; # server-1
server 10.10.126.101:80; # server-2
}
upstream server-2 {
server 10.10.137.101:80;
}
@toomasr
toomasr / blog.md
Created November 2, 2012 13:26 — forked from aslakknutsen/blog.md
Import your project's history in Sonar

When you do your first Sonar run on your project, you get a lot of new quality numbers to play with, but no trends. You only have one data set for comparison, the now picture.

Wouldn't it be nice if you could see the current trend of the project without waiting a couple of month for the 'daily/weekly' Sonar runs to fill up the data? Well, you're in luck! And if you're using Mercurial as a version system as well, this is your day. :)

In the Sonar Advanced Parameter documentation you will find a System Property called sonar.projectDate. The property let you tell Sonar when in time the running analysis was ran.

By combining this property and what your version system does best, track changes to source, we can now play back the history of the project as far as Sonar is concerned.

This little Bash script illustrates the concept. To spell out what it does in human readable form:

@toomasr
toomasr / tomcat.sh
Created October 15, 2012 14:42
Tomcat startup script - should work :)
#!/bin/bash
#
# Tomcat - stops and starts Tomcat
#
### BEGIN INIT INFO
# Provides: tomcat
# Required-Start: $network $syslog
# Required-Stop: $network $syslog
# Default-Start:
# Default-Stop:
@toomasr
toomasr / jf-convert.java
Created September 29, 2012 15:56
Quick convert
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
public class ConvertJF {
public static void main(String[] args) throws Exception {
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader bf = new BufferedReader(isr);