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 / bulk_data.json
Created June 3, 2012 22:38
Elasticsearch 0.20.0.Beta1-SNAPSHOT with has_parent merged : Search for childs with "has_parent" filter
{ "index" : { "_index" : "parent_child", "_type" : "store", "_id" : "store1" } }
{ "name" : "auchan", "owner" : "chris" }
{ "index" : { "_index" : "parent_child", "_type" : "department", "_id" : "department1", "parent" : "store1" } }
{ "name" : "toys", "numberOfProducts" : 150 }
{ "index" : { "_index" : "parent_child", "_type" : "product", "_id" : "product1", "parent" : "department1", "routing" : "store1" } }
{ "name" : "gun", "trademark" : "tiger", "price" : 9, "store_id" : "store1" }
# Author: Pieter Noordhuis
# Description: Simple demo to showcase Redis PubSub with EventMachine
#
# Update 7 Oct 2010:
# - This example does *not* appear to work with Chrome >=6.0. Apparently,
# the WebSocket protocol implementation in the cramp gem does not work
# well with Chrome's (newer) WebSocket implementation.
#
# Requirements:
# - rubygems: eventmachine, thin, cramp, sinatra, yajl-ruby
@r10r
r10r / build postfix with SASL TLS and MySQL support
Created June 10, 2012 00:25
Bulk load postfix virtual aliases map into mysql table
make -f Makefile.init makefiles \
CCARGS='-DHAS_MYSQL -I/usr/include/mysql -DUSE_SASL_AUTH -DUSE_CYRUS_SASL -I/usr/include/sasl -DUSE_TLS -I/usr/include/openssl' \
AUXLIBS='-L/usr/lib -lmysqlclient -lsasl2 -lssl -lcrypto -lz -lm'
make
@r10r
r10r / application_helper.rb
Created June 12, 2012 16:26
Generating HTML markup from github flavored markdown including syntax highlighting
@md_renderer = Redcarpet::Markdown.new(Redcarpet::Render::HTML,
:autolink => true,
:space_after_headers => true,
:fenced_code_blocks => true)
def markdown(text)
syntax_highlighter(@md_renderer.render(text)).html_safe
end
def syntax_highlighter(html)
@r10r
r10r / veewee_console_type.rb
Created February 21, 2013 11:12
Type something in a veewee box (virtualbox provider). Can be use for testing the :boot_cmd_sequence without rebuilding the box.
require 'veewee'
# see veewee/test/build_realtest.rb
@ve=Veewee::Environment.new({ :definition_dir => '<definitions dir>' })
box = @ve.providers["virtualbox"].get_box('sgg')
box.console_type(['foobar'])
@r10r
r10r / authorize_public_key.sh
Last active December 14, 2015 14:39
Authorize one or more public keys.
#!/bin/bash
# usage: cat $HOME/.ssh/id_dsa.pub | $0 foo@bar.com
PUBLIC_KEY=`cat`
echo "-- Adding public key(s) to account: $@ --"
echo "$PUBLIC_KEY"
ssh -T $@ <<EOF
[ -d \$HOME/.ssh ] || mkdir \$HOME/.ssh
echo "$PUBLIC_KEY" >> \$HOME/.ssh/authorized_keys
@r10r
r10r / script.sql
Created March 7, 2013 09:19
psql must return 1 when a script fails (must be enabled manually)
\set ON_ERROR_STOP 1
@r10r
r10r / enable_dnsmasq_on_osx.sh
Last active October 11, 2019 04:27
Installs and configures dnsmasq on osx (for local resolution of development machines e.g virtualbox). Cudos to Alan Ivey http://www.echoditto.com/blog/never-touch-your-local-etchosts-file-os-x-again
# ----------------------
# installing dnsmasq and enable daemon
# ----------------------
brew install dnsmasq
sudo cp -v $(brew --prefix dnsmasq)/homebrew.mxcl.dnsmasq.plist /Library/LaunchDaemons
# ----------------------
# adding resolver for vbox domain
# ----------------------
[ -d /etc/resolver ] || sudo mkdir -v /etc/resolver
sudo bash -c 'echo "nameserver 127.0.0.1" > /etc/resolver/vbox'
@r10r
r10r / dbus_pulseaudio.rb
Last active December 16, 2015 20:59
pulseaudio dbus
require 'dbus'
class DBus::Pulseaudio
attr_accessor :socket_path, :connection
OBJECTS = {
:core => ['org.PulseAudio.Core1','/org/pulseaudio/core1']
}
@r10r
r10r / pulse_dbus.py
Created May 2, 2013 09:19
Listen for pulse sink (device) state changes/updates.
import dbus
import os
from subprocess import call
def pulse_bus_address():
if 'PULSE_DBUS_SERVER' in os.environ:
address = os.environ['PULSE_DBUS_SERVER']
else:
bus = dbus.SessionBus()
server_lookup = bus.get_object("org.PulseAudio1", "/org/pulseaudio/server_lookup1")