Skip to content

Instantly share code, notes, and snippets.

View SubOptimal's full-sized avatar
🤓
the joy of coding - happy hacking

Frank Dietrich SubOptimal

🤓
the joy of coding - happy hacking
View GitHub Profile
@SubOptimal
SubOptimal / solution
Created September 12, 2014 10:18
Java "Hello World" without keyword "class"
# Linux / Mac
echo 'java.lang.System.out.println("Hello World")' | java -cp ${JAVA_HOME}/lib/tools.jar com.sun.tools.script.shell.Main
# Windows
echo java.lang.System.out.println("Hello World") | java -cp %JAVA_HOME%/lib/tools.jar com.sun.tools.script.shell.Main
@SubOptimal
SubOptimal / Targz.java
Created October 31, 2014 08:49
extract a tar file with multibyte and reserved characters in filename on Windows
// anser for: http://stackoverflow.com/questions/26656427/how-to-extract-tar-gz-including-multi-byte-characters-and-prohibited-characters
package tar;
import org.apache.tools.tar.*;
import java.io.*;
import java.nio.file.*;
import java.util.zip.GZIPInputStream;
public class Targz {
package sub.optimal.benchmark;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Random;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Fork;
@SubOptimal
SubOptimal / pom.xml
Last active October 13, 2015 18:59
execute SquirrelSql with `mvn exec:exec -Dexec.executable="java"``
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>sub.optimal</groupId>
<artifactId>SquirrelSqlCLI</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
@SubOptimal
SubOptimal / tooltip.ps1
Created October 19, 2015 07:55
fix locked taskbar autohide in Windows
# sometimes the autohide of the Windows taskbar doesn't work anymore
# and the taskbar is showed permanently
#
# beside killing and restarting the explorer.exe process it's enough
# forcing to display a new tooltip
[reflection.assembly]::loadwithpartialname("System.Windows.Forms")
[reflection.assembly]::loadwithpartialname("System.Drawing")
$notify = new-object system.windows.forms.notifyicon
$notify.icon = [System.Drawing.SystemIcons]::Information
$notify.icon = [System.Drawing.SystemIcons]::Error
import static java.lang.System.out;
import java.lang.reflect.Field;
import java.util.AbstractList;
import java.util.ArrayList;
/**
* Related to an answer to this Twitter post
* https://twitter.com/JosePaumard/status/864938907183480832
*
* @author Frank Dietrich <Frank.Dietrich@gmx.li>
@SubOptimal
SubOptimal / InterceptorThing.ps1
Created January 31, 2018 06:45
Interceptor - Normal User No Admin Required.
<#
.SYNOPSIS
This script demonstrates the ability to capture and tamper with Web sessions.
For secure sessions, this is done by dynamically writing certificates to match the requested domain.
This is only proof-of-concept, and should be used cautiously, to demonstrate the effects of such an attack.
Function: Interceptor
Author: Casey Smith, Twitter: @subTee
License: BSD 3-Clause
@SubOptimal
SubOptimal / RomanNumber.java
Created March 8, 2018 23:33
roman numerals converter
import java.util.HashMap;
import java.util.Map;
public class RomanNumber {
static final Map<Character, Integer> ROMAN_NUMERALS;
static {
HashMap<Character, Integer> m = new HashMap<>();
m.put('I', 1);
@SubOptimal
SubOptimal / Tuples.java
Created November 30, 2018 09:11
tuples in Java streams
// as long answer to https://twitter.com/pivovarit/status/1067883547669815296
import java.lang.reflect.Field;
import java.util.Arrays;
class Tuples {
public static void main(String... args) throws NoSuchFieldException, IllegalAccessException {
new Tuples().exec();
}
@SubOptimal
SubOptimal / GitHub Flavored Asciidoc (GFA).adoc
Created February 8, 2019 14:07 — forked from dcode/GitHub Flavored Asciidoc (GFA).adoc
Demo of some useful tips for using Asciidoc on GitHub

GitHub Flavored Asciidoc (GFA)