Skip to content

Instantly share code, notes, and snippets.

View r10r's full-sized avatar

Ruben Jenster r10r

  • Drachenfels GmbH
  • Pforzheim
View GitHub Profile
@r10r
r10r / trace.h
Created February 22, 2014 10:08
Time tracing header.
/*
* Simple header for tracing time.
* Include and define TRACE to enable.
*/
#ifndef _TRACE_H
#define _TRACE_H
#ifdef TRACE
#include <sys/time.h>
@r10r
r10r / Makefile
Created February 10, 2014 15:15
Ragel state machine generation
MACHINES=$(shell ls *.rl | xargs basename -s .rl)
CFLAGS= -O0 -g
RFLAGS= -V
# pattern rules
# see https://www.gnu.org/software/make/manual/html_node/Pattern-Rules.html#Pattern-Rules
%.o : %.c
gcc $(CFLAGS) -o $@ $<
@r10r
r10r / brewlibs
Created January 30, 2014 10:31
Generate CFLAGS from libraries installed through homebrew.
#!/bin/sh
brew_cflags() {
local flags
for lib in $@; do
P=`brew --prefix $lib`
name=`echo $lib | sed 's/^lib//'`
flags="$flags -L$P/lib -I$P/include -l$name"
done
echo $flags
@r10r
r10r / deploy_ssh_pubkey.sh
Created November 8, 2013 16:23
Simple SSH public key deployment.
#!/bin/sh
# Usage: $0 [user@]hostname
public_key_path="$HOME/.ssh/id_dsa.pub"
public_key=$(<${public_key_path})
ssh -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no $1 <<-END
echo "Authorize public key ${public_key_path} on \`hostname\`"
[ -d \$HOME/.ssh ] || mkdir \$HOME/.ssh
echo $public_key >> \$HOME/.ssh/authorized_keys
@r10r
r10r / launchd_aliases
Last active December 27, 2015 09:29
Relaunch daemons controlled by launchd easily.
dnsmasq=homebrew.mxcl.dnsmasq
postgres=homebrew.mxcl.postgresql
@r10r
r10r / date_asn1.sh
Last active December 26, 2015 10:49
ASN1 date format
DATE_FORMAT_ASN1="%y%m%d%H%M%SZ"
# @stdout: ASN1 formatted date string
# $1: offset expression (seconds) eg. 24 hours: '+(60*60*24)'
date_asn1() {
local offset=$1
date -j -f %s `echo $(date +%s)${offset}|bc` +${DATE_FORMAT_ASN1}
}
@r10r
r10r / sgrep.sh
Last active December 25, 2015 08:49
Combine grep and find to restrict search to certain files.
#!/bin/sh
# Combine find and grep to search (source) files.
# Just for lazy typers ;)
#
# E.g limit grep to *.h and *.c:
# sgrep X509_verify_cert .c .h
find_args=""
for arg in $(echo $@ | cut -d' ' -f 2-); do
@r10r
r10r / listing.txt
Last active December 22, 2015 16:28
Commandline network selection script for OS X.
tree ~/.network/
~/.network/
├── down.d
│   └── mynet_down.sh
└── up.d
└── mynet_up.sh
<html>
<body>
<p><%= @options[:title] %></p>
<%= import("chapter.html.erb") %>
</body>
</html>
@r10r
r10r / reek.rake
Created July 29, 2013 21:01
Reek checkstyle formatter
require 'reek/rake/task'
require 'syspect/rspec/reek_checkstyle_formatter'
Reek::Rake::Task.new do |t|
t.fail_on_error = false
t.reek_opts = '-y -n'
end
namespace :reek do
desc 'Generate checkstyle report for code smells analyzed by reek.'