Skip to content

Instantly share code, notes, and snippets.

package torrent
import (
"github.com/anacrolix/torrent/metainfo"
"testing"
"path/filepath"
"os"
"github.com/anacrolix/torrent/dht"
"io"
"errors"
@soul9
soul9 / build
Last active December 31, 2015 09:08
OpenELEC.tv package for socat
#!/bin/sh
. config/options $1
cd $PKG_BUILD
./configure --host=$TARGET_NAME \
--build=$HOST_NAME \
--prefix=/usr \
--bindir=/usr/bin \
@soul9
soul9 / services.cf
Last active December 15, 2015 18:39
cfengine promises for debian service management using the 'insserv' and 'service' commands, and links in /etc/rc*.d/
===== Example
===== Can be used in a bundle like so:
bundle agend foo {
services:
"ejabberd"
service_policy => disable,
service_method => service("disable");
}
===== Service management on debian
@soul9
soul9 / fail2ban_sqlite.py
Created April 4, 2011 12:27
This (unfinished) fail2ban script will adaptively ban recurring dictionary attackers for more and more time
#!/usr/bin/env python
import sqlite3, subprocess, time, random, sys, os
lfile='/var/run/fail2ban/fail2ban-sqlite.lock'
if os.path.exists(lfile):
sys.exit(0)
else:
open(lfile, 'w').close()
SCRIPT_LOCATION=$(dirname $0)
#get common configuration
if [ -f ${SCRIPT_LOCATION}/hosts/common/conf ]; then
. ${SCRIPT_LOCATION}/hosts/common/conf
fi
#set per-host configuration
if [ -f ${SCRIPT_LOCATION}/hosts/$(hostname --fqdn)/conf ]; then
. ${SCRIPT_LOCATION}/hosts/$(hostname --fqdn)/conf
@soul9
soul9 / Makefile
Created January 2, 2011 19:16
time package problem
include $(GOROOT)/src/Make.inc
TARG=testtickers
GOFILES=testtickers.go
include $(GOROOT)/src/Make.cmd
diff --git a/irc_callback.go b/irc_callback.go
index fead866..d68f92b 100644
--- a/irc_callback.go
+++ b/irc_callback.go
@@ -31,7 +31,7 @@ func (irc *IRCConnection) ReplaceCallback(eventcode string, i int, callback func
}
func (irc *IRCConnection) RunCallbacks(event *IRCEvent) {
- if event.Code == "PRIVMSG" && event.Message[0] == '\x01' {
+ if event.Code == "PRIVMSG" && len(event.Message) > 0 && event.Message[0] == '\x01' {
diff --git a/example/Makefile b/example/Makefile
index 05650bc..11255ff 100644
--- a/example/Makefile
+++ b/example/Makefile
@@ -1,13 +1,6 @@
include $(GOROOT)/src/Make.inc
-OBJS := $(patsubst %.go,%.$O,$(wildcard *.go))
-OUT := $(patsubst %.$O,%,$(OBJS))
+TARG=testirc
diff --git a/irc_callback.go b/irc_callback.go
index 7875fc3..00eaaf1 100644
--- a/irc_callback.go
+++ b/irc_callback.go
@@ -7,26 +7,12 @@ import (
"strconv"
)
-func AppendCallback(slice, data []func(*IRCEvent)) []func(*IRCEvent) {
- l := len(slice)
@soul9
soul9 / checkroot.bash
Created November 13, 2010 17:42
script to check what files don't belong to any package on /. Depends on equery and qlist
#!/bin/bash
loginfo() {
echo $* >&2
}
lastcheck() {
lines=$(equery -q belongs $1 |wc -l)
if test $lines -eq 0; then
return 0