Skip to content

Instantly share code, notes, and snippets.

#! /bin/bash
EC2_METADATA=http://169.254.169.254/latest
REGION=$(curl -s $EC2_METADATA/dynamic/instance-identity/document | jq -r '.region')
INSTANCE_ID=$(curl -s $EC2_METADATA/meta-data/instance-id);
INSTANCE_IP=$(curl -s $EC2_METADATA/latest/meta-data/local-ipv4);
cat > /etc/init.d/cloudmap-register <<-EOF
#! /bin/bash -ex
aws servicediscovery register-instance \
@chrisalbright
chrisalbright / gist:a9fa47ef09a2daa2ca5c9aca1fc73207
Created September 10, 2020 19:21 — forked from Miserlou/gist:11500b2345d3fe850c92
1000 Largest US Cities By Population
Largest 1000 Cities in America
2013 popuation data - Biggest US Cities By Population
rank,city,state,population,2000-2013 growth
1,New York,New York,8405837,4.8%
2,Los Angeles,California,3884307,4.8%
3,Chicago,Illinois,2718782,-6.1%
4,Houston,Texas,2195914,11.0%
5,Philadelphia,Pennsylvania,1553165,2.6%
@chrisalbright
chrisalbright / TypeClass.scala
Created May 28, 2019 20:34
Exploration of Type Classes in Scala
/**
* I'm trying to learn type classes in Scala. I've got
* a decent handle on Scala itself, but the intricacies
* of the Type system are still foreign to me.
*
* I decided to start with what I thought would be a
* simple enough problem: Convert a Thing into a String
*/
object TypeClass {
/**
@chrisalbright
chrisalbright / docker-cleanup-resources.md
Created May 17, 2019 21:38 — forked from bastman/docker-cleanup-resources.md
docker cleanup guide: containers, images, volumes, networks

Docker - How to cleanup (unused) resources

Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...

delete volumes

// see: https://github.com/chadoe/docker-cleanup-volumes

$ docker volume rm $(docker volume ls -qf dangling=true)

$ docker volume ls -qf dangling=true | xargs -r docker volume rm

@chrisalbright
chrisalbright / ShapelessCoproduct.scala
Created May 17, 2019 21:31 — forked from fancellu/ShapelessCoproduct.scala
Examples with Shapeless 2.0, easier to understand from examples. Taken from docs, more examples/comments added etc
// Coproduct is extension of Either concept, to N multually exlusive choices
type ISB = Int :+: String :+: Boolean :+: CNil
val isb = Coproduct[ISB]("foo") //> isb : qaaz.ISB = foo
isb.select[Int] //> res0: Option[Int] = None
isb.select[String] //> res1: Option[String] = Some(foo)

Keybase proof

I hereby claim:

  • I am chrisalbright on github.
  • I am chrisalbright (https://keybase.io/chrisalbright) on keybase.
  • I have a public key ASCdMBAs9JenzGWR0Py3YKnO1jGUeVRGA8bofGT2OTcl3Qo

To claim this, I am signing this object:

@chrisalbright
chrisalbright / index.html
Last active July 25, 2016 02:23
Bookmarklets :)
<a href='javascript:(function(){var a=alert,b=Date,c=Number,d="";if("undefined"!=typeof window.getSelection){var e=window.getSelection();if(e.rangeCount){for(var f=document.createElement("div"),g=0,h=e.rangeCount;g<h;++g)f.appendChild(e.getRangeAt(g).cloneContents());d=f.innerHTML}}else"undefined"!=typeof document.selection&&"Text"==document.selection.type&&(d=document.selection.createRange().htmlText);a(new b(c(d)));})();'>Parse Epoch</a>
@chrisalbright
chrisalbright / date.abnf
Created July 7, 2016 00:07 — forked from robjens/date.abnf
A few BNF files I co(rr|ll)ected for Instaparse
; http://www.ietf.org/rfc/rfc3339.txt
; and http://www.odata.org/documentation/odata-version-3-0/abnf/
oneToNine = "01" / "02" / "03" / "04" / "05" / "06" / "07" / "08" / "09"
zeroToNine = "00" / oneToNine
oneToTwelve = oneToNine / "1" ( "0" / "1" / "2" )
oneToThirteen = oneToTwelve / "13"
@chrisalbright
chrisalbright / cleanup_compromized_php.sh
Created January 23, 2014 01:27
Clean up eval(base64_decode(..*)) PHP code (php hates programmers)
ack-grep -c 'eval\(base64_decode' --php | grep -ve '0$' | cut -d: -f1 | xargs perl -pi -e 's@<..*eval.base64_decode..*?>@@'
/* Example using MultipleOutputs to write a Spark RDD to multiples files.
Based on saveAsNewAPIHadoopFile implemented in org.apache.spark.rdd.PairRDDFunctions, org.apache.hadoop.mapreduce.SparkHadoopMapReduceUtil.
val values = sc.parallelize(List(
("fruit/items", "apple"),
("vegetable/items", "broccoli"),
("fruit/items", "pear"),
("fruit/items", "peach"),
("vegetable/items", "celery"),
("vegetable/items", "spinach")