Archive for the ‘utilities’ Category

Culinary Carma

Thursday, February 26th, 2009

Admire The Minimalist Mark Bittman, for the range and stripped bare minimalism of the recipes, for the super-comic videopods with their ever evolving titles sequence. I was to feature him in my links list and found — surprise surprise — he had stolen one of my recipes (where “stolen” means “o my god, he made a video of that, I do it all the time!”). Now I’m not saying it’s the wheatberries & scallions one (except that I go with oatmeal), because you’ll figure what I have for brisk breakfast on quick days when I’m all thumping energetic.

A part of his charm is the city kid in a kitchen simplicity of the recipes, and the gritty this is so good I can’t mess up even if I try attitude. Beyond that I have no idea why his podcasts interest me more than movie trailers. (Speaking of trailers, who’s this guy doing the gruffy voiceover in *all* of them? — That guy deserves the mallet — I’m so sick of him, good movies are good in spite of him, and movies that avoid him are good by default.)

Breakfast
* Oatmeal, onions, salt, water
* Bagel, creamcheese, bellpepper, mushrooms
* Oatmeal, frozen fruit, munkha & nuts, yogurt/milk

Recipes
* Zuke & Bellpepper
* Zuke & muchroom pasta
* Soy & wheat flour pudding/rice pudding

Background Brightness

Saturday, October 11th, 2008

Problem: I use windowmaker and think that the brightness setting in bloatier window managers are a Feature I Want ™.
Solution: Change gamma of the picture before setting it with wmsetbg. And to use goog cache as my backup Tool of Choice ™, the nifty script that does little but does it well ™ is here, lol.

wmsetbgbright.sh


#!/bin/bash -x
usage () {
        echo ${0} <bgfile> [gamma] [wmsetbg options];
}

