Skip to content

Instantly share code, notes, and snippets.

@3h4x
3h4x / gist:f0e240455e66907f5008
Created June 14, 2014 08:09
Replace matching line in puppet
define replace_matching_line($file, $match, $replace) {
exec { "/bin/sed ${file} -i.bak -e 's/${match}/${replace}/'":
onlyif => "/bin/grep -E '${match}' ${file}",
}
}
11:25 $ sudo docker run terraform
TF_ACC= go test ./... -timeout=10s
ok github.com/hashicorp/terraform 0.005s
ok github.com/hashicorp/terraform/builtin/bins/provider-aws 0.004s
ok github.com/hashicorp/terraform/builtin/bins/provider-cloudflare 0.002s
? github.com/hashicorp/terraform/builtin/bins/provider-consul [no test files]
ok github.com/hashicorp/terraform/builtin/bins/provider-digitalocean 0.002s
ok github.com/hashicorp/terraform/builtin/bins/provider-dnsimple 0.002s
ok github.com/hashicorp/terraform/builtin/bins/provider-heroku 0.002s
ok github.com/hashicorp/terraform/builtin/bins/provisioner-file 0.002s
@3h4x
3h4x / count.sh
Last active August 29, 2015 14:07
#!/bin/bash
COUNTER=/tmp/kernel_lines # zmienna odwolujaca sie do pliku w ktorym beda ilosci linii
if [[ ! -f $COUNTER ]]; then echo 0 > /tmp/kernel_lines; fi # jesli nie ma pliku z liniami to go stworz i upchnij tam 0
NUM=`cat $COUNTER` # ogarnij ile linijek juz jest w pliku $COUNTER
LINES=`sed '/\/\*/,/*\//d' $1 | sed '/^\/\//d' | sed '/^$/d' | wc -l` # wypierdol komentarze z C
echo "$NUM + $LINES" # pokaz ze umiesz dodac to gowno
echo $((NUM+LINES)) > $COUNTER # zapisz to gowno
{
"id": "/ctrlpkw",
"groups": [
{
"id": "/ctrlpkw/db",
"apps": [
{
"id": "/ctrlpkw/db/cassandra-seed",
"constraints": [["hostname", "UNIQUE"]],
"ports": [7199, 7000, 7001, 9160, 9042],
{
"id": "/ctrlpkw/db",
"apps": [
{
"id": "/ctrlpkw/db",
"apps": [
{
"id": "/ctrlpkw/db/cassandra-seed",
"constraints": [
[
@3h4x
3h4x / latency.txt
Created January 31, 2017 18:33 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers
--------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@3h4x
3h4x / gist:0aa6b000d198d9ec8222e720c8f0bfd3
Created January 5, 2018 13:50
Checking Ubuntu AMI releases
python -c "import requests; import csv; import json; result = [row for row in csv.reader(requests.get('https://cloud-images.ubuntu.com/query/released.latest.txt').content.decode('utf-8').splitlines(), delimiter='\t')]; print(json.dumps({k[0]: k[3] for k in result}, indent=4))"
@3h4x
3h4x / gist:dbeff2e08d53f32ae7adf341829df3a4
Created January 9, 2018 18:24
Ubuntu AMI finder CLI
import json
import re
import click
import dataset
import demjson
import requests
@click.command()
@3h4x
3h4x / value
Last active July 18, 2018 10:36
8
### Keybase proof
I hereby claim:
* I am 3h4x on github.
* I am 3h4x (https://keybase.io/3h4x) on keybase.
* I have a public key ASC1t1qg9WeywJV0Q35buqGz5OcVRJMV3c9dAA7LY66Knwo
To claim this, I am signing this object: