Skip to content

Instantly share code, notes, and snippets.

@fbettag
fbettag / build_for_iphoneos.sh
Created April 13, 2011 20:09
libsox compile script for iPhoneOS/iOS
#!/bin/bash
################################################################################
#
# Copyright (c) 2008-2009 Christopher J. Stawarz
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation files
# (the "Software"), to deal in the Software without restriction,
# including without limitation the rights to use, copy, modify, merge,
@fbettag
fbettag / juniper-junos-bgp-peers-to-yaml.awk
Last active January 13, 2021 20:23
AWK script which takes the output of "show configuration protocols bgp" on a Juniper Router and converts it into yaml. Can be used to convert an old configuration on a router into Ansible JunOS style. Should be adapter to your configuration style and case.
#!/usr/local/bin/gawk -f
/neighbor|peer-as|description|apply-group|authentication-key/ {
out="";
for (i=7; i<=NF; i++) {
out=out" "$i
}
gsub(/"/, "", out);
if ($6 == "neighbor") {
@fbettag
fbettag / dork.rb
Created May 24, 2011 00:46
Ruby Google Dork
#!/usr/bin/ruby
# encoding: utf-8
# Copyright (c) 2011, Franz Bettag <franz@bett.ag>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
@fbettag
fbettag / libsox.m
Created April 13, 2011 20:23
libsoxx method in objective-c
#import "sox.h"
- (NSString *)transformAudioFileAtPath:(NSString *)path profile:(int)tprofile {
static sox_format_t *in, *out; /* input and output files */
sox_effects_chain_t * chain;
sox_effect_t * e;
char *args[10];
NSString *target = [path stringByReplacingOccurrencesOfString:@".0.wav" withString:[NSString stringWithFormat:@".%i.wav", tprofile]];
target = [target stringByReplacingOccurrencesOfString:@"Hoersimulator.app" withString:@"Documents"];
@fbettag
fbettag / cwmrc
Created January 17, 2019 11:48
tiling windows in cwm and other managers that don't support top-right, top-left etc. Works with multiple monitors using mmutils.
bind-key 4-Up "bin/tile.sh top"
bind-key 4-Down "bin/tile.sh bottom"
bind-key 4-Left "bin/tile.sh left"
bind-key 4-Right "bin/tile.sh right"
bind-key C4-Up "bin/tile.sh top-right"
bind-key C4-Left "bin/tile.sh top-left"
bind-key C4-Down "bin/tile.sh bottom-left"
bind-key C4-Right "bin/tile.sh bottom-right"
@fbettag
fbettag / migrate.sh
Last active August 5, 2018 18:23
SmartOS Zone Migration script that takes care of installing the required image on the target compute node. Just keep this script on the headnode.
#!/bin/sh
# Franz Bettag <franz@bett.ag> - August 2018
# Script script migrates Zones/KVMs on Joyent SmartOS from one node to another.
# First it creates a new VM on the target from the same config as the original VM.
# It leaves out the nics section as to not run into any conflicts with the currently running machine.
# We then zfs send an intial snapshot of the original VM to the target.
# Then we shutdown the original VM and create another snapshot.
# After the last snapshot has been transferred, we update the new VM with nics and start it up.
# Cleanup of course.
#
@fbettag
fbettag / freebsd dalmatiner db 0.3.3 port - almost working
Created November 15, 2017 05:50
Almost working port of dalmatinerdb. Works when you make package manually, but doesn't when poudriere tries to do offline/cleanroom builds. good luck, i'm out of time on this. HOW CAN A DATABASE CLAIM TO BE OPTIMIZED FOR ZFS AND NOT HAVE A WORKING FREEBSD PORT? WTF GUYS
# This is a shell archive. Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file". Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
# databases
# databases/dalmatinerdb
# databases/dalmatinerdb/Makefile
@fbettag
fbettag / mdata.sh
Created July 25, 2018 19:59
rudder agent hook script to be placed into /var/rudder/hooks.d
#!/bin/sh
# All available metadata within the sdc: namespace gets converted into vars.
VARS="uuid server_uuid datacenter_name alias billing_id brand cpu_shares create_timestamp dns_domain hostname image_uuid last_modified limit_priv max_locked_memory max_lwps max_physical_memory max_swap owner_uuid quota state tmpfs zfs_io_priority zonename zonepath"
E="{"
# The sdc: namespace.
for key in $VARS
do
#!/bin/sh
LINES=150
LOG=/logs/everything.log
IGNORE="'U7PG2|cron|no matching key|[Ii]nvalid user|preauth|Timeout before auth|service=retention|-- MARK --|Log statistics|ntpd|tsm1|last message repeated'"
CURLOG="egrep -ve $IGNORE $LOG | tail -n $LINES"
NOWLOG="tail -Fn 0 $LOG | egrep -ve $IGNORE"
ssh tail@data "$CURLOG && $NOWLOG" | ccze -A
@fbettag
fbettag / .Xmodmap
Created March 30, 2018 17:29
Logitech G610 xmodmap bindings for multimedia keys
! logitech g610 multimedia keys
keycode 170 = XF86AudioLowerVolume NoSymbol XF86AudioLowerVolume
keycode 92 = XF86AudioRaiseVolume NoSymbol XF86AudioRaiseVolume
keycode 189 = XF86AudioPrev NoSymbol XF86AudioPrev
keycode 190 = XF86AudioNext NoSymbol XF86AudioNext
keycode 184 = XF86AudioPlay XF86AudioPause XF86AudioPlay XF86AudioPause
keycode 207 = XF86AudioMute NoSymbol XF86AudioMute
keycode 147 = XF86AudioStop XF86Eject XF86AudioStop XF86Eject