Skip to content

Instantly share code, notes, and snippets.

@nilsmagnus
nilsmagnus / Makefile
Created September 5, 2018 18:14
Makefile for elm project with watching of sourcefile on ubuntu
SHELL := /bin/bash
.PHONY: pushify.js test clean package
bin: pushify.js
pushify.js: Pushify.elm
@elm make Pushify.elm --optimize --output pushify.js || notify-send "elm compilation failed"
@cp pushify.js ../api/web/static/pushify.js
watch:
@nilsmagnus
nilsmagnus / influx_to_csv.go
Last active February 6, 2018 19:14
Join several time-series from influxdb to a single csv output.
package main
import (
"fmt"
"log"
"github.com/influxdata/influxdb/client/v2"
"strings"
"flag"
)
@nilsmagnus
nilsmagnus / k8s-init-gcloud.md
Last active December 29, 2017 10:25
create kubernetes cluster with gcloud
@nilsmagnus
nilsmagnus / docker-compose.yml
Created November 27, 2017 21:14
docker compose for monitoring single app
version: '3'
services:
autr:
build: .
ports:
- "8080:8080"
prometheus:
image: "prom/prometheus:v2.0.0"
@nilsmagnus
nilsmagnus / nginx+certbot.conf
Last active June 13, 2017 19:37
Nginx + certbot mini howto and config
#1: install nginx
#2: install certbot and follow instructions to generate certificate: https://certbot.eff.org/
#3: configure nginx with the content below(replace references to bytecode.no with your domain(s)
#4: add a cronjob as root:
0 1 */15 * * certbot renew >/dev/null 2>&1
#5: submit request to be sts preloaded in chrome here: https://hstspreload.org/
server {
server_name bytecode.no www.bytecode.no;
@nilsmagnus
nilsmagnus / gribdown.sh
Created April 19, 2017 20:07
Download grib files from noaa.gov. Will only work every hour a new forecast is published.
#!/usr/bin/env bash
urldate=`date +%Y%m%d%H`
mkdir -p "data/gfs/$urldate"
cd "data/gfs/$urldate"
for no in `seq -f "%03g" 0 3 30`;
do
echo " Fetching log for date $urldate, no $no"
@nilsmagnus
nilsmagnus / continous_gotest_notify.sh
Last active February 23, 2017 12:16
Script that runs go test forever and gives a notification each time tests are broken or fixed.
#!/bin/bash
failing=0
while :
do
go test > /dev/null
if [ "$?" = "1" ]; then
if [ "$failing" = "1" ]; then
echo "Continuing failure!"
@nilsmagnus
nilsmagnus / get_offsets.go
Created February 15, 2017 09:11
Get newest offsets of all topics for your client, using the sarama/shopify library.
package main
import (
"github.com/Shopify/sarama"
"log"
"time"
"fmt"
"strings"
)
@nilsmagnus
nilsmagnus / kafka_consumer.go
Created February 15, 2017 08:04
Example of go consuming from kafka, using the shopify/sarama library
package main
import (
"fmt"
"github.com/Shopify/sarama"
"os"
"os/signal"
"strings"
)
@nilsmagnus
nilsmagnus / scan.sh
Created October 5, 2016 19:25
scan for probe requests
sudo apt-get install tshark
sudo ifconfig wlp2s0 down
sudo iwconfig wlp2s0 mode monitor
sudo ifconfig wlp2s0 up
tshark -i wlp2s0 -N m -T fields -e eth.addr_resolved -e eth.addr