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 / Dockerfile
Last active August 29, 2015 14:26
FROM centos:latest
MAINTAINER Henrik Feldt <[email protected]>
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
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 / LICENSE
Last active February 14, 2024 11:15
Setting up a digitalocean proxy
https://www.gnu.org/licenses/gpl-3.0.en.html
GNU GENERAL PUBLIC LICENSE v3
@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}'
@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: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.

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: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');"
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:8378818
Last active August 11, 2016 20:06
Windows EventLog logstash config
# filter handled by puppet
filter {
# actually EventTime matches: \d{4}\-\d{2}-\d{2} \d{2}\:\d{2}\:\d{2}
if [type] == "eventlog"
and [EventTime] =~ ".*"
and [Message] !~ "Session_Citrix Xen" {
mutate {
# Lowercase some values that are always in uppercase