This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* | |
* Today was on stackoverflow a question about how to convert a C++ source into | |
* Java source. The code was implementing a scoller like in the movie "The Matrix". | |
* | |
* As the question was not fulfilling the stackoverflow requirements for a valid | |
* questions, it has been deleted in the meantime by the moderators. Which is a | |
* little bit bad, as the code was nice. | |
* | |
* So I create this gist with my answer I would like to have posted to the |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.sun.tools.attach.VirtualMachine; | |
public class AttachClient { | |
public static void main(String[] args) throws Exception { | |
String pid = args[0]; | |
VirtualMachine vm = VirtualMachine.attach(pid); | |
System.out.println("vm = " + vm); | |
vm.detach(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ReportCpuCount { | |
public static void main(String[] args) throws Exception{ | |
while(true){ | |
System.out.printf("#Found %d CPUs%n", Runtime.getRuntime().availableProcessors()); | |
Thread.sleep(1000); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 <[email protected]> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
.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 |
OlderNewer