Governance by those who do the work.

Sunday, December 25, 2011

"Mathematical Marbling" to appear in IEEE Computer Graphics and Applications


A paper on marbling, which I wrote with Shufang Lu, Xiaogang Jin, Hanli Zhao, and Xiaoyang Mao has been accepted for publication:

Lu, S.; Jaffer, A.; Jin, X.; Zhao, H.; Mao, X.; ,
"Mathematical Marbling,"
Computer Graphics and Applications, IEEE , vol.PP, no.99, pp.1, 0
doi: 10.1109/MCG.2011.51
http://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=5887299&isnumber=5185484

Wednesday, November 30, 2011

The Colors of Heat

Hot objects can glow visibly. Heat Colors for Blacksmiths shows images of mild steel at various temperatures.

At a given temperature, a blackbody will emit more light than any other surface. The table below shows the colors of a blackbody at exponentially decreasing absolute temperate. The left column of colors is how they would naturally appear. The top color is a sky blue, which has a color temperature of approximately 10000 K.

In the right column, each temperature's chromaticity is scaled proportionally to its Celsius temperature.

Read more at http://people.csail.mit.edu/jaffer/Color/Heat.

Saturday, August 20, 2011

Script to Monitor Websites

As the maintainer of several websites, it is annoying to learn that a website has been down for hours or days only by email from a frustrated member of the browsing public.

What is needed is an automated method to periodically check websites and notify me when their status changes (up or down). This method must involve a computer other than the one hosting the website, because a stopped computer can't notify me of anything.

I have created a Unix script "wstatus" to be run periodically by crontab. Its first argument is a URL to retrieve from the website; the second is the email address to send notifications to. The wstatus script puts small files in a $(HOME)/.status/ directory (.status in your home directory).

The crontab entry:
*/10 * * * * $HOME/bin/wstatus http://voluntocracy.org/server-status.txt jaffer@localhost
reads "server-status.txt" from "http://voluntocracy.org" every 10 minutes. If the content or error retrieved differs from the last, then the first line of that content or error is emailed to me (locally). "server-status.txt" contains just the line "voluntocracy.org is up!".

I wonder how often my ISP changes my IP-address:
25 * * * * $HOME/bin/wstatus http://automation.whatismyip.com/n09230945.asp jaffer@localhost
checkes once an hour (at 25 minutes past). Of course, if I move my computer to another network, I get an email notifying me of the change. If you use automation.whatismyip.com, be sure to observe their rule: We ask that automated files hit our site no more then once every five minutes or once every 300 seconds.

The early version of wstatus consisted of just the black code below. But it occasionally sent two email notices for a single change of status when the cron period was small. I believe this happens because cron starts its child processes with less (numerically higher) priority than users have; and these processes queue up while higher priority jobs are running.

The code in red was added to dismiss a wstatus process if another is already running. Among the basic Unix file commands, only rm (ReMove file) returns a status allowing it to be used as a mutex. Thus, to grab the mutex the script tries to remove a file with the extension ".idl". If it succeeded, the script continues to run; otherwise it exits immediately.

This will work except if the script is interrupted and does not restore the ".idl" file. To handle this case, the line in green was added to restore the ".idl" file when the script exits because it doesn't grab the mutex. Whereas the code without the green line will generate only one email per change no matter how many wstatus processes are running simultaneously, with the green line, only suppression of the second wstatus process is guaranteed. If it is the case that double processes occur more frequently than higher multiples, then this approach is reasonable.

wstatus
#! /bin/sh
# Copyright (C) 2011 Aubrey Jaffer
if test -z "$1"; then
    echo "$0: Missing URL (first) argument" 1>&2
    exit 1
elif test -z "$2"; then
    echo "$0: Missing email (second) argument" 1>&2
    exit 1
