Skip to content

Instantly share code, notes, and snippets.

View ScalaWilliam's full-sized avatar
🏠
Working from home

ScalaWilliam ScalaWilliam

🏠
Working from home
View GitHub Profile
@ScalaWilliam
ScalaWilliam / gist:f882c6dcaebee19a7b6f6bdbbb74d676
Created June 26, 2017 00:26
Expanding params for curl... cool.
```
[03:18] <ScaWilliam> I have a file that contains multiple lines of curl arguments, eg one line -X POST, one line -H 'Content-Type: application/json' one line -d '{"some": "payload"}' --- I tried doing curl "$(cat file.txt)" http://host/ but it won't work - it doesn't evaluate the arguments properly. How do I do what I want?
[03:20] <greycat> ScaWilliam: mapfile -t curlargs < myfile; curl "${curlargs[@]}" "$url"
[03:30] <ScaWilliam> @greycat your command worked with one line -X, another POST, another -H another Content-Type: ...
[03:31] <greycat> But...?
[03:31] * greycat waits for "I actually have multiple options per line and they're shell-quoted"
[03:31] <ScaWilliam> hah no, figured out that one myself.
[03:31] <ScaWilliam> thanks, I'll share your website on twitter, this was very helpful :-)
@ScalaWilliam
ScalaWilliam / some.md
Last active June 26, 2017 00:25
Kubernetes links
@ScalaWilliam
ScalaWilliam / ddd.md
Created June 15, 2017 23:13 — forked from zsup/ddd.md
Documentation-Driven Development (DDD)

Documentation-Driven Development

The philosophy behind Documentation-Driven Development is a simple: from the perspective of a user, if a feature is not documented, then it doesn't exist, and if a feature is documented incorrectly, then it's broken.

  • Document the feature first. Figure out how you're going to describe the feature to users; if it's not documented, it doesn't exist. Documentation is the best way to define a feature in a user's eyes.
  • Whenever possible, documentation should be reviewed by users (community or Spark Elite) before any development begins.
  • Once documentation has been written, development should commence, and test-driven development is preferred.
  • Unit tests should be written that test the features as described by the documentation. If the functionality ever comes out of alignment with the documentation, tests should fail.
  • When a feature is being modified, it should be modified documentation-first.
  • When documentation is modified, so should be the tests.
- name: zulu apt key
apt_key: keyserver='hkp://keyserver.ubuntu.com:80' id=0x219BD9C9
- name: Add Zulu repository
apt_repository:
repo: deb http://repos.azulsystems.com/debian stable main
state: present
- name: ensure zulu jdk installed
apt:
java.nio.file.Files.lines(
java.nio.file.Paths.get("/dev/stdin")
).map(function (line) {
var time = line.substring(0, line.indexOf(" "))
var payload = line.substring(line.indexOf(" ") + 1);
var instant = java.time.LocalDateTime.parse(time).atZone(java.time.ZoneId.of("Europe/Paris")).toInstant()
var newTimeStr = java.time.format.DateTimeFormatter.ISO_INSTANT.format(instant);
return [newTimeStr, "aura.woop.ac:10000", payload].join("\t");
})
.forEach(print);
cut -c 1-10,20- | \
cut -f 1,2 -d $'\t' | \
mawk -F $'\t' -v OFS=$'\t' '$1 == last_date { counts[$2]++; } $1 != last_date { for ( i in counts ) print last_date, counts[i], i; last_date = $1; delete counts; }; END {for ( i in counts ) print last_date, counts[i], i;}'
#curl -s 'https://actionfps.com/logs.tsv?from=2017-01-01T00:00:00Z&to=2099-04-10T11:02:03Z' > AFPS2017.txt
#python fraudeur.py < AFPS2017.txt > fraudeur.csv
import sys
fragCLA={"AssaultCube[local#1999]": 0, "AssaultCube[local#2999]": 0, "AssaultCube[local#3999]":0, "AssaultCube[local#4999]":0, "AssaultCube[califapublic]": 0, "ActionFPS[local#7654]": 0, "ac_server[32337]": 0}
flagCLA={"AssaultCube[local#1999]": 0, "AssaultCube[local#2999]": 0, "AssaultCube[local#3999]":0, "AssaultCube[local#4999]":0, "AssaultCube[califapublic]": 0, "ActionFPS[local#7654]": 0, "ac_server[32337]": 0}
fragRVSF={"AssaultCube[local#1999]": 0, "AssaultCube[local#2999]": 0, "AssaultCube[local#3999]":0, "AssaultCube[local#4999]":0, "AssaultCube[califapublic]": 0, "ActionFPS[local#7654]": 0, "ac_server[32337]": 0}
flagRVSF={"AssaultCube[local#1999]": 0, "AssaultCube[local#2999]": 0, "AssaultCube[local#3999]":0, "AssaultCube[local#4999]":0, "AssaultCube[califapublic]": 0, "ActionFPS[local#7654]": 0, "ac_server[32337]": 0}
time={"Assau
@ScalaWilliam
ScalaWilliam / kube.sh
Created April 9, 2017 14:12
How I got started with minikube/kubernetes on mac.
$ brew install kubectl
$ minikube start
$ minikube dashboard
Set up a service (e.g. scalawilliam/eventsource-hub)
$ kubectl cluster-info
Get an IP
$ kubectl describe service
Get NodePort
$ curl http://<NodePort>:<IP>
$ jjs -cp $(coursier fetch org.jsoup:jsoup:1.10.1)
var document = org.jsoup.Jsoup.connect("http://www.bbc.com/news").get()
document.select(".title-link__title-text").stream().map(function(item) { return item.text(); }).forEach(print);
document = org.jsoup.Jsoup.connect("http://www.bbc.com/news").get()
document.select(".title-link__title-text").forEach(function(item) { print(item.text()); })
document.select(".title-link__title-text").stream().map(function(item) { return item.text(); }).forEach(print);
document.select(".title-link__title-text").stream().map(lambda x: x.text()).forEach(lambda x: print(x))