BGDIR=${HOME}/GNUstep/Library/WindowMaker/Backgrounds
if [ ${#} -lt 1 ] ; then
        usage ${0}; exit;
else
        IMG=${1}
        GAMMA=${2}
        OPTIONS=${@:3}
fi

IMGDIR=`dirname ${IMG}`
IMG=`basename ${IMG}`

convert -modulate ${GAMMA} ${IMGDIR}/${IMG} ${BGDIR}/wm-${IMG}
wmsetbg ${OPTIONS} ${BGDIR}/wm-${IMG}

STFT and ISTFT

Wednesday, September 17th, 2008

Problem: I need to invert a spectrogram to listen to the signal. And I want to do it the best way possible.

Solution: It isn’t all that sophisticated. Here’s a limited implementation of Yang’s ICASSP 2008 solution; which is — surprise surprise — quite nearly the same as the ubiquitous heuristic overlap and add istft.

It’s limited in the following ways:

  • The least-squares solution is not implemented. This means that LS solution is available only for regularly spaced frequency bands since in that case LS solution reduces to p=2 solution.
  • MATLAB fft/ifft routines are used; and they take care of the P matrix (excess zeros to round to powers of 2).
  • The matrix algebra is not exploited — this is a quick and dirty test run.

(more…)

Get PRAAT Pitch into MATLAB/Python

Thursday, August 7th, 2008

Problem: I want to compare my pitch extraction algorithm to PRAAT’s

Briefly: Write a praat script to extract script and dump into a text file. Eat up into your favorite environment.

Solution:
The following get_praat_pitch.m calls the extract_pitch.praat script.


function praatpitch=get_praat_pitch(snd, fs)

% TODO hardcoded location of praat
        fprintf('WARNING get_praat_pitch: Hardcoded location of praat and extract_pitch.praatn');
        global MSOROOTDIR
        SNDDIR=[MSOROOTDIR, 'sep', filesep];
        FILENM=['praat-tmp'];
        FULLFILENM=[SNDDIR, FILENM, '.wav'];
        wavwrite(snd, fs, FULLFILENM);

        if(ispc()),
                PRAATCOMM=['"', MSOROOTDIR, 'extraneous/praatcon-win', '"'];
        elseif(isunix()),
                PRAATCOMM=[MSOROOTDIR, 'extraneous/praat'];
        end;

        praatcommand=[PRAATCOMM,' "',MSOROOTDIR,...
                'helpers/extract_pitch.praat" ',...
                FILENM, '.wav', ' ', FILENM, '.Pitch ', SNDDIR];

        retval=system(praatcommand);
        delete(FULLFILENM);
        if(retval==0),
                fprintf('Got pitch from praat!n');
                praatpitch=load([SNDDIR, FILENM, '.Pitch']);
                fprintf('Pitches read...n');
        else,
                fprintf('Praat error occurred.n');
                input('Press any key to continue...');
        end;

extract_pitch.praat

# Extract pitch from file (first parameter) and write it out to a text file
# (second parameter).

form PitchExtractor
        sentence sound_file_name
        sentence pitch_file_name
        sentence Directory
endform

echo Reading from 'Directory$''sound_file_name$'
Read from file... 'Directory$''sound_file_name$'
To Pitch... 0.0 75 600

pitchID = selected("Pitch");
Down to PitchTier
pitchtierID = selected("PitchTier")
num_points = Get number of points

filedelete 'Directory$''pitch_file_name$'
echo Writing to 'Directory$''pitch_file_name$'
for i to num_points
        time = Get time from index... i
        hertz = Get value at index... i
        fileappend "'Directory$''pitch_file_name$'" 'time' 'hertz' 'newline$'
endfor

LaTeX/bash Calendar

Monday, February 18th, 2008

Problem How do I create a manageable calendar that:

  • Is on paper, because I’m cool
  • Has my weekly schedule, so I don’t rewrite my schedule every week
  • Has customizable daily schedule
  • Has space for general todo lists
  • Has space for regular todo lists, e.g. research and course commitments
  • Is cool

Weekly calendar jpeg preview

Briefly LaTeX/Python Planner post makes it easier to generate this. Go read it instead. Use bash to generate the dates; and use latex command definitions to insert weekly schedule. A list of reminders (TODO list with due dates) is maintained at the beginning of the file; when the date appears on the planner, the task appears on the calendar. Monthly schedules don’t recur — each monthly due-date is added iindividually in the TODO list. A three-month calendar a la published calendars is printed on every planning page.

The P/K/M/N are symbols for my commitments B-) and, needless to say, are customizable.

(more…)

Thinkpad R60 Modem Disconnect on Call

Thursday, December 27th, 2007

Problem Linux box got a winmodem (Conexant HSF) and needs to

  • dialup
  • disconnect on call

Briefly Modem drivers from de11 and a bash script to disconnect
(more…)

PDF File jpeg Preview

Thursday, December 13th, 2007

Problem I have a pdf file, and I want to show it off on the interwebb. How can I get a good jpg thumbnail?
Solutionpdftoppm (from xpdf) -> pnmtojpeg (from Netpbm) -> convert (from ImageMagick) to scale

Try pdfcover.sh

[[code]]DQojIS9iaW4vYmFzaA0KDQppZiBbWyAkIyAtbHQgMSBdXTsgdGhlbiBlY2hvIHVzYWdlOiAkMCBwZGZmaWxlbmFtZSA7IGV4aXQ7IGZpDQoNClNDQUxFPTQwDQpUTVBQUE09L3RtcC90bXAtcHBtDQpQUkVGSVg9YGJhc2VuYW1lICR7MX0gLnBkZmANClBSRUZJWD1gYmFzZW5hbWUgJHtQUkVGSVh9IC5QREZgDQpwZGZ0b3BwbSAtZiAxIC1sIDEgLXIgMTAwICR7MX0gJHtUTVBQUE19DQpwbm10b2pwZWcgYGxzICR7VE1QUFBNfS0qWzBdMS5wcG1gID4gJHtUTVBQUE19LmpwZw0KY29udmVydCAtc2NhbGUgJHtTQ0FMRX0lICR7VE1QUFBNfS5qcGcgJHtQUkVGSVh9LXRodW1iLmpwZw0K[[/code]]

LSAT Timer

Tuesday, December 4th, 2007

Problem I need a full-featured timer for practice, but I don’t want to get a hardware one because it’s not allowed in the exam.

Solution Program it in Java quick-n-dirty. Here are four timers, one for each section, and it’ll even set your pace. For each section, put in the time limit in the first box, and number of questions you want to attempt in the second box, and go!
(more…)

random terminal

Monday, November 12th, 2007

Problem I got a funky background, but I need a terminal that lets me work while letting it show. Preferably minimal.

Briefly A bash script, requiring: aterm (compiled with transparency and shading), showrgb (installed with X?)

Solution A bash script “ranterm.sh” gets me a terminal which can be translucent/opaque with a high contrast pair of foreground and background colors which are different each time a new terminal is opened.
(more…)

G009le Atlas

Wednesday, November 7th, 2007

Problem: You want a printed atlas, as free as it gets

Briefly: Get it from G009le maps, using an unethical (i.e. wastes time, effort and isn’t even elegant) hack, but the code is here. Requires: bash, firefox, g009le map API, latex/pdflatex with pdfpages.sty (if pdf desired), pdfprinter (if pdf desired), headfile.html, tailfile.html

Solution:

  • Figure coordinates of top left and bottom right
  • Install g009le maps api
  • Write script to generate requests for a pageful at a time (determine appropriate scale)
  • Title the page by the map index (row index number and column index alphabet)
  • Print each page with pdf printer
  • Print cover map with top left and bottom right pageful
  • Overlay with a grid in gimp/illy
  • File them all

(more…)