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.net.*; | |
import java.io.*; | |
/* PROXY SETTINGS */ | |
System.getProperties().put("proxySet", "true"); | |
System.getProperties().put("proxyHost", "some.proxyserver.com"); | |
System.getProperties().put("proxyPort", "8080"); | |
Authenticator.setDefault(new MyAuthenticator()); | |
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.net.URL; | |
import java.security.SecureRandom; | |
import java.security.cert.CertificateException; | |
import java.security.cert.X509Certificate; | |
import javax.net.ssl.HostnameVerifier; | |
import javax.net.ssl.HttpsURLConnection; | |
import javax.net.ssl.KeyManager; | |
import javax.net.ssl.SSLContext; | |
import javax.net.ssl.SSLSession; | |
import javax.net.ssl.TrustManager; |
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
Latency Comparison Numbers | |
-------------------------- | |
L1 cache reference 0.5 ns | |
Branch mispredict 5 ns | |
L2 cache reference 7 ns 14x L1 cache | |
Mutex lock/unlock 25 ns | |
Main memory reference 100 ns 20x L2 cache, 200x L1 cache | |
Compress 1K bytes with Zippy 3,000 ns | |
Send 1K bytes over 1 Gbps network 10,000 ns 0.01 ms | |
Read 4K randomly from SSD* 150,000 ns 0.15 ms |
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/python | |
""" | |
Import Github issues from one repo to another. | |
The orignal work: https://github.com/mkorenkov/tools/blob/master/gh-issues-import/gh-issues-import.py | |
(assuming public domain license). | |
Used to migrate Github's Plone Conference 2012 temporary repository | |
to collective.developermanual issues. |
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
Map.metaClass.collectWithIndex = { yield -> | |
def collected = [] | |
delegate.eachWithIndex { key, value, index -> | |
collected << yield(key, value, index) | |
} | |
return collected | |
} | |
assert [a: 1, b: 1, c: 1].collectWithIndex { key, value, index -> key + value + index } == ["a10", "b11", "c12"] |
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
/* | |
* Initialize console object used for logging in javascript code. | |
* For case when console object is not present (old browsers) use dump implementation. | |
*/ | |
window.console = window.console || {}; // in old browsers like IE7 there is no console object | |
console.info = console.info || function() {}; | |
console.error = console.error || function() {}; | |
console.warn = console.warn || function() {}; |
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
def generateMD5(String s) { | |
MessageDigest digest = MessageDigest.getInstance("MD5") | |
digest.update(s.bytes); | |
new BigInteger(1, digest.digest()).toString(16).padLeft(32, '0') | |
} |
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
${import1:import(org.slf4j.Logger)} | |
${import2:import(org.slf4j.LoggerFactory)} | |
private static final Logger LOG = LoggerFactory.getLogger(${enclosing_type}.class); |
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.text.Collator; | |
import java.util.Comparator; | |
import java.util.List; | |
import java.util.Locale; | |
import org.apache.wicket.Session; | |
import org.apache.wicket.markup.html.form.DropDownChoice; | |
import org.apache.wicket.markup.html.form.IChoiceRenderer; | |
import org.apache.wicket.model.IModel; |
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 final class StringUtils { | |
private StringUtils() { /* cannot be instantiated */ } | |
/** | |
* <b>WORKS ONLY IN JAVA 1.6 AND ABOVE !!!</b> | |
* | |
* @param textWithDiacritic | |
*/ | |
public static String removeDiacritics(String textWithDiacritic) { |