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

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

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

read?

Classics of American literature I may have missed: what should I read?

Hal Canary | Books | 2010-09-25 09:22:42 UTC
Permanent Link | Comments Off

recent books

[cover]The City & The City by China Miéville (034549752X). At first I had trouble suspending disbelief on the premise, but the book was so well written that the suspension happened anyway. How? The author stuck to the premise perfectly, creating a perfectly self-consistant world. I was somewhat upset that even though most of the mysteries of the book were resolved in the final act, the wierd history was never really explained.

[cover]When I was looking for downloadable audiobooks from the public library, I checked out the audio version of The Great Gatsby by F. Scott Fitzgerald (0743273567), and read by Alexander Scourby (1602834725). I'm glad I finally got around to this one; I keep telling myself that I'll read all the classics of American literature, but I never did, until I got started on the idea of listening to audiobooks while bicycling.

Hal Canary | Books | 2010-09-25 05:40:27 UTC
Permanent Link | Comments Off

Update comparison

No comparison. APT (the Advanced Packaging Tool) beats Windows Update by a million to one. I had hoped that Windows Seven would improve things, but no such luck.

APT: You run this script, once, in the background and it does everything.

#!/bin/sh
sudo apt-get update
sudo apt-get -y dist-upgrade
sudo apt-get clean

Windows Update: You run this program—

%windir%\system32\wuapp.exe

—then click on some things, then it downloads and installs, then it asks you to reboot. Then while it shuts down it does things, then while it boots up it does things, then you have to repeat the same process THREE TIMES to get all the updates!


Also, here’s my full script:

#!/bin/sh
# ${HOME}/bin/agu -- "Apt, Get Updates"
# Written by Hal Canary
# Dedicated to the public domain.
#
# You may want to add the following lines to the /etc/sudoers file:
#
##  %admin ALL=NOPASSWD: /usr/bin/nice /usr/bin/apt-get --yes update
##  %admin ALL=NOPASSWD: /usr/bin/nice /usr/bin/apt-get --yes dist-upgrade
##  %admin ALL=NOPASSWD: /usr/bin/nice /usr/bin/apt-get autoremove
##  %admin ALL=NOPASSWD: /usr/bin/nice /usr/bin/apt-get clean
##  %admin ALL=NOPASSWD: /usr/bin/nice /usr/bin/dpkg --configure --pending
#
echo "Running apt-get update, dist-upgrade, autoremove, clean"
echo ""
sudo /usr/bin/nice /usr/bin/apt-get --yes update && \
sudo /usr/bin/nice /usr/bin/apt-get --yes dist-upgrade
sudo /usr/bin/nice /usr/bin/apt-get autoremove
sudo /usr/bin/nice /usr/bin/apt-get clean
sudo /usr/bin/nice /usr/bin/dpkg --configure --pending

Hal Canary | Computers & Code | 2010-09-04 13:43:34 UTC
Permanent Link | Comments Off

Redesign of the Mexican flag

Here’s my candidate for a redesign of the Mexican flag.

Old:

New:

Hal Canary | Art | 2010-08-28 15:40:53 UTC
Permanent Link | Comments Off

published

Hal Canary | Life, Mathematics | 2010-08-12 09:42:12 UTC
Permanent Link | Comments Off

gravatar

<!-- Easy Gravatar implementation for
     WordPress comment page: -->
<?php
$gravlink = "http://www.gravatar.com/avatar/";
$gravlink .= md5(strtolower(trim(get_comment_author_email())));
$gravlink .= "?d=".urlencode("http://halcanary.org/images/q80.png");
echo $gravlink; ?>

Hal Canary | Computers & Code | 2010-07-17 09:25:23 UTC
Permanent Link | Comments Off

gnuplot question

Here’s your basic LaTeX document:

%% FILE: basic.tex
\documentclass[letterpaper,12pt]{article}
\begin{document}
\input{graph}
\end{document}

The file graph.tex is generated using Gnuplot like this:

#!/usr/bin/gnuplot
## FILE: graph.gnuplot
set xrange [-3:3]
set yrange [0:.42]
set ytics nomirror autofreq 0, .1
set terminal latex size 3,1.5
set output 'graph.tex'
f(x) = .39894228040143267794 * exp(-0.5 * (x ** 2))
set style line 1 linecolor rgb "black" linewidth 1
plot f(x) ls 1 notitle

Here’s the execution:

$ gnuplot graph.gnuplot
$ pdflatex basic.tex > /dev/null
$ evince basic.pdf &

This makes a really professional-looking graph I can put in a document.

[]

Now here’s what I want to see:

[]

How do I do this with Gnuplot?

Hal Canary | Computers & Code | 2010-07-16 22:10:14 UTC
Permanent Link | 2 Comments

filling an ebook reader

This week, I finally broke down and bought an ebook reader — B&N’s $150 WiFi Nook (ISBN 9781400532629). It’s a beautiful little device.

I got the Jonathan Adler Punctuation Cover (978161560062) since it’s both very sturdy and cheaper than most.

I’ve already side-loaded 90 free books onto the device. These books have come from several places. In no particular order:

• The Lee County Public Library lets you borrow ebooks via Adobe Digital Editions (ADE) software. You can use ADE to side-load ebooks onto a nook.

