Skip to content

Instantly share code, notes, and snippets.

View haf's full-sized avatar
💹
currently succeeding...

Henrik Feldt haf

💹
currently succeeding...
View GitHub Profile
@haf
haf / gist:8276833
Last active January 2, 2016 08:29
On "Operating on Types" by @hlindberg

It seems like you're doing a really good job cleaning up the puppet code base :) while enabling having values as types, like Integer[1,0x10] specifying an integer between 1 and 16. It looks like you're starting to add dependent types to puppet (thumbs up!).

In its core I want to use Puppet as a declarative specification system. Type systems are also declarative specifications and to me it seems a lot of the work you're doing on types means tooling like puppet lint and Geppetto will get stronger and catch more errors ahead of time.

It's worth considering more than values that represent primitives, regexes or hashes, imo. Since puppet is a configuration management tool and not a general programming language, I think it would be nice to have types that can specify security properties or protocols (finite state machines) that interact with resources or things that facilitate coordination between nodes initialising such as monotonic counters with auto-creating 'requires'-relationships to other nodes running.

@haf
haf / thoughts.md
Last active January 1, 2016 13:09
Thoughts on client libraries

In a client library reading TCP, there are constraints.

  • Latency:
    • up <- larger frames, more batching
    • down <- smaller frames, send without waiting in buffers, disable nagles' algorithm
  • Throughput:
    • up <- larger frames, more batching
    • down <- smaller frames, less batching
  • Slow connections:
@haf
haf / gist:8140280
Last active January 1, 2016 11:49
CRC32 in succinct F#
let IEEE = 0xedb88320u
/// The seed value default: all ones, CRC depends fully on its input.
let seed = 0xffffffffu
let inline (!!) v = v ^^^ 0xFFFFFFFFu
let crc_table = Array.init 256 (fun i ->
(uint32 i, [0..7])
||> List.fold (fun value _ ->
@haf
haf / gist:8043738
Created December 19, 2013 18:16
AWS anguish
It's not often I write in verse,
But I need urgent help,
so it might sounds a bit terse...
I'm not going to lie;
During the day,
When spirits are high,
AWS-EC2 has its way,
Bellows: 'THE END IS NIGH'!
Anguished devs scream NAY!!!
@haf
haf / from zk-kafka.txt
Last active December 22, 2015 02:49
irb session against riemann
[root@zk-kafka vagrant]# nmap -p 5555,5556 172.16.0.60
Starting Nmap 5.51 ( http://nmap.org ) at 2013-09-01 20:18 UTC
Nmap scan report for 172.16.0.60
Host is up (0.00034s latency).
PORT STATE SERVICE
5555/tcp open freeciv
5556/tcp open unknown
MAC Address: 08:00:27:2D:BE:24 (Cadmus Computer Systems)
@haf
haf / gist:6328013
Created August 24, 2013 13:04
Answer a security question!
require 'openssl'
require 'base64'
unless ARGV[0] && ARGV[1]
$stderr.puts 'you need to provide the question as the first argument'
$stderr.puts 'you need to provide the password as the second argument'
$stderr.puts 'usage: ./md5question.rb <question> <password> [ base64 | hex ]'
exit -1
end
@haf
haf / gist:6105364
Last active December 20, 2015 09:09
Get all directory parents in puppet, as an array
module Puppet::Parser::Functions
newfunction(:dir_parents, :type => :rvalue, :doc => <<-DOC) do |*args|
Get the parents of a directory path.
Examples:
dir_parents('/a/b/c') = [ '/a', '/a/b' ]
dir_parents('') = []
dir_parents('a') = []
@haf
haf / gist:5717121
Last active December 18, 2015 03:19
Hacking async APIs for the LULz
using System;
using System.Threading.Tasks;
using ConsoleApplication2.Authorization;
using ConsoleApplication2.ServiceStack;
using ConsoleApplication2.Sugar;
namespace ConsoleApplication2
{
internal class Program
{
#! /bin/sh
### BEGIN INIT INFO
# Provides: supervisord
# Required-Start: $remote_fs
# Required-Stop: $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Example initscript
# Description: This file should be used to construct scripts to be
# placed in /etc/init.d.
@haf
haf / gist:5630159
Created May 22, 2013 19:21
What to do when yum doesn't respond to SIGINT???
CTRL+Z
kill -s SIGKILL %1