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
1. Download cygwin
2. Install cygwin with make, git
3. git clone https://github.com/nikswamy/FStar.git
4. Download F# PowerPack (old) v4.0 from https://fsharppowerpack.codeplex.com/downloads/get/625448, unzip in C:\tools\fs-powerpack-4.0.0
5. Put 'C:\Program Files (x86)\Microsoft SDKs\F#\3.0\Framework\v4.0\;C:\tools\fs-powerpack-4.0.0;' in your PATH env var.
6. in cygwin do:
7. cd FStar
7. source setenv.sh
8. cd src
9. make test
@haf
haf / gist:10241ab9839d784db0dc
Created May 3, 2014 11:35
OS X log DNS resolution
P.S. In case anyone is following along at home, here's a bash script that observes the system log to determine which DNS server OS X is using to resolve google.com, for instance:
# enable logging on mDNSResponder
sudo killall -USR1 mDNSResponder
# set logging to the maximum
sudo syslog -c mDNSResponder -d
# start capturing log to a temporary file
syslog -w 0 | grep GetServerForQuestion > /tmp/resolutionquery.log &
# use python to resolve an address using the POSIX API
python -c "import socket;socket.gethostbyname_ex('google.com');"

Alternatives for shrinking

Pieces:

  • Simple Recovery Model
  • Bulk of < 4k items
  • Rebuild index at end
  • Ensure no user is working in app when you do it

Something like:

@haf
haf / gist:5e770676d8c007ca80c1
Created July 15, 2014 10:15
Logary versus exometer

Logary vs exometer

A roundabout of concepts

In Logary In Exometer Comment
Metric Metric For example transactions per second or memory usage. Create through exometer:new(), update through exometer:update() or on its own initiative through exometer_probe:sample behaviour impl.
implicit Data Point For Logary: implicit in the metric implementations. It is up to the metric to specify which data points are available under itself.
TODO? Metric Type "The metric type, in other words, is only used to map a metric to a configurable exometer_entry callback."
logger.Measure Entry Callback Compiles a measure reported through a [exometer:update() OR call to logger.Measure] into one or many data points. Logary doesn't map Entry Callbacks directly to metrics; this is under construction -- either as a pipeline that is configured or similar to exometer.
@haf
haf / xkcd.https.user.js
Last active August 29, 2015 14:05
xkcd.https.user.js
// ==UserScript==
// @name xkcd.https
// @namespace haf
// @description Loads images over https
// @include https://xkcd.com/*
// @version 1
// @grant none
// ==/UserScript==
(function() {
jQuery("#comic img").attr("src", jQuery("#comic img").attr("src").replace("http:", "https:"))
@haf
haf / gist:d30ea2c1862b507ef51c
Created November 10, 2014 14:23
Auditd Grok Login
USERNAME ([a-zA-Z0-9\._-]+)
TAG ([a-zA-Z0-9\._-]+)
type=%{WORD:audit_type} msg=audit\(%{NUMBER:audit_epoch}:%{NUMBER:audit_counter}\): pid=%{NUMBER:audit_pid} uid=%{NUMBER:audit_uid} auid=%{NUMBER:audit_audid} ses=%{NUMBER:audit_session} subj=%{WORD:audit_se_user}:%{WORD:audit_se_role}:%{WORD:audit_se_type}:%{USERNAME:audit_se_mls}:%{TAG:audit_se_tags} msg='op=%{WORD:audit_sshd_op} acct="%{USERNAME:audit_sshd_user}" exe="%{PATH:audit_sshd_path}" hostname=%{NOTSPACE:audit_sshd_hostname} addr=%{IP:audit_sshd_ip} terminal=%{WORD:audit_sshd_terminal} res=%{WORD:audit_sshd_result}'
pcregrep --color=auto -I -l -r -n '[\xf6]' *.php | xargs -I{} sh -c "iconv -f iso-8859-1 -t utf-8 {} > {}.new && mv {}.new {}";
@haf
haf / Dockerfile
Last active August 29, 2015 14:26
FROM centos:latest
MAINTAINER Henrik Feldt <henrik@haf.se>
ENV BUILD_PREFIX /tmp/build
ENV APP_PREFIX /app
ENV LISTEN_PORT=8083
RUN mkdir -p $BUILD_PREFIX
COPY paket.dependencies $BUILD_PREFIX/paket.dependencies
COPY paket.lock $BUILD_PREFIX/paket.lock
Trouble with Transactions
This is a piece on why you should use transactions.
The trouble with transactions in contemporary programming is that the APIs for
transactions don't fit how applications are written. Say you want to support
transactions in your app, how would you go about?
First of all, you're already doing implicit transactions around each SQL
statements. So you are moving away from this model if you're changing how you
@haf
haf / unit-test-ruby
Created June 15, 2011 10:34
How to unit-test exec_get/getter.call
class StrQ < Q
attr_accessor :default
def initialize(question, default = nil, io_source = STDIN, validator = nil)
@question = question
@default = default
@io_source = io_source
@validator = validator || lambda { true }
end