Project Gutenberg — the first place to go for books from the public domain. All of their books are now availible in ePub versions.

Google Books, Some of the scans availible are in the public domain, and are therefore downloadable. Generally, the Gutenberug editions are a higher quality than the Google versions, since The Gutenberg tries to be an ideal textual copy of the book while Google tries to be a good representation a particular physical book.

• Many of the works of Cory Doctorow are availible as ePubs on his website, Craphound. I especially recommend Makers and Little Brother.

The Baen Free Library — All copyrighted works which you may read for free, and all are availible as ePubs.

The Baen CD Mirror — These files are also copyrighted but free to redistribute. The newer CDs have ePub files on them. The older CDs do not, but you can use a program like Calibre to covert file formats.

Places to buy eBooks:

http://bn.com/ebooks — of course. Also check the Unbound Blog every friday for the name of a free book that can be added to your B&N library that week. [Update. Here, too: http://bn.com/freelibrary]

Webscription — A store that sells unencombered ebooks, all of which are availible in ePub format. The prices aren’t bad at all.

Hal Canary | Books, Computers & Code | 2010-06-27 14:39:03 UTC
Permanent Link | Comments Off

girdle

Six days ago I woke up with a horrible back pain. I must have strained it at work, and I think those magazine recycling boxes are to blame. After taking it easy over the weekend I felt much better, but work exacerbates the pain.

After I let my boss know that my back was still hurting me, she pointed out that we had some lumbar support belts hidden away in the office. So I started using one and found that it helped me put less strain on the injured part of my back. But I look like a dork.

Hal Canary | Life | 2010-06-10 07:04:12 UTC
Permanent Link | Comments Off

simple mergesort

Even though I’ve studied this algorithm a couple of times, I’ve never had to implement it before. So I assigned it to myself.

/** should have a time-complecity of O(N×log(N))
    and a space-compelcity of O(N) **/
void mergesort(int N, int array[]) {
  int k; // k is the block size.
  int x; //x is which block we are at.
  int i,j; //indices in old[]
  int p; // index in new[]
  int ilimit,jlimit; //end of blocks.
  int *hold = malloc(sizeof(hold) * N);
  if (hold == NULL) {
    fprintf(stderr,"malloc failed\n");
    exit(2);
  }
  int *new = hold;
  int *old = array;
  int *tmp;
  for (k = 1; k < N; k *= 2) {
    p = 0;
    for (x = 0; x < N; x += (2*k)) {
      i = x;
      ilimit = i + k;
      j = ilimit;
      if (ilimit >= N) {
	while (i < N)
	  new[p++] = old[i++];
 	break; //out of for-loop
      }
      jlimit = j + k;
      if (jlimit >= N)
	jlimit = N;
      while (1) {
	if (old[i] < old[j]) {
	  new[p++] = old[i++];
	  if (i == ilimit) {
	    while (j < jlimit)
	      new[p++] = old[j++];
	    break; //out of while-loop
	  }
	} else {
	  new[p++] = old[j++];
	  if (j == jlimit) {
	    while (i < ilimit)
	      new[p++] = old[i++];
	    break; //out of while-loop
	  }
	}
      } // End while loop.
    } // End inner for loop.
    tmp = old; old = new; new = tmp;
  }// End outer for loop.
  if (old != array)
    for (i = 0; i < N; i++)
      array[i] = old[i];
  free(hold);
  return;
}

Next step is to translate to Java and use .compareTo() with arrays of references:

  public static void mergeSort(Comparable array[]) {
    int N = array.length;
    int k; // k is the block size.
    int x; // x is which block we are at.
    int i,j; //indices in old[]
    int p; // index in new[]
    int ilimit,jlimit; // end of blocks.
    Comparable hold [] = new Comparable [N];
    Comparable neww [] = hold;
    Comparable old [] = array;
    Comparable tmp [];
    for (k = 1; k < N; k *= 2) {
      p = 0;
      for (x = 0; x < N; x += (2*k)) {
        i = x;
        ilimit = i + k;
        j = ilimit;
        if (ilimit >= N) {
          while (i < N)
            neww[p++] = old[i++];
          break; //out of for-loop
        }
        jlimit = j + k;
        if (jlimit >= N)
          jlimit = N;
        while (true) {
          if (old[i].compareTo(old[j]) < 0) {
            neww[p++] = old[i++];
            if (i == ilimit) {
              while (j < jlimit)
                neww[p++] = old[j++];
              break; //out of while-loop
            }
          } else {
            neww[p++] = old[j++];
            if (j == jlimit) {
              while (i < ilimit)
                neww[p++] = old[i++];
              break; //out of while-loop
            }
          }
        } // End while loop.
      } // End inner for loop.
      tmp = old; old = neww; neww = tmp;
    }// End outer for loop.
    if (old != array)
      for (i = 0; i < N; i++)
        array[i] = old[i];
  }

Hal Canary | Computer Science, Computers & Code | 2010-05-08 07:55:23 UTC
Permanent Link | Comments Off

« Previous Entries | Next Entries »

Copyright 1997-2012 by Hal Canary.
mailto: halcanary at gmail dot com
http://halcanary.org