Skip to content

Instantly share code, notes, and snippets.

View phaer's full-sized avatar
💭

Paul Haerle phaer

💭
View GitHub Profile
#!/bin/zsh -f
set -e
HOSTNAME=$1
PASSWORD=toor
VMNAME=$HOSTNAME
FILE="$VMNAME.img"
SIZE=2G
ARCH=amd64
{-# LANGUAGE OverloadedStrings #-}
import Prelude hiding (FilePath)
import Control.Monad
import Data.Maybe
import Data.List
import qualified Data.Text as T
import qualified Data.ByteString.Lazy.Char8 as C
import Text.Feed.Types
import Text.Feed.Import
@phaer
phaer / roundcube_subscribe.php
Created June 19, 2015 14:47
roundcube: subscribe to all mailboxes
<?php
define('RCUBE_CONFIG_DIR', '/var/lib/roundcube/config/');
define('RCUBE_PLUGINS_DIR', '/var/lib/roundcube/plugins/');
require_once '/var/lib/roundcube/program/lib/Roundcube/bootstrap.php';
$rcube = rcube::get_instance(rcube::INIT_WITH_DB | rcube::INIT_WITH_PLUGINS);
$imap = $rcube->get_storage();
@phaer
phaer / cfg_to_defaults_main.yml
Created August 25, 2015 01:19
Cfg file to defaults/main.yml
import sys
import re
"""
Loops over a file with configuration in the form of
#key = value
and produces a yaml file suitable for ansibles defaults/main.yml
"""
@phaer
phaer / coffeescript_converter.rb
Created May 6, 2011 22:39
A trivial CoffeeScript.org -> Javascript plugin for jekyll ( https://github.com/mojombo/jekyll ). Put this file in '_plugins/' and write a YAML header to your .coffee files (i.e. "---\n---\n")
module Jekyll
require 'coffee-script'
class CoffeeScriptConverter < Converter
safe true
priority :normal
def matches(ext)
ext =~ /coffee/i
end
@phaer
phaer / private.py
Last active December 23, 2015 07:28
Mediagoblin m*e*ddleware to keep your instance private.
from mediagoblin.meddleware import BaseMeddleware
from mediagoblin.tools.response import redirect
class PrivateMeddleware(BaseMeddleware):
"""Private Meddleware
Redirects requests by unauthenticated clients to the login form.
"""
public_views = [
@phaer
phaer / overpass-query.txt
Created April 14, 2016 01:17
Get RBL number for viennese public transport stops around a given location
/*
This has been generated by the overpass-turbo wizard.
The original search was:
“(railway=station or railway=tram_stop or highway=bus_stop) around Semperdepot”
*/
[out:json][timeout:25];
// adjust the search radius (in meters) here
{{radius=600}}
// gather results
(
@phaer
phaer / broker.ml
Last active September 19, 2016 22:34
open Lwt.Infix
open Websocket_lwt
open Ppx_lwt
open Frame
let ip_port = ("127.0.0.1", 3000);;
let clients = Hashtbl.create 10;;
let section = Lwt_log.Section.make "stream_shape";;
Lwt_log.(add_rule "*" Debug);;
@phaer
phaer / sshjail.py
Created December 23, 2016 14:51
connection_plugin for Ansible and FreeBSD jails, connecting through ssh on the jailhost.
# connection_plugin for Ansible and FreeBSD jails, connecting
# through ssh on the jailhost.
# inspiration: https://github.com/austinhyde/ansible-sshjail
from ansible.errors import AnsibleError
from ansible.plugins.connection import ConnectionBase
from ansible.plugins.connection import ssh
try:
from __main__ import display
except ImportError:
@phaer
phaer / metalab-teletext-remote.ino
Last active January 14, 2017 22:10
Metalab Teletext Remote control code.
#include <IRremote.h>
#include <Keypad.h>
const byte ROWS = 4;
const byte COLS = 4;
// define the symbols of the buttons on the keypads.
const char hexaKeys[ROWS][COLS] = {
{'1','2','3','A'},
{'4','5','6','B'},