weblog d’un abbe


BitlBee 3.0 and SRV lookups

Filed under: Fun, Hacking — Tags: , , , , , , , , — abbe @ 1023

As BitlBee 3.0 is released and has now included OTR support :), I don’t have to maintain bitlbee-otr anymore. For FreeBSD, I noticed, the SRV DNS records lookup support is not compiled in by default, so I submitted a diff to upstream and the maintainer. For users of irc/bitlbee port, who want to try SRV lookup support can try the port diff.

Let me know if you experience any issues or have any questions.


BitlBee OTR 1.2.8 Released

Filed under: Fun, Hacking — Tags: , , , , , , , — abbe @ 0659

Just finished integrating OTR support code from bitlbee-otr into bitlbee-1.2.8, and is available as bitlbee-otr-1.2.8.tar.bz2 (sha256sum: f09a88be7d995a0cc489ee9bea4ac49dc326c1b2e9396a8e7cc886b3894883a3 , md5sum: 1273e7861f393473c5060f5ec5d6c214). PR for FreeBSD port is not needed anymore. The tarball can be downloaded from:

Thanks to SourceForge and Veniamin (aka zloidemon) for hosting the tarball.

UPDATE: FreeBSD port irc/bitlbee-otr is updated.


BitlBee OTR 1.2.7 Released

Filed under: Fun, Hacking — Tags: , , , , , , , — abbe @ 1410

Just finished integrating OTR support code from bitlbee-otr into bitlbee-1.2.7, and is available as bitlbee-otr-1.2.7.tar.bz2 (sha256sum: 2cb8817e98e5ac40dda1f3e8c7a76ae1ed421c265c85e2455c4f3080b9e99982, md5sum: 063d849c4011c599c4980eda87f0e0b4). PR for FreeBSD port needs to be submitted. The tarball can be downloaded from:

Thanks to SourceForge and Veniamin (aka zloidemon) for hosting the tarball.

UPDATE: The corresponding FreeBSD PR is ports/146666.


BitlBee OTR 1.2.6a released

Filed under: Fun, Hacking — Tags: , , , , , , , — abbe @ 1538

Just finished integrating OTR support code from bitlbee-otr into bitlbee-1.2.6, and is available as bitlbee-otr-1.2.6a.tar.bz2 (sha256sum: ab8bb786fcd34f87c4b8056b3786d896ee7aeae7fc21d09a49d3be920891c135, md5sum: 3419f352a8dfc06b1bd1954ddeb9ee34). The corresponding FreeBSD PR is ports/145911. The tarball can be downloaded from:

Thanks to SourceForge and Veniamin (aka zloidemon) for hosting the tarball.


BitlBee OTR 1.2.5 released

Filed under: Fun, Hacking — Tags: , , , , , , , — abbe @ 1822

Just finished integrating OTR support code from bitlbee-otr into bitlbee-1.2.5, and is available as bitlbee-otr-1.2.5.tar.bz2 (sha256sum: 93d283ff829decf6ee8c89d23f4ad441f3a6c24820bba8ea9580e738865bf605, md5sum: 26c20921ff586fcd5253a324f33bde1b). The corresponding FreeBSD PR is ports/144975. The tarball can be downloaded from:

Thanks to Veniamin (aka zloidemon) for hosting the tarball.


Pencil on FreeBSD

Filed under: Fun, Hacking — Tags: , , , , , — abbe @ 2028

Someone recently mentioned to me about using a proprietary GUI mockup tool, which reminded me I’ve to port Pencil to FreeBSD. So I’ve submitted a PR for the port. Happy sketching GUIs…;)


Hacking a codegen

Filed under: Experiences, Fun, Hacking, Yippee!! — Tags: , , , , , , — abbe @ 0456

So, finally I’ve hacked a basic AMD64 code generator, after so many tries. This code generator is hacked in Common Lisp, and is currently generating a code for a very simple toy like language. I’ve not written any grammar specification for it. It is a LISP like language. This piece of code generator is dedicated to one of my cool friend Edwin Jose, and is thus named as louzer. Following is an example of the language for which louzer generates code.

	 (let principal rate time amount x)
	 (= principal 1000)
	 (= rate 10)
	 (= time 100)
	 (= x 100)
	 (= amount
		(/ (* principal (* rate time))
	 (print "Amount (%d) - %d is %d.\\n"  amount x (- amount x))
	 (print "Hello World, louzer\\n"))

The language code is also embedded along with the source code in the LISP file. Following is how I’m using it with GNU clisp implementation:

% clisp louzer.lisp |tee test.S
.section .text
.extern printf
.type main,@function
.globl main
 pushq %rbp
 movq %rsp, %rbp
 subq $40, %rsp
 movq $1000, %rbx
 movq %rbx, -8(%rbp)
 movq $10, %rbx
 movq %rbx, -16(%rbp)
 movq $100, %rbx
 movq %rbx, -24(%rbp)
 movq $100, %rbx
 movq %rbx, -40(%rbp)
 movq -16(%rbp), %rbx
 imul -24(%rbp), %rbx
 imul -8(%rbp), %rbx
 movq %rbx, %rax
 movq $100, %rbx
 xorq %rdx,%rdx
 idiv %rbx
 movq %rax, -32(%rbp)
 leaq __string_0,%rdi
 movq -32(%rbp), %rsi
 movq -40(%rbp), %rdx
 movq -32(%rbp), %rbx
 subq -40(%rbp), %rbx
 movq %rbx, %rcx
 xorq %rax,%rax
 call printf
 leaq __string_1,%rdi
 xorq %rax,%rax
 call printf
 xorq %rax, %rax
 movq %rbp, %rsp
 popq %rbp
.section .rodata
__string_1: .string "Hello, louzer World\n"
__string_0: .string "Amount (%d) - %d is %d.\n"
/* Generated by louzer :) */

Above is the piece of AMD64 assembly code emitted by the louzer. So, now time to assemble and link the above assembly code and generate the output of the above code.

% cc -o test test.S
% ./test
Amount (10000) - 100 is 9900.
Hello, louzer World

Voila. Oh, sorry to keep you waiting, now you can download the louzer.lisp and have fun. BtW, code is not perfect and has couple of limitations, which I’ve not fixed due to lack of time, as I’ve an exam day after tomorrow. So, I’ll be able to work on it only after 20081219. Happy hacking codegens…;)

