Older blog entries for Leimy (starting at number 35)

26 May 2004 (updated 26 May 2004 at 06:20 UTC) »

How not to write code with scsh [Scheme Shell]

For the hell of it I decided to write that "content_index" calculator in scsh.

With a lot of help from Riastradh on #scsh I've now got the following:

(let ((read-ls-output (field-reader (infix-splitter (rx (+ " ")) -8))))
 (format #t "~A kilobytes"
 (/ 
 (fold + 0
 (map string->number
 (run/strings
   (| (find "." -name "content_index" -print0)
    (xargs "-0" ls -l)
        (begin
          (read-line)
          (awk
                (read-ls-output)
                (record fields) ()
                (#t (format #t "~A~%" (list-ref fields 4))))))))) 1024))(newline))
Which works but is incredibly ugly.

It performs the find as you would expect. Then I use the scsh "awk"-like functionality to filter out the 4th field [size]. run/strings builds a list of strings which I convert to numbers using map with string->number.

To sum the items I call fold with + and 0 [is the identity of addition]. I divide it by 1024 and use the result in a format statement [works like printf for scheme]. The let statement binds me an expression holding the result of field-reader which produces a function. The -8 means that I expect at least 8 records and the rest are seen as the final record. This is for

ls -l
when you have files/directories with spaces.

Nasty eh?

There are better ways...

And here it is:

(begin
(format #t "~A kilobytes"
(/
(fold + 0
(map file-info:size 
(map file-info
(run/strings (find "." -name "content_index"))))) 1024)) (newline))

Again... thanks fo Riastradh for teaching me about the REPL.

L8er...

This is pretty awesome for you OS X folks:

http://ranchero.com/bigcat/

I was able to use this Finder plugin thingy to write a bash script that allows the tarring of many directories from finder with a few clicks.

here is the script:

#!/bin/sh

# Tar directories.

while [ "$*" != "" ] do if [ -d "$1" ] then echo "tar cvfz $1.tgz -C `dirname $1` `basename $1`" tar cvfz $1.tgz -C `dirname $1` `basename $1` fi shift done

chmod u+x and stick it in ~/Library/Application\ Support/Big\ Cat\ Scripts/Files. Now select a bunch of directories and ctrl-click [right click] and find the scripts context menu and select whatever you named the above script.

It will echo what it's doing to the console log. If you don't want this behavior remove the echo line.

Saves me a bunch of time...

Dave

Still workin... Getting ready for next week's apartment hunt in Seattle. Lots to do. I finally spent some time figuring out Mach IPC via MiG in OS X. I need to do a write-up on it so people can refer to it when they have problems. I am not sure I am ready to answer questions about how it all works yet so I don't want to put myself out there as a Mach IPC guru.

Other than that my work-work has picked up more again. This is good of course. I hate being idle.

8 Mar 2004 (updated 26 May 2004 at 06:23 UTC) »

For you Mac OS X 10.3 folks running Mail.app:

You may or may not notice that content_index files get very large in your ~/Library/Mail folder.

To find them do "find . -name "content_index" -print0 | xargs -0 ls -l

If you have many mailboxes and accounts this can get pretty big... I checked mine today and it was 1456KB.

I used this one liner script to calculate:

echo `find . -name "content_index" -print0 | xargs -0 ls -l | awk 'END { for (i = 1; i < NR; ++i) print "+"; print "1024/p"} {print $5}' | dc` kilobytes

It's using awk to pipe commands to dc... reverse polish notation rules.

Been a long time since I've posted. Started working from home and am going to relocate to the Seattle area in a few months.

Still trying to keep my hands dirty in OpenDarwin related stuff. Right now my focus is libFoundation and occasionally 7WX! [http://www.7wx.org]

Also chillin out on orkut these days... It's oh so trendy... please get a friend to sign you up so I can be connected to more of the hundreds of thousands of folks out there.

Also learning Haskell and continuing to love emacs...

Nifty applescript "alarm clock" I use with iCal... Inspired, adapted and mostly stolen from my buddy Jason Deraleau on #opendarwin [irc.freenode.net]



-- launch iTunes and start music slowly increasing volume
set volume 5
try
	tell application "iTunes"
		activate
		play playlist "easy"
		set i to 10
		repeat 100 times 
			set the sound volume to i 
			set i to i + 1 
			delay 0.25
		end repeat 
	end tell 
on error 
	beep 
end try

Thanks again Jason

Haven't updated since July... Seems its about time.

Working from home these days. FreeBSD 5.x CURRENT is a bit of a mess these days. Matt Dillon forked 4.8 and made dragonflyBSD and I must say I find it somewhat refreshing. Too bad I can't run it yet. My hardware is far too new. When my new G5 comes [just shipped tonight] I hope I will be able to get FBSD on the old G4 :) I realize it doesn't do "release" yet but I am hoping to find some time to work on it.

Other than that these days.. just hackin around with Cocoa and Applescript in my spare time

Took some time out to get familiar with Haskell and have been playing around with Lisp too recently. There are a lot of different perspectives one can pick up from learning a new programming language. I suggest you try it... many idioms out there that may lend themselves to solutions you have in mind.

Sometimes open source people aren't open minded enough... C++ is treated like a red-headed stepchild in spite of the fact that very good things have been done with the subset of it that is commonly implemented :).

Nothing like rambling to one's self on one of the older public blog sites :)

4 Jul 2003 (updated 4 Jul 2003 at 03:04 UTC) »

Haven't done this in a LOOONG time. I stopped watching most of KDE development as I haven't had the time. I try to stay connected with my OpenDarwin peeps though and hope to get some time to do something useful.

in the meantime I am keeping busy with work and interesting projects I can't talk too much about.



NDA's kick ass :)

I sent Soeren Schmidt some hardware for an SiI 3112 controller chip and he has supported this nice SATA device in FreeBSD... its coming to you for FreeBSD 5.2

Check here!!

Its good to know that, though I haven't had enough time to code stuff myself lately for my favorite open sourced projects, that I can still make a bit of a difference somehow.

Doing what I can to test FBSD CURRENT. Getting back to PC assembly after a really long time too. Thinking about optimizing some of FBSD's libc for Athlon/Intel P3 and higher CPUs. SIMD operations for things like bcopy could be a useful enhancement. How many programs do you think call that anyway?

FreeBSD is a good platform to try this on since it is encouraged to recompile the whole system to get updates. If there is a good way to switch which implementation of certain libc functions get called it could be a nice enhancement.

Anyway that's what I have been doing in my decreasing spare time.

Well its been quite a while since my last entry... I am currently working with the C99ification project for FreeBSD... I got into it because of my interest in porting applications to that platform.

I am going to spend some time learning how things are done in libc and etc.

As a result of less time to develop stuff I am now selling my Sharp Zaurus SL-5500.

I already have a PDA and don't really need two to stay organized ... in fact that confuses things more than one would might think double the organizers would do!

I want to help out my fellow Open Source developers as much as possible so if you tell me you saw the item from this diary entry I will knock some of the price off for ya!
Take it easy.

26 older entries...

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!