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 java.util.Objects; | |
import java.util.regex.Pattern; | |
class IPRangeExpander { | |
private static final Pattern IPV4_PATTERN = Pattern.compile("^(([1-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){1}(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){2}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$"); | |
public void expand(String from, String to) { | |
if (from == null || to == null) { | |
throw new IllegalArgumentException( | |
"Invalid ip range: from " + from + " to " + to); |
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 java.io.ByteArrayInputStream; | |
import java.io.IOException; | |
import java.io.InputStream; | |
import java.util.Objects; | |
public class PrettyXmlInputStream extends InputStream { | |
private static final byte[] EMPTY_BYTES = new byte[0]; | |
private static final byte[] CLOSE_TAG_PREFIX = new byte[]{'<', '/'}; | |
private static final byte[] CDATA_PREFIX = "[CDATA[".getBytes(); | |
private static final byte[] CDATA_SUFFIX = new byte[]{']', '>'}; |
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 java.util.Arrays; | |
import java.util.Objects; | |
public class AsciiSequence implements CharSequence { | |
private static final AsciiSequence EMPTY_STRING = | |
new AsciiSequence(new byte[0]); | |
final byte[] value; | |
final int offset; | |
final int length; |
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 abstract class TerminableThread extends Thread { | |
private volatile boolean stopRequested; | |
private volatile boolean stopped; | |
public boolean isStopRequested() { | |
return stopRequested; | |
} | |
public boolean isStopped() { |
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.Math.abs; | |
import static java.lang.Math.acos; | |
import static java.lang.Math.cos; | |
import static java.lang.Math.sin; | |
import java.util.Arrays; | |
import java.util.LinkedList; | |
import java.util.List; | |
public class GeographyUtil { |
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
alias sbr='mvn clean && mvn spring-boot:run' | |
alias nem='emacs -nw' | |
alias ics='dpkg -l|grep' | |
alias rm='rm -i' | |
alias psef='ps -ef|grep' | |
alias gdd='git difftool -t meld -d' | |
alias psport='netstat -atnl|grep -P' | |
alias mcp='mvn clean package' | |
alias mcpnt='mcp -Dmaven.test.skip=true' | |
alias mcc='mvn clean compile' |
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
#!/bin/bash | |
for STYLE in 0 1 2 3 4 5 6 7; do | |
for FG in 30 31 32 33 34 35 36 37; do | |
for BG in 40 41 42 43 44 45 46 47; do | |
CTRL="\033[${STYLE};${FG};${BG}m" | |
echo -en "${CTRL}" | |
echo -n "${STYLE};${FG};${BG}" | |
echo -en "\033[0m" | |
done | |
echo |
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 java.io.File; | |
import java.security.cert.CertificateException; | |
import java.security.cert.X509Certificate; | |
import org.apache.http.HttpEntity; | |
import org.apache.http.client.methods.CloseableHttpResponse; | |
import org.apache.http.client.methods.HttpGet; | |
import org.apache.http.conn.ssl.DefaultHostnameVerifier; | |
import org.apache.http.conn.ssl.SSLConnectionSocketFactory; | |
import org.apache.http.impl.client.CloseableHttpClient; |
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
#!/bin/bash | |
_echo() { | |
echo | |
# echo $1 | |
echo $'\e[0;33m'"$1"$'\e[0m' | |
} | |
_check() { | |
[ $1 -eq 0 ] || exit $1 |
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
--- http://www.lua.org/pil/9.html | |
function producer() | |
return coroutine.create( | |
function() | |
while true do | |
local v = io.read() | |
coroutine.yield(v) | |
if not v then break end | |
end |
NewerOlder