NOTE (for Grammar Nazis): Forgive me for any grammatical mistakes you encounter above, and ofcourse point out the mistake :).

P.S. Forgot to mention, you’ll need an AMD64 architecture CPU, toolchain and POSIX OS to test out above stuff.


Ready to assassinate spam

Filed under: Experiments, Fun, Hacking — Tags: , , , , , — abbe @ 2136

Since a week or two, I noticed I suddenly started to get many spams (at the rate of around 10/day) delivered to my gmail inbox. I reported them every time, but that is of not much use. So tired of reporting spams, I started to create filters (in gmail) based on From address, ‘Subject’ etc. to delete them as soon they arrive, and I noticed that some of the ham mails also got deleted due to my filters. So, to get rid of this problem yesternight I installed SpamAssassin (which I’m afraid of installing earlier because I heard of its complex configuration) on my box integrated with postfix instance on my Gentoo GNU/Linux. The installation (thanks to portage) is very easy and integration with postfix is also quite easy and well documented on its wiki. And now, the best part, my SpamAssassin today recognized those mails as spam, which gmail‘s spam filters delivered into my inbox :).

Following is a Gnus hack to report spam as ham and ham as spam :

(defun my-gnus-mark-spam()
  (gnus-summary-save-in-pipe "spamc -L spam")
  ;; substitute "nnmaildir:spam" with the name of group holding "spam"
  (gnus-summary-move-article nil "nnmaildir:spam"))

(defun my-gnus-mark-ham()
  (gnus-summary-save-in-pipe "spamc -L ham")
  (gnus-summary-respool-article nil))

;; in summary mode use "B s" and "B h" keys to mark a mail as spam and ham
;; respectively for SpamAssassin to learn, and to also move to "spam" maildir
;; or respool mail accordingly
(define-key gnus-summary-mode-map (kbd "B s") 'my-gnus-mark-spam)
(define-key gnus-summary-mode-map (kbd "B h") 'my-gnus-mark-ham)

I could have used Gnus built-in spam filtering, but Gnus is not the only MUA I use ;) . Anyways, happy assassinating spam…;)


fake identd server

Filed under: Fun, Hacking — Tags: , , — abbe @ 2007
-- identd: RFC1413 incompliant identd server
-- author: Ashish Shukla <gmail.com!wahjava>
-- license: GNU GPLv2 or later version at your option
-- special thanks to: consolers on #emacs
-- 1. Compile the file: abbe@chateau $ ghc --make identd.hs
-- 2. Make it setuid root: abbe@chateau $ chown 0 identd; chmod u+s identd
-- 3. Execute it: abbe@chateau $ ./identd abbe
-- happy faking ident

import System.IO (hGetContents, hClose, openFile, hPutStrLn, hGetLine)
import System.Random (randomRIO)
import IO
import Network.BSD
import Network.Socket

import System.Environment (getArgs, getProgName)

import System.Posix.User (getUserEntryForName, setUserID, UserEntry, userID)

import Control.Exception (evaluate)

wordsFile = "/usr/share/dict/words"

loadWords :: FilePath -> IO [String]
loadWords fileName = do
    handle <- openFile fileName ReadMode
    contents <- hGetContents $ handle
    let listOfWords = lines contents
    lenWords <- evaluate (length $ listOfWords)
    hClose handle
    return listOfWords

getUserName :: [String] -> IO String
getUserName words = do
    index <- randomRIO (0, length words - 1) :: IO Int
    return (words !! index)

handleSocket :: [String] -> IO (Socket, SockAddr) -> IO Bool
handleSocket words struct = do
  (socket, sockaddr) <- struct
  handle <- socketToHandle socket ReadWriteMode
  line <- hGetLine handle
  name <- getUserName words
  -- logged-in from a LISP Machine ;)
  hPutStrLn handle $ (withoutWS line) ++ " : USERID : LISPM : " ++ name
  hClose handle
  return True
  where withoutWS = filter (\x -> x `notElem` [ '\r', '\n'])

main = do
  args <- getArgs
  progName <- getProgName
  if null args
    then putStrLn $ "Usage: " ++ progName ++ " [username]"
    else do
        user <- getUserEntryForName $ args !! 0
        let uid = userID user
        rng <- getStdGenuu
        ssock <- socket AF_INET6 Stream defaultProtocol
        bindSocket ssock (SockAddrInet6 113 0 (0,0,0,0) 0)
        setUserID uid
        words <- loadWords wordsFile
        sockaddr <- getSocketName $ ssock
        listen ssock 5
        loopForever (handleSocket words . accept) ssock
        sClose ssock
  where loopForever function y = do
            retval <- function y
            if retval
              then (loopForever function y)
              else return ()

Happy faking ident…;)


bitlbee-otr 1.2.3 update

Filed under: Fun, Hacking — Tags: , , , — abbe @ 0826

I’ve added some fixes to the existing bitlbee-otr tarball related to OTR help. Please update your installation, if you’re not getting help information related to OTR support in your bitlbee-otr installation. Happy IMing off-the-record…:)

Older Posts »

Create a free website or blog at WordPress.com.