Voder-Vocoder

The Log of Hal Canary

Navigation: Home | THE LOG | Log Archives | Resume | Contact Info | Public Key | SSL | Math Applets | Site Map | RSS2 | Atom | Backend

Archive for the “Computers & Code” Category

« Previous Entries

spam rules

These are my new spamassassin rules. If your configured email client fails to have a valid DKIM or DK signature or SPF record, I’m probably going to mark you as spam.

#### .spamassassin/user_prefs
required_score -1.0
score DKIM_VALID_AU -10.0
score SPF_PASS -5.0

99% of my legitimate correspondents are okay already.

Hal Canary | Computers & Code, Life | 2011-10-26 15:01:41 UTC
Permanent Link |
Comments Off (but feel free to email)

change-epub-formatting.py

#!/usr/bin/python
#DTPD#
import subprocess
import os.path
import sys
import glob

def fixfile(in_file_name):
  ebookconvert = r'C:\PROGRA~2\Calibre2\ebook-convert.exe'
  #ebookconvert = '/usr/bin/ebook-convert'
  base = os.path.basename(in_file_name)
  dirn = os.path.dirname(in_file_name)
  newdir = 'myformat'
  try:
    os.mkdir(os.path.join(dirn, newdir))
  except OSError:
    pass
  out_file_name = os.path.join(dirn, newdir, base)

  cmd = [ebookconvert, in_file_name, out_file_name,
    '--preserve-cover-aspect-ratio',
    '--change-justification', 'left',
    '--margin-bottom', '4',
    '--margin-left', '4',
    '--margin-right', '4',
    '--margin-top', '4',
    '--remove-paragraph-spacing']
  print ' '.join(cmd), '\n'
  sproc = subprocess.Popen(cmd)
  sproc.wait()

if __name__ == '__main__':
  for arg in sys.argv[1:]:
    for filen in glob.glob(arg):
      fixfile(filen)
  exit(0)

Hal Canary | Books, Computers & Code | 2011-06-24 15:28:54 UTC
Permanent Link |
Comments Off (but feel free to email)

scrabble.sh

#!/bin/sh
#DTPD#
DICT=/usr/share/dict/words
test "$1" || { cat "$0"; exit 1; }
exec grep -i "$@" "$DICT" | less
#
# Useage:
#   scrabble.sh PATTERN
# Example:
#   scrabble.sh '^a[lonrchl]\{4,7\}$'

Hal Canary | Computers & Code | 2011-06-21 06:27:46 UTC
Permanent Link |
Comments Off (but feel free to email)

txt to html with hyperlink conversion

I don’t have time to be writing programs.

#!/bin/sed -f
1 i\
<!DOCTYPE HTML PUBLIC \
"-//W3C//DTD HTML 4.01 Transitional//EN" \
"http://www.w3.org/TR/html4/loose.dtd">\
<html><head>\
<meta http-equiv="Content-Type" \
content="text/html; charset=utf-8">\
<title></title></head><body>
s/\&/\&amp;/g;
s/\"/\&quot;/g;
s/</\&lt;/g;
s/>/\&gt;/g;
s/'/\&#0039;/g;
s/\(http:\/\/[^ ]\+\)/<a href="\1">\1<\/a>/g
1 s/^/<pre>/
$ s/$/<\/pre><\/body><\/html>/

Hal Canary | Computers & Code, Uncategorized | 2011-04-23 20:19:44 UTC
Permanent Link |
Comments Off (but feel free to email)

/bin/coin

#!/usr/bin/env python
# ~/bin/coin
#DTPD#
if (ord(open('/dev/random').read(1)) % 2):
 print "heads"
else:
 print "tails"

But why throw away seven bits of entropy?

#!/usr/bin/env python
#DTPD#
n=ord(open('/dev/random').read(1))
for i in xrange(8):
 if  (n % 2):
  print "heads",
 else:
  print "tails",
 n >>= 1
print

Hal Canary | Computers & Code | 2011-04-10 22:21:24 UTC
Permanent Link |
Comments Off (but feel free to email)

convert asterisks to html-bold via sed