fi
host=`echo $1 | sed 's%.*//%%' | sed 's%/.*%%'`
sfile=${HOME}/.status/${host}-status.txt
mfile=${HOME}/.status/${host}-status.idl
mkdir -p ${HOME}/.status/
if test -f ${sfile}; then
    if ! rm ${mfile} > /dev/null 2>&1; then
        touch ${mfile}
        exit 0
    fi
    cp -f ${sfile} ${sfile}~
fi
if ! wget -q -T 30 -O- $1 > ${sfile} 2>&1; then
    echo could not reach \"`echo $1 | sed 's%.*//%%'`\" > ${sfile}
fi
if ! (test -f ${sfile}~ && diff -q ${sfile}~ ${sfile} >/dev/null 2>&1;) then
    mail -s "`head -1 ${sfile}`" $2 < ${sfile}
fi
touch ${mfile}

The use of rm as a mutex is rare, perhaps novel. I have not tested whether rm is actually atomic; but even if it isn't, it reduces by an order of magnitude the window of opportunity for repeated messages from wstatus.

Wednesday, July 6, 2011

Recurrence for Multidimensional Self-Similar Functions


Staring at this diagram of the Peano space-filling curve inspired the recurrence formula, something I have been seeking for a couple of years. It remains to derive the inverse function and generalize the recurrence to produce Hilbert space-filling functions as well.

If the unit cell is a Hamiltonian Path, the resulting function is a space-filling curve. Functions resulting from unit cells which don't connect all their nodes are still self-similar (fractal).


Once the formula was discovered, creating a better space-filling curve, one which is nearly isotropic, is not difficult. This may not be novel in 2 dimensions, but the higher dimensional varieties are.

Sunday, June 12, 2011

Free Convection from Rectangular Plate

Have completed a milestone in theory of convection  (corrected 2012-01-08) http://people.csail.mit.edu/jaffer/SimRoof/Convection/:



Free convection correlations for inclined rectangular plates involve characteristic-lengths LHLW, and L* (area divided by perimeter). Each correlation is computed using its own characteristic-length. Flows are then compared and selected as convective surface-conductances (h).

Proposed is the complete free convective surface conductance for one side of a flat LH by LW rectangular isothermal plate inclined θ around the level edge which is LW long.


L* =LHLW / (2 (LH+LW))
R =min(LHLW)/2
Pr =cp⋅μ/k
Ra(L) =T|⋅g⋅ρ2cpL3 / (T⋅μ⋅k)
HHT*(Ra*) ={0.65 + 0.36 Ra*1/6}21≤Ra*≤1.5×109θ=−90°
T9.3(Ra) ={.825 +.387 Ra1/6

[1+(.492/Pr)9/16]8/27
}21≤Ra≤1012θ=0°
Nu45(Ra) =0.544 Ra1/5

[1+(0.785/Pr)3/5]1/3
θ=+90°

h k⋅max(Nu45(Ra(R))

R
,T9.3(Ra(LH) cos θ)

LH
)0°≤θ≤90°UCT3
h = k⋅max(HHT*(Ra(L*) sin(−θ))

L*
,T9.3(Ra(LH) cos θ)

LH
)−90°≤θ≤0°UHT3



Sunday, May 8, 2011

Excess Fructose Content of Foods


Fructose and glucose are simultaneously absorbed in equal amounts by the intestines. Excess fructose is absorbed by a different mechanism. In individuals with fructose malabsorption, excess fructose remains in the intestines where fermentation causes gastric distress.

Glucose requires insulin to be absorbed from the bloodstream, while fructose does not. There has been vigorous debate as to whether individuals with Diabetes mellitus (a metabolic disease characterized by high blood sugar) should consume or avoid fructose.

In any case, it would be interesting to have a chart showing the spectrum of fructose-heavy to glucose-heavy foods.

The USDA National Nutrient Database gives nutrient values for 7636 foods; but only 1134 of them have fructose and glucose values.

This database was used to create a table of the 1134 foods having fructose and glucose values. The foods are listed in order of decreasing amount of excess fructose.

