Skip to content

Instantly share code, notes, and snippets.

@xim
xim / sendmail-checkattach-ng.bash
Created June 25, 2010 13:07
CheckAttach NG bash script
#!/bin/bash
# Sendmail replacement inspired by CheckAttach script for mutt.
# http://wiki.mutt.org/?ConfigTricks/CheckAttach for the original script.
# To use, simply add the following line to your .muttrc:
# set sendmail="/path/to/this/script -oi -oem"
# Note that -oi -oem are the default parameters given by mutt to sendmail. You
# could also use e.g. -t -i or... whatever floats your boat :)
# Then restart mutt.
@xim
xim / rarx.bash
Created July 11, 2010 20:08
Unrar recursively in bash, using evil™
#!/bin/bash -xv
# ^^ debug, feel free to remove...
# Enable evil expansion mode: +([0-9])
shopt -s extglob
do_unrar() {
rar x "$@"
}
@xim
xim / mangastream.py
Created August 5, 2010 02:48
Manga Stream “direct download” by scraper
#!/usr/bin/env python
"""%prog [-d] Manga [chapter]
NOTE: Does not work any more!
I probably won't fix it. Ever.
Patches accepted =)
Quick and dirty: Manga Stream direct download hack.
Fetches a named comic matching the regex given on cmd line. E.g:
@xim
xim / playlist.bash
Created October 25, 2010 16:10
mplayer wrapper for making playlists
#!/bin/bash -f
SORT="sort -n"
filter="-type f"
DENIED_EXTS="txt m3u pls jpg jpeg gif nfo srt sub torrent zip rar cbz cbr"
if [[ "$1" =~ ^- && "$1" != "--help" ]] ;then
if [[ "$1" = "--cat" ]] ; then
SORT="cat"
@xim
xim / annoy.pl
Created November 9, 2010 21:39
A short and annoying script for irssi, made on request :p
use strict;
use vars qw($VERSION %IRSSI);
$VERSION = '0.1';
%IRSSI = (
authors => 'Morten M. Neergaard',
contact => 'user xim some major IRC networks? =)',
name => 'annoy.pl',
description => '/annoy <msg> # sends <msg> to all in current channel (except me)',
license => 'Who cares',
@xim
xim / r00.bash
Created November 22, 2010 23:12
A wrapper around RAR(1) for making archives on the form .rar .r00 etc.
#!/bin/bash
# Make rar multiparts with the extensions .rar .r00 etc.
# Many programs prefer / look for this, not the .partX.rar
# Usage: r00 [archive name OR file1] [file(s)]
# Enable evil expansion mode: +([0-9])
shopt -s extglob
for arg in "$@" ; do
@xim
xim / go2.py
Created May 19, 2011 01:34
Hack for opening arbitrary files in gnome using their default program
#! /usr/bin/env python
# encoding: utf-8
# Written by Morten Minde Neergaard – m@8d.no
# Based on idea from http://therning.org/magnus/archives/251
"""
Open a file in a manner similar to gnome-open.
Fall back to using xdg-open.
Return code: The sum of all return codes given by the called programs.
@xim
xim / cluster_example.py
Created October 11, 2011 20:19
Clustering K-Means by euclidian distance, yay!
import sys
import numpy
from nltk.cluster import KMeansClusterer, GAAClusterer, euclidean_distance
import nltk.corpus
from nltk import decorators
import nltk.stem
stemmer_func = nltk.stem.EnglishStemmer().stem
stopwords = set(nltk.corpus.stopwords.words('english'))
@xim
xim / custom-term.patch
Created September 24, 2012 07:18
Quick patch to oe to allow custom terminals.
diff --git a/meta/classes/terminal.bbclass b/meta/classes/terminal.bbclass
index 3cfc84b..906fa58 100644
--- a/meta/classes/terminal.bbclass
+++ b/meta/classes/terminal.bbclass
@@ -4,7 +4,7 @@ OE_TERMINAL[choices] = 'auto none \
${@" ".join(o.name \
for o in oe.terminal.prioritized())}'
-OE_TERMINAL_EXPORTS = 'XAUTHORITY SHELL DBUS_SESSION_BUS_ADDRESS DISPLAY EXTRA_OEMAKE SCREENDIR'
+OE_TERMINAL_EXPORTS += 'XAUTHORITY SHELL DBUS_SESSION_BUS_ADDRESS DISPLAY EXTRA_OEMAKE SCREENDIR'
@xim
xim / statements.py
Last active December 16, 2015 10:29
#!/usr/bin/env python
import re
statement_matcher = re.compile(r'^s(.)(?:(?!\1).)*\1(?:(?!\1).)*\1$')
def get_interesting_triplets(dictionary_file, statement_file):
with open(dictionary_file) as fh:
words = [word.strip() for word in fh.readlines()]