Oct 15 2009

Defeating the Anti-Autocomplete Demons

There are demons out there. They have sent their evil henchbugs to make my life difficult. The Santa Clara library login page for some unfathomable reason doesn’t trigger Firefox’s autocomplete. No, the HTML form doesn’t specify “autocomplete=off”. As far as I can tell, it’s just that Firefox doesn’t seem to think that my library barcode is worth remembering. Which is a real bummer because it’s impossible to remember and about as sensitive as the callus on my big toe.

So I got jiggy with GreaseMonkey and made my own autofill script:

// ==UserScript==
// @name Santa Clara Library Autocomplete
// @namespace hans.fugal.net/
// @include https://sccl.santaclaraca.gov/patroninfo*
// ==/UserScript==
name = document.getElementsByName('name')[0];
code = document.getElementsByName('code')[0];
name.value = 'Fred Flintstone';
code.value = 'Your impossible-to-remember-barcode goes here';

no comments   |  tags: autocomplete, firefox, greasemonkey, javascript


Oct 12 2009

Graph-paper Weight Loss

I think I’ve posted on this before, but I want to post my method for weight loss again, and try to do it in as few words as possible this time. If you want more information about the principles upon which I based this method, read Total Fitness in 30 Minutes a Week by Laurence Morehouse, and The Hacker’s Diet by John Walker.

First, why you should care: I lost 40 pounds eating whatever I wanted and have kept it off even after joining Facebook and eating up to 3 meals a day at the gourmet buffet plus micro kitchens.

Second, why you may not care: you want to lose more than 2 lb / week (good luck with that) or you are a masochist.

Here’s what you need: a piece of graph paper, a pencil, and a bathroom scale (digital is best). Oh, and a little patience and a small amount of willpower (much less than your average diet requires). To set up all you need to do is draw a line in the corner that goes over 5 squares and down 1 square for a weight loss rate of 1 pound per 5 days, you can choose any weight loss or gain rate that you want as long as it’s not more than 2 pounds per week. Obviously, the faster you lose the more willpower you need, but no matter how much willpower you have it won’t work if you go much over 2 pounds per week.

Here’s what you do every day: just after you wake up you use the bathroom and then step on the scale—before eating or drinking anything. Mark your weight on the graph paper. Then, imagine the line that best fits the marks for the past 5 days (least squares fit for you mathy types).

Is that line sloping down more steeply than your reference line? Congratulations: you can eat as much of anything you want today. Don’t gorge yourself, but don’t fret it. Want that ice cream? Go for it. Candy bar? Sure. Triple burger with guacamole? Ok, but think about making it a double man.

Is that line flatter than your reference line (or going up)? Then today you still get to eat (almost) whatever you want! But, we need to restrict quantity. In specific, we need to eat about 500–800 calories less than your normal intake. You can accomplish this easily by eating smaller portions at meals and skipping dessert.

That’s it. Fast forward 1 year and if you have stuck with the plan you will have lost as much as 70 pounds. But we know life (and holidays) happens, so be realistic and figure you’ll fall off the horse a few times. No big deal, this system is designed to keep your morale up and recover gracefully. To be safe, expect 40 pounds per year, then be pleasantly surprised.

There is no correlation between what you eat today and what you weigh tomorrow. Well that’s technically a lie, but there are much bigger effects than what you ate. Your weight will fluctuate as much as 2 lb due to various effects. You have no control over this. The method is not relying on any correlation between today’s diet and tomorrow’s weight. It is relying on the long-term effects of eating smaller portions approximately half the days (maybe even less). If you weigh more today it doesn’t mean you failed yesterday! If you weigh less today it doesn’t mean you succeeded yesterday! You have to take the long-term view and just stick with the program.

Now some short notes. First, exercise is a good idea. No, a great idea. Although it’s not essential to this plan, I think you’ll find it helps you with appetite control and to just feel better all-around. Second, eating healthy doesn’t hurt either, obviously.

1 comment   |  tags: diet, excercise, health, life, weight


Oct 8 2009

AC_TYPE_UINT8_T and friends

If you get errors like this:

$ autoreconf
configure.ac:110: error: possibly undefined macro: AC_TYPE_UINT8_T
If this token and others are legitimate, please use m4_pattern_allow.
See the Autoconf documentation.
configure.ac:111: error: possibly undefined macro: AC_TYPE_UINT16_T
configure.ac:112: error: possibly undefined macro: AC_TYPE_UINT32_T
configure.ac:113: error: possibly undefined macro: AC_TYPE_UINT64_T
configure.ac:115: error: possibly undefined macro: AC_TYPE_SSIZE_T
autoreconf: /usr/bin/autoconf failed with exit status: 1

