Skip to content

Instantly share code, notes, and snippets.

View fbettag's full-sized avatar

Franz Bettag fbettag

View GitHub Profile
@fbettag
fbettag / archlinux-packer.cf
Created September 15, 2012 22:58
ArchLinux Packer CFengine package method
body package_method packer {
package_changes => "bulk";
package_list_command => "/usr/bin/pacman -Q";
package_list_name_regex => "([^\s]+).*";
package_list_version_regex => "[^\s]+ ([^\s\n\r]+)";
package_name_convention => "$(name)";
package_installed_regex => ".*";
package_name_regex => "([^\s]+).*";
bundle edit_line sshd_config {
replace_patterns:
"^.*Port (?!22).*$" replace_with => content("Port 22");
"^.*Protocol (?!2).*$" replace_with => content("Protocol 2");
"^.*ServerKeyBits (?!2048).*$" replace_with => content("ServerKeyBits 2048");
"^.*PermitRootLogin (?!without-password).*$" replace_with => content("PermitRootLogin without-password");
"^.*PubkeyAuthentication (?!yes).*$" replace_with => content("PubkeyAuthentication yes");
"^.*PermitEmptyPasswords (?!no).*$" replace_with => content("PermitEmptyPasswords no");
"^.*TCPKeepAlive (?!yes).*$" replace_with => content("TCPKeepAlive yes");
@fbettag
fbettag / vif-vlan-bridge.sh
Created September 25, 2012 03:20
Xen dom0 vif-bridge script for dynamic vlans
#!/bin/bash
dir=$(dirname "$0")
. "$dir/vif-common.sh"
netdev=${netdev:-eth1}
vlan=${vlan:-0}
vlandev=$netdev.$vlan
retval=$( ip link show | grep $vlandev | wc -l )
@fbettag
fbettag / server.scala
Created October 11, 2012 23:52
weird netty issue
[error] Server.scala:55: type mismatch;
[error] found : io.netty.channel.ChannelOption[java.lang.Boolean]
[error] required: io.netty.channel.ChannelOption[Any]
[error] Note: java.lang.Boolean <: Any, but Java-defined class ChannelOption is invariant in type T.[error] You may wish to investigate a wildcard type such as `_ <: Any`. (SLS 3.2.10)
[error] .childOption(ChannelOption.TCP_NODELAY, true)
[error]
@fbettag
fbettag / netty4.scala
Created October 12, 2012 13:47
Another Netty 4 scala weirdness
[error] AuthenticationHandler.scala:54: overriding method inboundBufferUpdated in class ChannelInboundMessageHandlerAdapter of type (x$1: io.netty.channel.ChannelHandlerContext)Unit;
[error] method inboundBufferUpdated cannot override final member
[error] def inboundBufferUpdated(ctx: ChannelHandlerContext) {
[error] ^
[error] one error found
Oct 14, 2012 4:01:44 PM io.netty.channel.socket.nio.NioEventLoop
WARNING: Unexpected exception in the selector loop.
java.util.ConcurrentModificationException
   at java.util.HashMap$HashIterator.nextEntry(Unknown Source)
   at java.util.HashMap$KeyIterator.next(Unknown Source)
   at io.netty.channel.socket.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:268)
   at io.netty.channel.socket.nio.NioEventLoop.run(NioEventLoop.java:211)
   at io.netty.channel.SingleThreadEventExecutor$1.run(SingleThreadEventExecutor.java:80)
   at java.lang.Thread.run(Unknown Source)
@fbettag
fbettag / netflow.scala
Created October 23, 2012 04:48
UDP NetFlow 2 bytes to get Int/Long
def toLong(buf: Array[byte], offset: Int, length: Int) = {
var ret = 0L
var i = offset
while (i < offset + length) {
ret = ((ret << 8) & 0xffffffff) + (buf(i) & 0xff)
i += 1
}
ret
}
@fbettag
fbettag / gist:4013910
Created November 4, 2012 21:45
The reality of #sbt. a fucked up build system for scala..
scala> exit
<console>:11: warning: method exit in object Predef is deprecated: Use sys.exit() instead
exit
^
null
scala> sys.exit()
null
scala> <- (i hit ctrl+d, screen locked up and i had to wait a few seconds)
build:~/kyotocabinet$ cat pkg/.control.kyotocabinet/.PKGINFO
# Generated by abuild 2.13.1
# using fakeroot version 1.18.4
# Thu Nov 22 14:44:22 UTC 2012
pkgname = kyotocabinet
pkgver = 1.2.76-r0
pkgdesc = GDBM, QDBM and Tokyo Cabinet successor
url = http://falllabs.com/kyotocabinet
builddate = 1353595462
packager = me
dom0:~# apk add cfengine
(1/5) Installing pcre (8.31-r0)
(2/5) Installing pkgconf (0.8.9-r0)
(3/5) Installing pkgconfig (0.25-r1)
(4/5) Installing tokyocabinet (1.4.48-r0)
(5/5) Installing cfengine (3.3.8-r0)
Executing busybox-1.20.2-r3.trigger
Executing uclibc-utils-0.9.33.2-r14.trigger
OK: 344 MiB in 75 packages