Archive for the ‘Uncategorized’ Category

Where the printf() Rubber Meets the Road

Sunday, March 14th, 2010

After ignoring StackOverflow for a while, I decided to check up on it a bit lately. Someone asked a question that’s one of those kind of fundamental curiosity issues that I enjoy explaining. He said:

I always thought that functions like printf() are in the last step defined using inline assembly. That deep into stdio.h is buried some asm code that actually tells CPU what to do. Something like in dos, first mov beginning of the string to some memory location or register and than call some int. But since x64 version of Visual Studio doesn’t support inline assembler at all, it made me think that there are really no assembler-defined functions in C/C++. So, please, how is for example printf() defined in C/C++ without using assembler code? What actually executes the right software interrupt?

Obviously the answer is going to depend on the implementation. Yet I thought that with the open-sourced GNU C Library, it would be pretty straightforward to show how most of it is in C but it bottoms out at syscall. But it really was quite a maze to connect all the dots without doing any hand-waving! So I found that my explanation just kept growing until it was so long that a blog entry was a more fitting format.

So read on, fearless explorers, as we dig into the complicated answer to a seemingly simple question…

(more…)

BIL 2010 PARTICIPANTS - WELCOME

Saturday, February 13th, 2010

Today I attended the fantastic event BIL. It is an “un-conference”, and was originally conceived as populist way of crashing/synergizing with the event known as TED.

(Though TED is awesome at spreading great ideas across the web, the speakers are by invite-only…and uninvited people must pay thousands of dollars to attend!!)

The incomparable organizer Todd Huffman gave me a minute to make an announcement after the talks had finished. I said something along these lines:

Hi there. My name is Brian. I love open source, and started a web site to support it called hostilefork.com. I also love Wikipedia—and I love events like BIL. So if you are doing something awesome and write me, I’ll do my best to offer any insights I can to help. My time is yours.

ALSO… I have an extra ten of these drinking glasses that need to find happy homes. As an added incentive, for each glass that is adopted I will donate $10 to BIL. So if you want to talk to someone technical–who will make time for you and your great idea, at no charge–find me and adopt a glass.

I hope to help you, but if for nothing else, do it for BIL!!

Yet while I and the other final announcers were speaking, the enthusiastic attendees were voluntarily packing up chairs. After all, we had to make our deadline for exiting the venue!! But I don’t think hardly anyone could hear me, and I think “something about open source and a glass” is about the gist of what anyone got out of what I said. :)

Thus only four glasses were claimed by the time we left the pavilion for lunch. But as lunch was wrapping up and I was about to hand Todd the $40 and head on home… people began to express curiosity about what was up with the glasses. Suddenly they were in demand, and the tenth was even contested over who would get it! I’m glad that the result is that every glass found a home, and I could give $100 to a wonderful cause that I supported wholeheartedly all the way back to when I attended the first BIL two years ago!

SO IF YOU GOT A GLASS: My hope is that you will keep it, and some night you will be enjoying a drink and be reminded that “The Fork” humbly offers his time and insights free-of-charge to the very sort of good people who think BIL is important!!! (I want not only good ideas to flow, but also that we all be vigilant in ensuring there isn’t an ever-increasing barrier to participation in that flow…)

MY PROJECTS: I know my WordPress theme is the default and lame, but if you look over in the right hand column you’ll see I’ve tried to make pages for my various open source projects. The one I’m most excited about is BlackHighlighter, which I’d like to develop further. (I’m especially interested in changing the balance of power in communications between people with little influence who send messages to those who get a lot of messages…and my goal is to employ BlackHighlighter to the communications between the electorate and Congressional representatives.)

I’M OPEN TO YOUR IDEAS AND CRITIQUE: This site is still in its formative stages, and it’s only one of my projects. But I did manage to get #1 Google rank for “hostile fork” and “hostilefork” and that makes me happy. (Because I want to STOP hostile forks, see my about page for more on my wish that open source developers push toward synergy, as if they were a company even though they are not!)

I invite you to talk with me about anything you’re working on. Leave a comment and I’ll write you back, or write me on Gmail… or follow me on Twitter.


I’d like to give thanks again to Todd, and to all the speakers and participants who gave their time the last two days. As much as I respect institutions and gatekeepers of clarity in knowledge, *someone* has to stand up and be the arXiv to the ACM… the Wikipedia to the Citizendium… the BIL to the TED!!


The Story behind the Glasses

These were a batch of 10 that had been in storage and difficult to give away, because the printer had screwed up in applying the third color (the white in the eyes):

I’d thought many times of just tossing them into the recycling, as they didn’t meet spec. But BIL has revolutionary thinkers—who share stories like beer bottles being presciently designed as interlocking bricks to build houses! How could I be throwing out these perfectly functioning highball glasses?

