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
#!/bin/bash | |
set -ex | |
# I am on server A | |
sshpass -e ssh -o PubkeyAuthentication=no -o StrictHostKeyChecking=no "${SSH_USERNAME}@${SERVER_B}" <<EOF | |
# Now I am on server B | |
export SSH_USERNAME=$SSH_USERNAME # Copy env. variable from server A to server B | |
export SERVER_C=$SERVER_C # Copy env. variable from server A to server B | |
export SSHPASS=$SSHPASS # INSECURE!! copy env. variable from server A to server B |
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
package util; | |
import java.util.regex.Matcher; | |
import java.util.regex.Pattern; | |
public final class ActiveDirectoryUtils { | |
private static final Pattern ERROR_CODE = Pattern.compile(".*LDAP: error code\\s([0-9]*).*data\\s([0-9a-f]{3,4}).*"); | |
public static final int USERNAME_NOT_FOUND = 0x525; |
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
package util; | |
import java.util.Arrays; | |
import java.util.function.Supplier; | |
public final class Util { | |
/** | |
* Retry to run a function a few times, retry if specific exceptions occur. | |
* |
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
error() { | |
local parent_lineno="$1" | |
local message="$2" | |
local code="${3:-1}" | |
if [[ -n "$message" ]] ; then | |
echo "Error on or near line ${parent_lineno}: ${message}; exiting with status ${code}" | |
else | |
echo "Error on or near line ${parent_lineno}; exiting with status ${code}" | |
fi | |
MIN_LINE=$(($parent_lineno - 5 > 0 ? $parent_lineno - 5 : 1)) |
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
Interesting Links: | |
Web cache explained: | |
http://www.mnot.net/cache_docs/ | |
RedBot - Cache control validation: | |
http://redbot.org/ | |
Dremel: Interactive Analysis of Web-Scale Datasets | |
http://research.google.com/pubs/pub36632.html |
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
insert into counter_hourly(DataCenter,Env,HostName,CustomerID,Hour,TotalRequests,TotalLatency,TotalBytes) | |
values | |
('DC1','ENV2','NTC-CLFSTGAPP3','Lic_ID1','2012-8-23 10:00','11','2190','8822') | |
on duplicate key update | |
`TotalRequests` = `TotalRequests` + '11' , | |
`TotalLatency` = `TotalLatency` + '2190' , | |
`TotalBytes` = `TotalBytes` + '8822' | |
; | |
-- Here's the DDL used to create this table. |
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
List<String> values = [] | |
int start, stop | |
// Quickly parse TSV line | |
while (true) { | |
stop = line.indexOf('\t', start) | |
if (stop < 0) break; | |
values.push(line.substring(start, stop)) | |
start = stop + 1 | |
} |
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
long contentLength = doc.getContentLength() // never mind where the long value comes from. | |
// Classify doc size. Notice that numbers in map's key have to be ordered (TreeMap) and last key should be Integer.MAX_VALUE: | |
// This is map of max length size value to a string describing this group | |
def docGroupMap = new TreeMap([2048:'0-2 KB', 5120:'2-5 KB', 10240:'5-10 KB', (Integer.MAX_VALUE): '10+ KB']) | |
// The find() method iterates the map and checks every key with the expression in its closure-parameter. | |
// Since TreeMap is used, the keys are ordered. | |
// Once the expression is true, the value is being assigned to the string. |