#!/bin/sed -f
#DTPD#
#convert *bold* text to *html bold*
# also converts /italic/ text to html em
s/\*\([^\*]*\)\*/<strong>\1<\/strong>/g;
s/\/\([^\/]*\)\//<em>\1<\/em>/g;

Hal Canary | Computers & Code | 2011-03-07 20:37:44 UTC
Permanent Link |
Comments Off (but feel free to email)

speaking of the Touch…

I’ve decided that using it as an ebook reader is incredibly convenient, because of its small size (it fits nicely in my pocket!). The only advantage an e-ink screen still holds for me is super-long battery life.

Hal Canary | Books, Computers & Code | 2011-03-05 21:23:56 UTC
Permanent Link |
Comments Off (but feel free to email)

HTML/CSS for Ipod Touch

I added these lines to the CSS for this page

pre { overflow:auto;
      overflow-y:visible; }

and this line to the (X)HTML

<meta name="viewport"
    content="width=device-width" />

which seems to make the site render much much better on my Ipod Touch’s small screen.

Hal Canary | Computers & Code | 2011-03-05 21:20:35 UTC
Permanent Link |
Comments Off (but feel free to email)

Occam the Dell

I really think a computer should last more than 32 months. Sloop, the computer I built in June 2008, failed yesterday. Coincidentally, I ripped the old HDDs out of Dalek the day before to send it to be recycled. Now I have two old boxes to recycle.

I bought a cheap desktop at the store yesterday and didn't even try to look for a good deal online. I just wanted to have a functioning computer. The new case is 34% smaller by volume (I just measured). I would have gotten something even smaller, but I wanted a t least one PCI slot, one PCI Express slot, and room to mount my old HDD. I named it Occam.

Occam is a Dell. The CPU is a Intel Pentium Dual-Core E5800. One benchmark rates this as 34% faster than Sloop's Athlon 64 X2 6000+, which was an upgrade 18 months ago.

Hal Canary | Computers & Code, Life | 2011-02-14 22:43:08 UTC
Permanent Link |
Comments Off (but feel free to email)

REAL10

“Real” is not an acceptible synonym for “80-bit floating-point number.” Real numbers aren't even countable, much less in a bijection to a set of size 2^80.

Hal Canary | Computer Science, Computers & Code, Mathematics | 2010-12-09 00:20:44 UTC
Permanent Link |
Comments Off (but feel free to email)

using emacsclient

Attention Emacs users. It took me a while to realize that new-style fonts can be enabled by adding this to the ~/.emacs file.

(set-face-attribute 'default
  nil :font "Monospace-11")

So here's how I set up the look of Emacs in my .emacs:

(require 'color-theme)
(color-theme-dark-laptop)
(set-scroll-bar-mode 'right)
(tool-bar-mode nil)
(menu-bar-mode nil)
(set-face-attribute 'default
  nil :font "Monospace-11")

And here's my emacs startup script:

#!/bin/sh
#DTPD#
# ${HOME}/bin/e
if test "$DISPLAY" ; then
  nohup /usr/bin/emacsclient \
    -a '' -n  "$@" \
    > /dev/null 2>&1 &
else
  exec /usr/bin/emacs "$@"
fi

This startes emacs in daemon mode if it's not already running (there's not a lot of harm in leaving a daemon going in the background all the time) and then the client tell the daemon to spawn a new window to open the files mentioned in the command-line arguments. The "nohup" part deparents the server so you don't get error messages hitting your console.

Hal Canary | Computers & Code | 2010-11-07 13:36:36 UTC
Permanent Link |
Comments Off (but feel free to email)

Flashblock Alt Image

I noticed that someone had the bright idea to layer Adobe Flash objects *over* images using a <div style="background-image:url($IMAGE_URL)">. That way, when the Flashblock add-on blocks a Flash object, you can give users an idea of what you are blocking. Here’s an example of the technique in use, but it won’t make any sense if you aren’t using Flashblock.

Hal Canary | Computers & Code | 2010-09-26 19:30:06 UTC
Permanent Link |
Comments Off (but feel free to email)

« Previous Entries

Copyright 1997-2011 by Hal Canary.
mailto: h3 at halcanary dot org
http://halcanary.org