The database doesn't give data for High Fructose Corn Syrup. Used mostly in soft drinks, HFCS 55 is composed of approximately 55% fructose and 42% glucose. This would give it a 13% excess of fructose, comparable to the 15% and 20% fructose excesses of lemonade powders near the top of the chart.

When dried, the Agave americana plant pictured above has the most excess fructose (39%) of the foods in the database.

Wednesday, March 23, 2011

Design Pattern for Multi-Format Extract-Transform-Load

Presented is a design-pattern for single-pass extract-transform-load (ETL) processing of line-oriented files which automatically detects the line format, but which does not require any domain-specific code devoted to deciding the format of the input file.


The Color-Name Dictionaries web-page analyzes and compares more than 3 dozen color dictionaries from book and online sources. The dictionary sources are in 19 (plain-text and HTML) formats. The largest is the "NBS/ISCC Dictionary of Color Names" with 5411 color names; and there are several with over 1300 names. Some color dictionaries are updated or added every year.

The dictionary files share these characteristics:

  • Each color-name entry appears on a single line.
  • All the intended color-name entries in a file have the same
    format.
  • A Preamble and comments may be mixed with the color-name
    entries.

There are format errors, inconsistencies, duplicates, and collisions (where a color name is repeated with different color coordinates) in some of the files. In spite of this, file->color-dictionary and url->color-dictionary in the SLIB color-database module are able to automatically detect the format and extract and clean the data and insert it into relational tables. This is accomplished in an easy-to-extend fashion using closures. This code is written in Scheme, but the same idea should work in any language with closures.

