Skip to content

Instantly share code, notes, and snippets.

@j-keck
j-keck / ubuntu: disable dhcp from dnsmasq-base
Created July 5, 2014 06:26
how to disable dhcp server (dnsmasq-base) on ubuntu
dnsmasq from package 'dnsmasq-base' starts with a (from libvirt) generated configuration: /var/lib/libvirt/dnsmasq/default.conf.
this configuration file is not directly editable because it gets overwritten from libvirt.
there is no possibility to set 'no-dhcp-interface=eth0' per 'libvirt'.
# ###########################################################
# deactivate dhcp in dnsmasq per libvirt
# dnsmasq listen on port 53 (dns) and 67 (dhcp)
j@ubuntu:~$ sudo netstat -taupen | grep -E ':53|:67'
tcp 0 0 192.168.122.1:53 0.0.0.0:* LISTEN 0 9817 1218/dnsmasq
@j-keck
j-keck / störfunk
Created November 13, 2014 09:40
lost packets, network latency and rate limit for testing purpose
linux:
# drop packets (10% probability)
iptables -A INPUT -m statistic --mode random --probability 0.1 -j DROP
iptables -A OUTPUT -m statistic --mode random --probability 0.1 -j DROP
# drop packets (10% probability), add latency (500ms) and limit bandwidth (1Mbps)
tc qdisc add dev eth0 root netem delay 250ms loss 10% rate 1mbps
@j-keck
j-keck / scala
Last active August 29, 2015 14:09
random scala notes
* print generated code: scala -Xprint:typer <scala file>
* compiler phases: scalac -Xshow-phases
* show generated code: scala -Xprint:<phases> (-Xprint:typer or -Xprint:1-14 or -Xprint:all)
* show generated code in gui: scala -Ybrowse:<phases>
scalac options in sbt [source](http://tpolecat.github.io/2014/04/11/scalac-flags.html):
from: http://play.golang.org/p/P5DDZrcXZB
package main
import "fmt"
type Monad interface {
Bind(func(interface{}, Monad) Monad) Monad
Return(interface{}) Monad
}
PROGRAMMING WITH EFFECTS
Graham Hutton, January 2014
Shall we be pure or impure?
The functional programming community divides into two camps:
o "Pure" languages, such as Haskell, are based directly
upon the mathematical notion of a function as a
mapping from arguments to results.
@j-keck
j-keck / network
Created December 12, 2014 15:11
cmdline
# tcpdump
* HTTP GET request
tcpdump -s 0 -A 'tcp[((tcp[12:1] & 0xf0) >> 2):4] = 0x47455420'
* HTTP POST
tcpdump -s 0 -A 'tcp dst port 80 and (tcp[((tcp[12:1] & 0xf0) >> 2):4] = 0x504f5354)'
  1. General Background and Overview
@j-keck
j-keck / Sys.scala
Last active July 12, 2017 20:41
scala: cancelable / async scala.sys.process.Process
/*
The MIT License (MIT)
Copyright (c) 2016 j-keck <[email protected]>
Permission is hereby granted, free of charge, to any person obtaining a copy of this
software and associated documentation files (the "Software"), to deal in the Software
without restriction, including without limitation the rights to use, copy, modify,
merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to the following conditions:
@j-keck
j-keck / Main.hs
Created October 30, 2015 13:19
haskell wreq: disable certificate validation
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Control.Exception (SomeException, try)
import Control.Lens
import qualified Data.ByteString.Lazy as BL
import Network.Connection (TLSSettings (..))
import Network.HTTP.Client.TLS (mkManagerSettings)
import Network.Wreq
@j-keck
j-keck / journal2pg.pl
Created January 12, 2016 20:29
perl script to send systemd logs in a postgresql db
#!/usr/bin/env perl
#
# save systemd journal logs to a postgres instance
#
#
# * first run with '-init-db' to intialize the database
# * second run to load all logs
# (maybe with '-journalctl-args "-n 1000000"')
# * the following runs inserts only new log entries
#