This file contains hidden or 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 java.util.concurrent.ForkJoinPool; | |
import java.util.concurrent.RecursiveTask; | |
/** | |
* Solve a computing task with the ForkJoin framework. | |
*/ | |
public class MyForkJoinPool { | |
private static final int NTHREADS = 10; |
This file contains hidden or 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 java.io.*; | |
/** | |
* Serialize and deserialize an object. Also demonstrates how constructors are invoked on deserialization. | |
*/ | |
public class SerializeDeserialize { | |
public static void main(String[] args) throws IOException, ClassNotFoundException { | |
Bar myBar = new Bar(); |
This file contains hidden or 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 java.io.BufferedWriter; | |
import java.io.IOException; | |
import java.nio.charset.Charset; | |
import java.nio.file.*; | |
import java.util.ArrayList; | |
import java.util.List; | |
import static java.nio.file.StandardOpenOption.*; | |
import static java.nio.file.StandardCopyOption.*; |
This file contains hidden or 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
class OldStyle(): | |
def __init__(self): | |
print "Init old style" | |
def func(self, arg): | |
print "Invoked old func with: {}".format(arg) | |
class NewStyle(object): |
This file contains hidden or 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 Java8ParallelStream { | |
public static void main(String[] args) { | |
List<String> values = new ArrayList<>(); | |
int max = 1000000; | |
for (int i = 0; i < max; i++) { | |
UUID id = UUID.randomUUID(); | |
values.add(id.toString()); | |
} | |
NoArgsFunction sequential = () -> values.stream().sorted().count(); |
This file contains hidden or 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 java.lang.annotation.ElementType; | |
import java.lang.annotation.Retention; | |
import java.lang.annotation.RetentionPolicy; | |
import java.lang.annotation.Target; | |
import java.lang.reflect.Method; | |
public class TestRunner { | |
public static void main(String[] args) { | |
System.out.println("Testing..."); |
This file contains hidden or 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.org.apache.xml.internal.security.utils.Base64; | |
import javax.crypto.*; | |
import javax.crypto.spec.IvParameterSpec; | |
import javax.crypto.spec.PBEKeySpec; | |
import javax.crypto.spec.SecretKeySpec; | |
import java.io.UnsupportedEncodingException; | |
import java.security.*; | |
import java.security.spec.InvalidKeySpecException; | |
import java.security.spec.InvalidParameterSpecException; |
This file contains hidden or 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
@Configuration | |
@ComponentScan(basePackages = "sen.ansig.spring") | |
@PropertySource("classpath:config.properties") | |
@PropertySource(value = "file:${config.path:config.properties}", ignoreResourceNotFound = true) | |
public class MySpringAppWithProperties { | |
} |
This file contains hidden or 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
#!/usr/bin/env bash | |
######################################################################################################## | |
# This is a utility script to fetch artifacts from a Nexus server. It is based on an example # | |
# from Sonartype Nexus: http://blog.sonatype.com/2011/01/downloading-artifacts-from-nexus-with-bash/ # | |
######################################################################################################## | |
set -e | |
REST_PATH=/service/local |
This file contains hidden or 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
Closure envVar(String key, String val) { | |
return { | |
it / 'buildWrappers' / 'EnvInjectBuildWrapper' / 'info' << { | |
propertiesContent("${key}=${val}") | |
} | |
} | |
} | |
Closure secureGroovyScript(String scriptText, boolean useSandbox) { | |
return { |