The main ETL loop has port bound to an input-stream reading from the dictionary source file:

        (do ((line (read-line port) (read-line port)))
            ((eof-object? line)
             (display "Inserted ") (display *idx*) (display " colors") (newline)
             *rcs-header*)
          (let ((colin (parse-rgb-line line)))
            (cond ((equal? "" line))
                  ((not colin) (write-line line))
                  ((numbered-gray? (cadr colin)))
                  (else
                   (for-each
                    (lambda (name)
                      (let ((oclin (color-table:row-retrieve name)))
                        (cond
                         ((and oclin (equal? (car colin) (cadr oclin))))
                         ((not oclin)
                          (set! *idx* (+ 1 *idx*))
                          (color-table:row-insert
                           (list name (car colin) *idx*)))
                         (else (slib:warn 'collision colin oclin)))))
                    (cdr colin))))))

The do loop iterates over the lines read from port, calling parse-rgb-line on each. The call to parse-rgb-line returns false unless the line was parsed as a valid color-dictionary line. If it returns false, line is printed to the log. If it returns a data row, each name in the row is checked for an existing table entry; if it matches, nothing is done; if it doesn't match, a warning is generated; if there is no entry, then it is created.

    (define (parse-rgb-line line)
     ...
        (for-each
         (lambda (method)
           (or ans
               (let ((try (method line)))
                 (cond (try (set! ans try)
                            (display "**** Using method ")
                            (display method-id) (newline)
                            (set! parse-rgb-line method))))))
         (list
          (lambda (line) ...)
          (lambda (line) ...)
          ...
         )))

The construction of parse-rgb-line is a bit unusual. The for-each procedure calls its first argument (lambda (method) ...) with each function (lambda (line) ...) in the list which is its second argument. The first-argument procedure returns immediately if ans is not false. Otherwise, it calls method with the input line. If method returns a data row, then ans is set to it, and no other methods will be called. The test of ans can be eliminated through the use of an escape continuation.

Most importantly, when method returns a data row, it sets parse-rgb-line to method, so that after the current invocation of parse-rgb-line returns (or escapes), the method which worked will be called directly. Thus parse-rgb-line is a self-replacing function!

If parse-rgb-line is defined internally to another procedure, the containing procedure can be reentrant (as SLIB is).

Here is a typical (lambda (line) ...) function:

          (lambda (line)
            (case (sscanf line " %24[a-zA-Z0-9_ ] %d %d %d %e %e %e %s"
                          name r g b ri gi bi junk)
              ((7)
               (set! method-id 'm7)
               (list (check-match line
                                  (color:sRGB r g b)
                                  (floats->rgb ri gi bi))
                     (color-name:canonicalize name)))
              (else #f)))

sscanf is called with 8 variables, but this function will succeed only if exactly 7 are scanned; this is to detect extra stuff on the line. method-id is for reporting which method succeeded. check-match is called to warn if the RGB integer coordinates don't match the floating-point color coordinates.

If a format needs to ignore junk at the end of lines, then it should come after any functions (in the list) whose formats it might spoof. This way, the more specific format takes precedence.

Conclusion

A design-pattern employing a self-replacing function provides single-pass ETL processing of line-oriented files which automatically detects the line format.

Tuesday, March 15, 2011

Names for Hammer Dulcimer in English Books 1800-2000


Google Labs has a nice webapp for creating graphs of word- and phrase-frequency versus time for the millions of books they have scanned.

Here is a graph of the frequency of various names for hammer-dulcimer from 1800 to the present. Click on the graph to try out the webapp for your own ideas. One caution; it is case-sensitive.

Friday, March 4, 2011

YouTube Hangs my Ubuntu-10.04 HP-dv7

At 7:17pm on Mar 2 2011 Ubuntu-10.04.1 running on an HP dv7 (x86_64) ceased to be able to play YouTube videos. Both Chromium and FireFox get wedged. Hulu and other Flash services play without problems. But after a couple of seconds of playing a YouTube video, the screen goes black with white streaks. /var/log/kern.log goes into loop:
Mar  2 19:17:37 dv7 kernel: [ 8232.470145] [drm:radeon_fence_wait] *ERROR* fence(ffff8800b8044980:0x000097BA) 510ms timeout going to reset GPU
Mar  2 19:17:37 dv7 kernel: [ 8232.470157] radeon 0000:01:00.0: GPU softreset 
Mar  2 19:17:37 dv7 kernel: [ 8232.470164] radeon 0000:01:00.0:   R_008010_GRBM_STATUS=0xE53024A4
Mar  2 19:17:37 dv7 kernel: [ 8232.470171] radeon 0000:01:00.0:   R_008014_GRBM_STATUS2=0x00110002
Mar  2 19:17:37 dv7 kernel: [ 8232.470177] radeon 0000:01:00.0:   R_000E50_SRBM_STATUS=0x200000C0
Mar  2 19:17:37 dv7 kernel: [ 8232.470192] radeon 0000:01:00.0:   R_008020_GRBM_SOFT_RESET=0x00007FEE
Mar  2 19:17:37 dv7 kernel: [ 8232.470249] radeon 0000:01:00.0: R_008020_GRBM_SOFT_RESET=0x00000001
Mar  2 19:17:37 dv7 kernel: [ 8232.470314] radeon 0000:01:00.0:   R_000E60_SRBM_SOFT_RESET=0x00000402
Mar  2 19:17:37 dv7 kernel: [ 8232.519205] radeon 0000:01:00.0:   R_008010_GRBM_STATUS=0x00003028
Mar  2 19:17:37 dv7 kernel: [ 8232.519211] radeon 0000:01:00.0:   R_008014_GRBM_STATUS2=0x00000002
Mar  2 19:17:37 dv7 kernel: [ 8232.519217] radeon 0000:01:00.0:   R_000E50_SRBM_STATUS=0x200000C0
Mar  2 19:17:37 dv7 kernel: [ 8232.523318] [drm:radeon_fence_wait] *ERROR* fence(ffff8800b8044980:0x000097BA) 570ms timeout
Mar  2 19:17:37 dv7 kernel: [ 8232.523320] [drm:radeon_fence_wait] *ERROR* last signaled fence(0x000097BA)
Mar  2 19:17:39 dv7 kernel: [ 8235.040219] [drm:radeon_fence_wait] *ERROR* fence(ffff8800c4203ac0:0x000097C3) 510ms timeout going to reset GPU
Mar  2 19:17:39 dv7 kernel: [ 8235.040231] radeon 0000:01:00.0: GPU softreset 
Mar  2 19:17:39 dv7 kernel: [ 8235.040238] radeon 0000:01:00.0:   R_008010_GRBM_STATUS=0xA0003028
Mar  2 19:17:39 dv7 kernel: [ 8235.040245] radeon 0000:01:00.0:   R_008014_GRBM_STATUS2=0x00000002
Mar  2 19:17:39 dv7 kernel: [ 8235.040251] radeon 0000:01:00.0:   R_000E50_SRBM_STATUS=0x200000C0
Mar  2 19:17:39 dv7 kernel: [ 8235.040263] radeon 0000:01:00.0:   R_008020_GRBM_SOFT_RESET=0x00007FEE
Mar  2 19:17:39 dv7 kernel: [ 8235.040319] radeon 0000:01:00.0: R_008020_GRBM_SOFT_RESET=0x00000001
Mar  2 19:17:39 dv7 kernel: [ 8235.040384] radeon 0000:01:00.0:   R_000E60_SRBM_SOFT_RESET=0x00000402
Mar  2 19:17:39 dv7 kernel: [ 8235.089275] radeon 0000:01:00.0:   R_008010_GRBM_STATUS=0x00003028
Mar  2 19:17:39 dv7 kernel: [ 8235.089280] radeon 0000:01:00.0:   R_008014_GRBM_STATUS2=0x00000002
Mar  2 19:17:39 dv7 kernel: [ 8235.089286] radeon 0000:01:00.0:   R_000E50_SRBM_STATUS=0x200000C0
Mar  2 19:17:39 dv7 kernel: [ 8235.091966] [drm:radeon_fence_wait] *ERROR* fence(ffff8800c4203ac0:0x000097C3) 570ms timeout
Mar  2 19:17:39 dv7 kernel: [ 8235.091968] [drm:radeon_fence_wait] *ERROR* last signaled fence(0x000097C3)
Mar  2 19:17:42 dv7 kernel: [ 8237.611578] [drm:radeon_fence_wait] *ERROR* fence(ffff8800c4203f00:0x000097CA) 510ms timeout going to reset GPU
Mar  2 19:17:42 dv7 kernel: [ 8237.611591] radeon 0000:01:00.0: GPU softreset 
Reinstalling Flash didn't help. Eight hours earlier, I had updated to 2.6.32-29-generic; but booting with the previous kernel version doesn't help. Installing the "linux-firmware-nonfree" drivers made no difference.
Start-Date: 2011-03-02  10:42:14
Install: linux-headers-2.6.32-29-generic (2.6.32-29.58), linux-headers-2.6.32-29 (2.6.32-29.58), linux-image-2.6.32-29-generic (2.6.32-29.58)
Upgrade: linux-generic (2.6.32.28.32, 2.6.32.29.35), linux-headers-generic (2.6.32.28.32, 2.6.32.29.35), linux-image-generic (2.6.32.28.32, 2.6.32.29.35), linux-libc-dev (2.6.32-28.55, 2.6.32-29.58)
End-Date: 2011-03-02  10:43:29
What has changed to cause this?
Others with the same problem are posting to
http://ubuntuforums.org/showthread.php?t=1699550

Fix Pink / Red YouTube Videos Bug Using Flash 10.2 In Ubuntu
"Possible fix 3" solved the problem by disabling "hardware acceleration" in Flash. So who's bug is this? Is the bug in Flash 10.2 or something it calls? In any case, plugins shouldn't be able to crash X11. So X11 is behaving badly; but the errors show up in "kern.log"; does the kernel deserve some of the blame?

Wednesday, February 2, 2011

Asperger-Syndrome Software Job Index

Asperger syndrome is an autism spectrum disorder that is characterized by significant difficulties in social interaction, along with restricted and repetitive patterns of behavior and interests.

In the last few years it seems like more and more job postings for engineers are including requirements for better than average communication or interpersonal skills. Back when I was an undergraduate student, engineering was a good career choice for nerds. Apparently, no longer. Looking at Craigslist - boston software/QA/DBA/etc jobs classifieds for Wed Feb 02, 2011, 19 out of 33 postings require good communication or interpersonal skills. Several of the postings by third-party recruiters didn't have the full job description and might also require those skills. So today's Asperger-syndrome-software-job-index is 42% or less; only 42% of the job postings don't mention communication or interpersonal skills.

Software Development Engineer - (UMass, Boston Campus)
Research Programmer - (Cambridge)Strong organizational and communication skills and the ability to work with others.
SQL Database Administrator - (Cranston, RI)Good written and oral communication skills.

Good interpersonal skills.

Ability to present ideas in user-friendly language.
Software Engineer (Java) - (Downtown Boston)Excellent verbal and written communication skills. Be able to clearly communicate at both high and basic technical levels.
Data/Analytics Engineer - (Boston)
Developer in Testing - (Boston, MA)High energy level & excellent people/team member skills

Good communication ability
Director of Systems Operations - (Kendall Square, Cambridge, MA)Excellent customer service attitude, communication skills (written and verbal), and interpersonal skills.
QA Engineer - Java - (Greater Boston)
QA Engineer - (Waltham)
Microsoft Tech. Solutions Prof. - (Virtual)Excellent written and oral communication skills
Entry-level Tech Support - $60k - (Waltham, MA)Excellent communication skills
Software Engineer – .NET Development Contractor - (Cambridge, MA)Good written and oral communication skills
Sr. Software Engineer - Flex/Flash - (Rte. 495 South)
.NET Application Engineer – C# - CSS - SQL - (Boston, MA)
Want to get into the HealthCare field?? VB.NET position open! - (Braintree, MA)
Sr. Software Engineer - (Rt. 128 West)
Junior Java Developer - (Downtown Boston)Good verbal and written communication skills
iOS Developer - (Providence Rhode Island)
Are you Mark Zuckerberg without the idea? -
Hardware Quality Assurance Engineer - (North Reading)Strong communication skills and cross-functional leadership
Contract Software Developer - (Boston) imgStrong communication and collaboration skills.
Document Prod Coord. - (Wellesley)
Mid-Level Software Developer - (Boston) imgStrong communication and collaboration skills.

Strong communication and collaboration skills.[sic]
Release Engineering Manager - (Boston) imgStrong communication and collaboration skills.
Information Management Software Developer - (Cambridge, MA)Should have problem solving and research skills along with excellent written and verbal communication skills.
Senior LAMP Developer - (Lexington)Excellent communication skills
Mid-Level LAMP Developer - (Lexington)Good communication skills

Monday, January 17, 2011

New webapp to transpose tunes in ABC format.

I made a web application out of my program to transpose tunes in ABC format.
http://voluntocracy.org/Music/Transpose.html

Instrument key (Bb), interval (-3. or 1/5), or semitones (+12):
Paste an ABC tune or its URL here:
  Check square to save file, otherwise view.

Monday, January 3, 2011

Simulating Availability of Radiative Cooling


The SimRoof program I have been developing can now create graphs of the availability of radiative cooling. This "Perfect CoolRoof" graph shows that in Guam:
  • The roof will provide more than 7 W/m2 of cooling 99% of the time;
  • the roof will provide more than 22 W/m2 of cooling 90% of the time;
  • the roof will provide more than 60 W/m2 of cooling 50% of the time (the median);
  • the roof will provide more than 80 W/m2 of cooling only 10% of the time;
  • the roof will provide more than 90 W/m2 of cooling only 1% of the time.

Blog Archive