Skip to content

Instantly share code, notes, and snippets.

View simonharrer's full-sized avatar
🏠
Mob Programming from my Home Office

Dr. Simon Harrer simonharrer

🏠
Mob Programming from my Home Office
View GitHub Profile
# ARGS
url = "TODO"
username = "TODO"
password = "TODO"
folder = "TARGET_FOLDER"
# LOGIC
require "fileutils"
FileUtils.rm_rf folder
FileUtils.mkdir folder
@simonharrer
simonharrer / build.gradle
Created August 5, 2015 12:41
How to convert a SVG to a PNG in a gradle build script.
configurations {
rasterizer
}
dependencies {
rasterizer 'org.apache.xmlgraphics:batik-rasterizer:1.7'
rasterizer 'org.apache.xmlgraphics:batik-codec:1.7'
}
task svg2png(type: org.gradle.api.tasks.JavaExec) {
classpath configurations.rasterizer
main "org.apache.batik.apps.rasterizer.Main"
@simonharrer
simonharrer / duplicate-finder.rb
Created September 16, 2015 15:21
Finds duplicate files in sibling folders
result = {}
Dir.glob("*").each do |dir|
result[dir] = Dir.glob("#{dir}/**/*").to_a.select {|p| File.file?(p)}.map {|p| p[dir.length..-1]}
end
puts "#{result.count} dirs found"
result.each do |key, value|
result.each do |key2, value2|
@simonharrer
simonharrer / gist:1006407
Created June 3, 2011 14:18
jruby on rails with sqlite3 on windows config
# Use simple JRuby 1.6.3 and Rails 3.0.7 to work on windows with sqlite3
# Add these gems to enable using jruby with sqlite3
gem 'activerecord-jdbcsqlite3-adapter'
gem 'jdbc-sqlite3'
gem 'jruby-openssl'
# Use old rake to let it work
gem 'rake', '0.8.7'
@simonharrer
simonharrer / gist:1173228
Created August 26, 2011 11:29
Use JRuby to create a Java Soap Web Service
require 'java'
require 'jruby/core_ext'
module WS
class WebService
def test()
puts "Call received at #{Time.new}"
# x = Result.new
# x.name = "asdf"
# return x
@simonharrer
simonharrer / gist:1322165
Created October 28, 2011 12:33
Calculation of the possibilities having three processes with 3, 3 and 2 steps being interleaved.
import groovy.util.PermutationGenerator;
import java.util.LinkedList;
import java.util.List;
import com.google.common.collect.Ordering;
public class Choice {
public static void main(String[] args) {
@simonharrer
simonharrer / gist:1525101
Created December 27, 2011 21:04
Reading Image Metadata from an image file
package de.feki.layout.timeinserter;
import java.io.File;
import java.io.IOException;
import java.io.StringWriter;
import javax.imageio.ImageIO;
import javax.imageio.ImageReader;
import javax.imageio.metadata.IIOMetadata;
import javax.xml.transform.OutputKeys;
@simonharrer
simonharrer / clean.bat
Created March 5, 2012 10:05
Latex cleanup file
rm *.aux
rm *.bbl
rm *.log
rm *.pdf
rm *.pgf
rm *.dvi
rm *.synctex*
rm *.toc
rm *.blg
@simonharrer
simonharrer / RecursiveUnzipper.groovy
Created June 20, 2012 11:43
Extracts zip files recursively to enable deep comparison of zips within zip files.
/**
* Extracts zip files recursively (zips within zip files too).
*/
class RecursiveUnzipper {
public static void main(String[] args) {
if(args != 3){
println "Usage: TARGET LEFT RIGHT"
}
@simonharrer
simonharrer / XmlAnalyzer.groovy
Created June 21, 2012 14:13
Counting the nodes in an xml file
class XmlAnalyzer {
public static final String[] commonNodes = ["process", "partnerLinks", "partnerLink", "variable", "variables", "import"]
public static void main(String[] args) {
if(args.length != 2){
throw new IllegalArgumentException("Usage: PATH EXTENSION")
}
analyzeFilesInDirectory(new File(args[0]),args[1])