Once my carpool arrived in Long Beach, I ponied up the paltry (not to mention purely optional) suggested BIL donation of $20. Then I noticed there was exactly $100 left in my wallet, and ten glasses in my backpack. An idea formed:

What if I suggested that I would donate $10 to BIL for each glass that people would agree to give a safe and happy home? I mean, why not? I could use a dry-erase marker to write my website on it and it would be like a “business” <cough> card!

The idea rolled around in my mind as I listened to the speakers. I hesitated, BUT a talk regarding the 4 steps to accomplishing “virtually anything” made me realize the actual difference between “I can’t” and “I won’t”. Like Wikipedia, here was a case where I could—and more importantly should—lend financial support!

I’m very happy with the results. So thank you all!

.Trashes, .fseventsd, and .Spotlight-V100

Wednesday, December 2nd, 2009

Merely plugging a removable drive into a mac (when it has write access) makes OS/X think it can take the liberty to write a lot of hidden garbage onto that disk. If you want to stop this from happening, you have to put some special files on that disk before you plug it in.

To stop OS/X from doing Spotlight indexing, you need a file called .metadata_never_index in the root directory of the removable drive.

To stop OS/X from making a .Trashes directory, you need to make your own file that *isn’t* a directory and call it .Trashes

To keep it from doing logging of filesystem events on the drive, you need to make a directory called .fseventsd and inside that folder put a single file named no_log

The contents of these files don’t matter, so you can make them empty files using touch. Even better, you could make it a text file with a link to this post, so that you (or someone else) wandering across the files will know what they’re for.

Apple’s choice to do this is incredibly self-serving and shameful. At bare minimum, hidden files and features like these should be off by default for any non-mac-only filesystem formats. They should only be enabled when the user has been made aware of them.

Permanently Changing GRUB Menu In Ubuntu

Sunday, November 22nd, 2009

Ubuntu has a nice install screen that lets you press F4 for Modes or F6 for Other Options. If you have an older laptop, you may find that you can’t boot unless you turn on “Safe Graphics” or check “acpi=off”.

(Note: In my case, the failure I was experiencing on boot was accompanied by horrible graphic corruption on the LCD. This made me think I’d need safe graphics mode, but that had no effect. It turned out the acpi=off was the setting I needed to get through the boot. YMMV.)

Yet there’s a catch to getting Ubuntu working this way. It may get you through the install, but once you’re finished and try to boot from your hard disk these options aren’t there any more. As of 9.10, it seems that it does not slipstream these settings into the configuration files on your hard disk.

As more of an exercise than anything else, I looked into how to address this after installing Ubuntu onto an old Pentium III laptop. Hopefully it can help someone else. Here goes…

(more…)

An Enumerated Type For REBOL 2

Saturday, June 13th, 2009

I’ve uploaded a script (enum.r) to rebol.org, which implements enumerated types. Although I typically prefer catching these things at compile-time instead of run-time, I’m pretty pleased with how it works. Especially cool is that I could add a powerful version of this language feature in only about 60 lines of code!!

(Note: That figure doesn’t include the comments and the regression tests. I included those in the script, but they are not necessary to use the enum itself.)

I called it “powerful” because it does more than just ensure assignments to objects use legal possibilities. Here’s a demo to show it off, and bear in mind that there’s no native support for enumerations in REBOL:

>> fruit: make-enum-type [apple orange banana mango]
 
>> favorite_fruit: make-enum fruit 'apple
 
>> set-enum favorite_fruit 'shoe
** User Error: illegal enum value ( shoe ) when 
     possibilities are [ apple orange banana mango ]
 
>> switch-enum favorite_fruit [
     orange [print "orange"]
     mango [print "mango"]
]
** User Error: missing switch-enum cases for [ apple banana ]
 
>> switch-enum/default favorite_fruit [
     mango [print "mango"]
     apple [print "apple"]
     banana [print "banana"]
] [print "other stuff"]
** User Error: switch-enum specifies a /default which is 
   more clearly expressed as case ( orange )
 
>> switch-enum favorite_fruit [
     appel [print "apple"]
     bananna [print "banana"]
     orange [print "orange"]
     mango [print "mango"]
]
** User Error: illegal case values for switch-enum
     [ appel bananna ] when possibilities are 
     [ apple orange banana mango ]

The syntax isn’t necessarily ideal, but that’s a *lot* of features for 60 lines of code!

It makes me reconsider the tradeoffs when compared with gigantic compilers. Although static analysis tools are necessary for huge codebases, the REBOL approach might be able to reduce the amount of code to a manageable size. Perhaps then, one can verify it is correct by actually reading it. :)

(more…)


Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported