The Foursquare Blog

recording discoveries along the pathway of life

Entries tagged "code".

5th May 2010

Tags: advogato, code, programming.
1st May 2010

Tags: advogato, code, programming.
Referenced by: Time Conversion: timegm()
12th July 2006
My list of mailing lists is getting so large that I now have a class of mboxes that are more archive and reference than something I'm actively interested in.

Here's an update for those following my newmail.cc mailbox reporter program.

I added the capability of listing archive mboxes in your .newmailrc with a value of -2. Then you can selectively hide/show this second-tier list of mboxes with the -H and -S switches.

I also added an environmental getopt() that behaves the same way as getopt(), but prepends the command line options from an environment variable ahead of the argv[] options.

env_getopt() seemed like something that somebody would have implemented before, but I didn't see anything like it in my web search. I may have reinvented the wheel. Anyway, it is now implemented as GPLv2 in case others need the same functionality.

[Edited to fix link]

Tags: advogato-old, code, email.
25th June 2006
fxn:

Advogato also has XMLRPC, with which you can do programmatic access to your diary. I do this in the hope that it saves advogato bandwidth.

Below is a small python beginner script that I cooked up just for this task. It checks the dates of the posts and saves the new ones as individual files.

If someone finds it useful, please feel free to use it.


#!/usr/bin/python

import xmlrpclib import os import difflib

def Download(filename, entry): print "Downloading: " + filename out = open(filename, "w") create, update = server.diary.getDates("cdfrey", entry) out.write("%s\n" % update) out.write(server.diary.get("cdfrey", entry)) out.close()

def GetTimestamp(filename): inf = open(filename, "r") s = inf.readline() inf.close() return s[0:len(s)-1]

def Update(filename, entry): print "Updating: " + filename filetime = GetTimestamp(filename) webcreated, webupdated = server.diary.getDates("cdfrey", entry) if( filetime != webupdated ): print "Entry %d is out of date" % entry if os.access(filename + ".bak", 0): os.unlink(filename + ".bak") os.rename(filename, filename + ".bak") Download(filename, entry)

oldf = open(filename + ".bak", "r") newf = open(filename, "r") oldl = oldf.readlines() newl = newf.readlines() print ''.join(difflib.unified_diff(oldl, newl))

path = "/home/cdfrey/text/advogato/posts/" server = xmlrpclib.Server("http://www.advogato.org/XMLRPC")

entryCount = server.diary.len("cdfrey")

for entry in range(entryCount): filename = path + "advogato.%03d" % entry if os.access(filename, 0): Update(filename, entry) else: Download(filename, entry)

Tags: advogato-old, code, programming.
2nd April 2006
dwmw2 mentioned that he can't live without a tree view of mail folders showing which have new messages.

I currently use a combination of procmail, mutt, and my own scripts to sort and read mail. The procmail script sorts the mail into organized mbox files in ~/Mail/. Then I run newmail to get a list of mailboxes with new messages in them. Then I use

mutt -f Mail/mboxfile
to read.

Here's an example of my "newmail" output:

 Total     New  Mbox                                                          
------  ------  ----------------------------------------------                
    55       1  barry
   158      21 *bochs-dev (1)
  2096    1405  boost
   446     444 *bugtraq (3)
    80      78  bugtraq-generic
   402     144  c++
  4072       3  canada-dmca-opponents
  1200     157 *cdfrey (1)
   166     120  debian
   246      67  gentoo-announce
    41      15 *gentoo-desktop (1)
  1848    1022  gentoo-dev
    38       6  gentoo-gwn
    82      28  gentoo-hardened
   355     237 *gentoo-portage-dev (1)
   605      62  gentoo-security
   276     247 *gentoo-server (4)
  1217    1217  git
    11      10  gnupg-announce
    91      90  gnupg-devel
   423     331  gnupg-users
   129      82  kt
  1162       8  kwlug
   364     133  libusb
 10023   10022  linux-kernel
   601     344  linux-thinkpad
   144     144 *mailer-daemon (5)
   551     314  mplayer-users
   411     401  open-graphics
  1404     164  plusplus
   541      35  plusplus-commits
    63      34  risks
   211     189  slashdot
    47       2  spca50x-devs
     8       1  xboard

Yes, I'm a little behind. :-) This shows the total messages in the mbox file, the total unread messages, which mboxes have had new mail since I last checked (*), and how many new messages arrived since I last checked.

It's worked pretty well, not only as a mail system but as a spam whitelist too. I only use the code personally, so the code isn't polished for release. It's a single .cc file that can be compiled standalone, so it shouldn't be too hard to play with if you want.

Tags: advogato-old, code, email.
15th September 2005
I finally got around to adding some features to the GNU split command, which I felt were sadly lacking ever since I thought of them. :-)

I often use split to break huge files into multi-CD images, such as for backups or archiving. At the same time, I often find I'm low on disk space, so I would like to process each split file chunk as they appear instead of doing it all at once at the end.

I wrote a patch that adds exec and pause functionality with the following arguments:

  -e, --exec=CMD          run CMD after each output file is closed
  -w, --exec-wait=CMD     run CMD after each output file is closed
                          and wait for the child to exit
  -p, --pause             pause for keypress after each output file is closed

I find these features very useful, so I hope they make it into the official coreutils tarball.

If anyone has any tips on how to handle recovering a tty-based STDIN (see the split source code), please let me know. I'm currently just open()ing the tty on STDOUT, but that is not ideal.

Tags: advogato-old, code, programming, split.

RSS Feed

Created by Chronicle v4.6