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/env bash | |
# git branch freshness test. | |
# branch-rot.sh [expiration-date-epoc-seconds] | |
# default expiration date is about one month ago | |
# seconds*minutes*hours*days*weeks*months ~ one month ago | |
expiration_date=$(( $(date +%s) - 60*60*24*7*4 )) | |
if [[ $# -eq 1 ]]; then | |
expiration_date=$1 | |
fi |
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
require 'net/http' | |
def instance_zone | |
uri = URI("http://metadata.google.internal/computeMetadata/v1/instance/zone") | |
req = Net::HTTP::Get.new(uri) | |
req['Metadata-Flavor'] = 'Google' | |
begin | |
resp = Net::HTTP.start(uri.hostname, uri.port) { |http| http.request(req) } | |
resp.body.split("/").last | |
rescue Exception => msg | |
puts "failed to request instance zone: #{msg}" |
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
# vscode rust seti[ | |
use vscode-rust ( not rusty ) | |
rustup component install rust-src | |
rustup component install rust-docs | |
rustup update | |
rustup which rust-src ( save this path ) | |
cargo install --force racer | |
cargo install --force rustfmt | |
cargo install --force rustsym |
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 | |
jarfile1=$1 | |
jarfile2=$2 | |
tmpdir=`mktemp -d -t jiff-XXX` | |
echo $tmpdir | |
mkdir -p $tmpdir/{dir1,dir2} | |
cp $jarfile1 $tmpdir/dir1 | |
cp $jarfile2 $tmpdir/dir2 | |
cd $tmpdir/dir1 | |
jar xvf $(basename $jarfile1) |
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
// env! gets inserted at compile time, not run time | |
// https://doc.rust-lang.org/std/macro.env.html | |
const BUILD: &str = env!("BUILD_NUM"); | |
fn main() { | |
println!("was built with {}", BUILD); | |
} |
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 | |
# prints differences in files | |
first=$1 | |
second=$2 | |
diff \ | |
<(tar -tvf $first | awk '{printf "%10s %-100s %s\n",$3,$6,$1}'|sort -k2) \ | |
<(tar -tvf $second |awk '{printf "%10s %-100s %s\n",$3,$6,$1}'|sort -k2) |
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 | |
bazel query --noimplicit_deps 'kind("(scala|java)_*", deps(//...))' --output graph > build.dot | |
dot -Tpng < build.dot > build.png |
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
# starts, when needed, a daemonized bazel container which receives | |
# sets of bazel arguments | |
docker_bazel() { | |
local project=$(echo $PWD | base64) | |
project=${project%%=*} | |
docker inspect bazel-$project >/dev/null | |
if [ $? -ne 0 ]; then | |
docker run --privileged=true -d -it --name bazel-$project -v "$PWD":/usr/src/app insready/bazel | |
if [ $? -ne 0 ]; then | |
echo "failed to start bazel container. bailing" |
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
struct Config { | |
secret: String, | |
coolfactor: f32, | |
prize: Option<usize> | |
} |
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
extern crate envy; | |
use std::env; | |
#[derive(Deserialize, Debug)] | |
struct Config { | |
secret: String, | |
coolfactor: f32, | |
prize: Option<usize> | |
} |