Skip to content

Instantly share code, notes, and snippets.

$ tx push -s
Pushing translations for resource quassel.master:
Pushing source file (po/quassel.pot)
Resource does not exist. Creating...
Cannot get type for resource. Please, add it in the .tx/config file.
TypeError: cannot concatenate 'str' and 'NoneType' objects
$ cat .tx/config
[main]
host = https://www.transifex.net
ip6_gw=beef:fac3::1
ip6_vhost=beef:fac3::2
irc_ports=6667:6669
interface=eth0
echo 1 irc6 >> /etc/iproute2/rt_tables
ip -f inet6 route add default via $ip6_gw table irc6 dev $interface src $ip6_vhost
ip -f inet6 rule add fwmark 1 table irc6
ip6tables -t mangle -I OUTPUT -o $interface -p tcp --dport $irc_ports --syn -j MARK --set-mark 1
#!/bin/bash
set -u
basepath="${1:-/}"
read device rest < <(df -P "$basepath" | grep ^/)
mount | grep "^${device} " | while read dev on mountpoint rest; do
[[ "$mountpoint" != "${basepath}" ]] && echo "$mountpoint"
done
@AlD
AlD / solaris-pkgrm-broken-pkgs.sh
Created September 11, 2012 12:33
remove broken packages (unresolved dependencies) from a Slowlaris host
#!/usr/bin/env bash
pushd /var/sadm/pkg &&
for pkg in *; do
[ -f $pkg/install/depend ] &&
egrep '^[PR] ' $pkg/install/depend |
tr '[:space:]' ' ' |
cut -d\ -f2 |
while read dep; do
if ! pkginfo -q $dep; then
$ cat myapp.pl
#!/usr/bin/env perl
use Mojolicious::Lite;
get '/' => sub {
my $self = shift;
my $text;
$text = $self->render_partial('a', body => rand());
$text .= $self->render_partial('b', body => rand());
my $from = [ 'links', 'vlans' ];
my $what = [ 'links.ifname', 'vlans.vlanid' ];
my $where = { 'links.neighbour' => { '=' => \"vlans.device",
'like' => $neighbour . '%'
},
'links.device' => $device,
};
my $order = '';
my $result = $dbh->select($from, $what, $where, $order);
@AlD
AlD / gist:3900298
Created October 16, 2012 16:14
Net::SSH2 poll
my $cmd = '/bin/cat /proc/cpuinfo';
my $chan = $ssh->channel;
$chan->exec($cmd);
my $buf;
my @poll = ( { handle => $chan,
events => [ 'in', 'ext', 'channel_closed' ], },
);
@AlD
AlD / Wrapper.pm
Created March 14, 2013 16:12
Add a default search base to Net::LDAP via new(base => $base)
package Net::LDAP::Wrapper;
use strict;
use parent 'Net::LDAP';
my $_base;
sub new {
@AlD
AlD / poor_mans_at.sh
Created June 27, 2013 12:23
when you have no atd, this is handy
#!/bin/bash
# Basic bash implementation of at(1). Obviously doesn't survive a reboot.
poor_mans_at() {
delay=$[$(date +%s -d "$*") - $(date +%s)]
if [[ ! "$delay" -ge 0 ]]; then
echo "error: invalid time specification" >&2
return 1
fi
mapfile cmds
( sleep $delay && eval "${cmds[@]}" )&disown
$ ./redir.sh 3>&1 >&2 | while read line; do
> echo $line go\!
> done
Hey!
Ho!
Let's go!
$ cat redir.sh
#!/bin/bash