It probably just means you have an old autoconf. These macros were introduced in autoconf 2.60. But it’s probably no big deal if you have a sensible stdint.h.

no comments   |  tags: autoconf, autotools, C, cs, linux, unix


Oct 8 2009

EINVAL on sendmsg() to a UNIX Doman Socket

I’m seeing an EINVAL result when trying to do a sndmsg() call to a UNIX socket. The man page says that means that the sum of the iov_lens overflows an ssize_t, but an ssize_t is 8 bytes on this machine and there’s only one iov and its length is 671. Last I checked that doesn’t overflow anything but a char. What gives? Same code works fine in Linux and when using UDP or TCP.

no comments   |  tags: C, cs, mystery, network, socket


Sep 28 2009

SIGABRT and gdb

So you fire up gdb and pepper your code with assert() calls. Then one of your assertions fails and you see this:

Assertion failed: (item_idx < si.slabclass[clsid].perslab), function ITEM, file slabs_items.h, line 78.
Program received signal SIGABRT, Aborted.
0x00007fff83efab16 in kevent ()
(gdb)

Well shucks, you think you're screwed because gdb doesn't seem to have left you in a useful state. So you investigate conditional breakpoints (that are a pain to set and don't seem want to work in inline functions), and generally beat yourself over the head for awhile.

Then you realize that gdb's throwing you out into a different thread, and your pretty backtrace is there for the exploring, you just have to switch to the right thread. Yeah, remember that. Then maybe you can set a breakpoint on the actual assert code (which you can find with the backtrace—it was __assert_rtn() in my case) so you're already in the right thread and just need to go up the backtrace one level to get to debugging goodness.

no comments   |  tags: assert, cs, gdb, SIGABRT


Sep 11 2009

Rental Deposits

Dear Internets,

I seek your advice regarding rental deposits. We left the property in decent condition and the managers want to not only withhold our deposit but charge us $200 to boot. What are our rights?

When we moved to Las Cruces we got lucky and found a great place managed by a great company, Doña Ana Properties. Somewhere along the line, the property was sold and the new owner switched management to the unscrupulous Mathers Realty. There was much mourning, but thankfully our stay remained uneventful until the end.

When we moved out everyone told us Mathers would weasel out of returning the deposit, so it came as no surprise when we received a bill in the mail explaining all the ways in which they deserved our money more than we did. What was surprising is that they didn’t stop at exhausting the deposit, but racked up an additional $200 in charges. They charged $100 for “repairs” such as “a towel [in the bathroom] needs to be removed,” “the blinds are broken,” (they had been replaced not two weeks earlier and were perfectly fine), “remove the pan from the oven,” (all our pans are accounted for—I’m not sure what they are talking about). Then they charged $95 to clean the carpet that we steam cleaned, and $95 for “janitorial services”—we left it clean.

There are a few things I would be (grudgingly) willing to give them: the blinds in the other bedroom that were broken but from normal wear and tear, a modest amount for painting (they charged $150, the lease said “minimum of $50″), a modest amount for “janitorial services”, etc. In fact, I’d be willing to let them take the whole deposit (we had written it off anyway, based on their reputation). But I really don’t want to send them a check.

Here is the only relevant text of the lease: “As a general rule, you will not be held financially responsible for repairs due to ‘normal wear and tear’ or routing maintenance. YOU WILL BE HELD RESPONSIBLE FOR THE REPAIR OF DAMAGE DUE TO YOUR NEGLECT OR MIS-CONDUCT.” and “The deposit may be applied to recover losses, if any, suffered by reason of the Tenant’s non-compliance with this Rental Agreement including non-payment of rent. [...] Refund of your deposit is contingent upon the condition of the rental unit after vacated. The condition of the unit will be compared to its original condition as stated on the check-in list. (i.e. carpet shampooed, cleanliness, condition of walls, damages, etc.). A minimum of $50.00 will be charged for painting upon move-out.”

4 comments


Sep 10 2009

Publishing Availability

I have a calendaring dream. I want to publish my availability somewhere where people can see it.

My calendaring at work happens on an Exchange server, which works really nicely with iCal in Snow Leopard. I also do some non-work scheduling with iCal. I shouldn’t publish details of work scheduling because that has the potential to leak sensitive information. But there should be no problem with publishing availability.

Alas, I can’t figure out how to publish the Exchange information from iCal at all. The publish item in the context menu is greyed out. Although that calendar does have “affects availability” checked, I can’t see any way to publish that availability for others to see, which kind of defeats the purpose of availability don’t you think?

no comments


Sep 3 2009

git whereami

Update: I added git branch -a so that you can actually see where you are, and --since='2 months' so if your repo is huge like mine it doesn’t take 2 seconds to run. (The actual value of --since will probably need tweaking for your situation.)

Here’s the awesome git trick of the day:

# in ~/.gitconfig
[alias]
w = !git branch -a && git log --branches --oneline --graph --decorate --simplify-by-decoration --since='2 months ago'


$ git w
* 0bfd287 (refs/remotes/git-svn, refs/heads/foo) commit message
| * 0b5d8d4 (refs/heads/bar) another commit message
|/
| * 575185a (refs/heads/baz) YACM
|/
* b98de6b (refs/remotes/origin/master, refs/remotes/origin/HEAD) YACM
* eadfbbe initial commit message

If you’re lucky enough to have a recent version of git, the --decorate option doesn’t print out the boring refs/{remotes,heads} stuff by default.

no comments


Aug 24 2009

Terminal Merge Conflict Resolution

A very important tool in the toolbox of any collaborating developer is a merge conflict resolution tool. OS X has the fantastic FileMerge, there are various graphical tools for linux like kdiff3, but I have yet to hear of one for the terminal. There’s vimdiff, but it is really not up to the task of merge conflict resolution (doesn’t handle 3-way diffs). There’s probably something in emacs, just because there’s always something for emacs. Emacs users please enlighten me, I’m not above using emacs for merge-conflict resolution. Might even be the gateway drug.

It doesn’t seem overly hard (at least, no harder than writing kdiff3 or FileMerge) to make an ncurses tool that will take a 3-way merge and let you efficiently choose A, B, or edit for each diff section. Can it really be that nobody has done it yet?

6 comments   |  tags: collaboration, conflict, cs, diff, distributed, git, linux, mac, merge, resolution, ssh, terminal


Jul 22 2009

Turabian

Long ago in the days of yore (1937), Kate Turabian, the dissertation secretary at the University of Chicago, wrote a booklet of guidelines for student writers. Fast forward seventy years, and you get the excellent “A Manual for Writers of Research Papers, Theses, and Dissertations.”

Turabian is still listed as the author. It says “revised by Wayne C. Booth, Gregory G. Colomb, Joseph M. Williams, and the University of Chicago Press editorial staff.” I think that’s a bit ironic, like attributing a Wikipedia page to whoever made the first revision. But I don’t worry myself about who wrote what in this fantastic tome.

The part that Turabian probably wrote, and has probably been heavily edited, revised, and updated since 1937, is the style guide. It’s everything the student writer would need to know about the Chicago Manual of Style, including how to cite internet sources, with a much more reasonable price tag. That right there is a good reason to buy the book.

But for me, the best part of the book was not the style guide, though it will definitely be an important reference as I finish my dissertation, but the writing guide in Part 1 which I understand is new to this edition and is adapted from “The Craft of Research” by Booth, Colomb, and Wililams. I won’t say it answered every question or definitively told me everything I ever need to know about writing a dissertation. But compared to other books and websites on writing a dissertation, it was lucid, concrete, and very helpful. Maybe I’m just a literal kind of guy and needed some concrete steps to follow, even if they’re not perfect steps. But this part of the book helped me finally come to a comfortable structure and tone for my dissertation. I found what I want to say and how I want to say it and how to organize what I want to say largely thanks to following some steps outlined in this writing guide. But it did come from within, they didn’t hand me the answers on a platter. This is good I think, because I think the answers are different for different people and certainly for different disciplines, and also because I would have just ignored it if they had.

The writing section, at least, is slightly geared towards what I’d call the soft sciences (whether or not that’s an accurate term), but not terribly so and not to the point that you can’t make the in-flight adjustments to your hard-science needs.

Excellent book and well worth the $17. But be sure you get the 7th edition. And forget about buying the Chicago Manual of Style ($50+) unless you’re going to be an editor or something.

no comments


« Older Entries
gipoco.com is neither affiliated with the authors of this page nor responsible for its contents. This is a safe-cache copy of the original web site.