Saturday, August 23, 2008

stacktrace with gdb

file [file name of executable]
[do the action that causes the crash]

MERA 877-431-2833 scam

I had a charge to a visa card for $9ish from a company identified only as MERA 877-431-2833 TX. I hadn't used the card for a while, so that sent up flags. I did a quick search on the internet. It seems that this has happened to a bunch of people [800notes]. I've disputed the charge with my company. The only additional information I got from them is that the co is listed as a toy company from texas. Check your records.

Tuesday, August 19, 2008

Endnote and MS word 2008 mac

With tracking on, and under circumstances I have not nailed down, endnote insert citation will fail with a 'COM' error and will not update the field codes. The solution is to close word, close endnote and then reopen the document. On the next citation insert all field codes will be properly updated.

Saturday, August 16, 2008

Install package from command line

To install a package (.mpkg) from the command line use

installer -pkg XXX.mpkg -target / (or whereever else you want it installed)

you can get a list of volumes where you can install by doing

installer -pkg XXX.mpkg -volinfo

Mount dmg from command line

To mount a disk image (dmg) on mac os X from the command line use hdid

Some one has a sense of humor...

Friday, August 15, 2008

200 MB log file

And I was wondering why syslogd was hogging 100% CPU and why, at midnight bzip, of all things grabbed 100% CPU.

Wednesday, August 13, 2008

"Instruments" : Memory leak tracking on Mac

  1. Instruments is a Mac GUI tool "...for dynamically tracing and profiling Mac OS X code." Jon says Instruments uses dtrace.
  2. I wanted a tool to track memory leaks in a c++ application I wrote
  3. I find the "Extended detail" view most useful because it shows a stack trace for each memory leak which includes the function name and the source code line number. To me, this is amazing.
I did not compile the code with any DEBUG settings on.

A big "Thank you" to Jon Hendry for this one.

The Mac just got a lot more attractive for me as a development platform, not that I hadn't gotten comfortable with it already. Between the debug mode in eclipse and this tool, I'm all set.

Sunday, August 10, 2008

Emulators on mac

  1. zx81 - zxsp. Games here
  2. c64 -

Installing matplotlib 0.98.3 on mac

(See this post for a step by step list for getting python and friends set up for analysis on a mac)
  1. Get numpy 1.1 from here [sourceforge]. Use the disk image version. Mount and then double-click the package installer
  2. Get matplotlib 0.98.3 egg from here [sourceforge]. Use easy_install to install the egg. It fails, but it installs fine. Why?
UPDATE: Charlie says:

The OSX egg on SF should work fine on ppc and x86 machines on OS 10.3
and up. Unfortunately setuptools does not understand fat binaries at all
yet. For some reason it installs the egg fine, but then tries to go out and
download the source and compile it. Your idea of using the nodeps flag is a
good one. That's the situation as it stands.

Want my money back

Watched Pineapple express, want my $10.50 AND my 2hrs back, should have gone and watched the Mummy instead.

Sunday, August 3, 2008

SQL to items in a table not in another table

select id from keywords where id not in (select keyword_id from photos_keywords);

Why I love Python

I was reading "The remarkable inefficiency of word recognition" (Pelli et al. 2003) and I wanted to generate some of the stimuli they were using. In Python it took me a few hours total, starting cold using the Python Imaging Library. The code is below....
"""This contains routines to generate degraded letter stimuli"""

import Image #The PIL
import ImageDraw
import ImageFont

import numpy

def generate_letter(contrast_energy = .01, #michelson contrast energy
noise = 30.,
bg_luminance = 128.,
letter = "a",
letter_size = 400):
N = 300 #size of image in pixels

#first figure out what is the ink-area of the letter

font = ImageFont.truetype("Data/arial.ttf", letter_size)
#we copy the .ttf file to the local directory to avoid problems

im_temp ="1", (1,1), 0)
draw = ImageDraw.Draw(im_temp)
#now we can draw on this

sz = draw.textsize(letter, font=font)
#this tells us the size of the letter

im_temp ="1", sz, 0)
#this is a temporary binary image created solely for the purpose of computing
#the ink-area of the letter
draw = ImageDraw.Draw(im_temp)
#now we can draw on this
draw.text((0,0), letter, font=font, fill=1)
pix = im_temp.load()
#pix is now an addressable array of pixel values
area_in_pixels = 0.
for row in xrange(sz[0]):
for col in xrange(sz[1]):
area_in_pixels += pix[row,col]

#since contrast_energy = contrast^2 * pixel_area
contrast = (contrast_energy/area_in_pixels)**0.5
fg_luminance = bg_luminance*(1+contrast)/(1-contrast)
print area_in_pixels
print contrast
print fg_luminance

im ="L", (N,N), bg_luminance)
#im is now a NxN luminance image with luminance set to bg_luminance

draw = ImageDraw.Draw(im)
#now we can draw on this

draw.text(((N-sz[0])/2, (N-sz[1])/2), letter, font=font, fill=fg_luminance)
#this centers the letter

if noise > 0:
pix = im.load()
#pix is now an addressable array of pixel values

rd = numpy.random.normal(scale=noise, size=(N,N))
for row in xrange(N):
for col in xrange(N):
pix[row,col] += rd[row,col]

Saturday, August 2, 2008

Python Imaging Library

There is a list here of how to get distributions of the python imaging library for different OS. For mac you can the PIL from here (same place as you can get matplotlib etc).

Friday, August 1, 2008

Alternatives to latex

From a thread on slashdot:
  1. lout
  2. xetex
  3. wyneken
  4. ant

Eject disc from command line

I had an issue where I clicked the disc icon on the desktop to eject the disk, the icon disappeared but the disk did not eject. The following command will eject the disk:

drutil eject

Laptop saga III

Well, a month or two ago HP came good with their promise to replace the busted laptop [post 1, 2] and they sent over a dv2000 replacement for the old one. However, I read here (electronista) that several of their models have been affected by bad nvidia chips (this was the problem I was facing) - and the dv2000 (the replacement I got) was one of them. So.. the replacement is subject to the same problem eh? I gotta ask HP what to do...