Home

Journal de Jamber

Recent Entries

Jamberwings

colorful yawning kah

View

Navigation

February 11th, 2007

Meh browsers..

Add to Memories Tell a Friend
yawn boring classes feh
Opera sez: You are about to open 71 bookmarks. Wtf, foo'? [Y/Ack,NNN!]

I love little things like this. They are proof of real thought going into a program, and a suggestion they might have even done that elusive thing, user testing. This is not the first time I've slipped with the mouse, and doing so in Firefox or in explorer can be deadly.

I loathe to say it--but I actually am getting really sick of FF. It's great for all the cool plugins, and for web dev. But the trouble is all the "browser logic" is Javascript... and sluggish JS for me at that. You know the feeling you get running .NET or Java apps? You can TELL it's not native code. By the time I add all my favorite extensions, it gets two or three times worse.

And to top it off, I recently upgraded to FF2. Instead of just hanging for 2-3 seconds on a page load, it locks my system too. That "I'm pushing 50MB through the swapfile" sorta freeze, nevermind I have plenty of RAM. Obviously this brings it from "maddening" to "unusable."

I was pleased to find that Opera offers a lot of the same features, even down to my favored window layout, so I think I will try that out for awhile. It's definitely not as fast as IE6 (they have a silly theme engine too, and do too much graphics buffering), but it isn't jamming up.

January 28th, 2007

Momentarily outwitted

Add to Memories Tell a Friend
colorful yawning kah

My code—or rather my bugs, you could say—have apparently been trying to make an artistic statement.

No comment, except... I think they succeeded. o..o

January 7th, 2007

Very paraphrased and condensed, but this is what I heard (not specifically the words we said, but what I got out of it):

Me: Okay, I hate these things (rant rant rant). ALL the interview advice I've ever seen or heard assumes I'm perfect, which is ridiculous. They also say the questions are very specific and nonintuitive [ed: for ex, "tell me about yourself?"]. But here's an example that crops up in just about every job interview. What do I say if they ask about X? I know next to nothing about X. If I tell the truth I'm certainly not going to get the job.

Parent: You'll learn as you go through them. They're not manipulative and prejudgemental. Stop looking for advice and just try it, figure it out yourself, be honest. I had to, what's your problem? By the way, you had plenty of time to learn about X in school so what are you complaining about? [ed2: fine, but you know the circumstances almost as well as I do, and wherever the problem lies—the fact is I didn't pick it up, whining about the past is a waste of time, and I need help now, not another slap in the face, okay?]

I think from one angle, this sums up a lot of my problems.
(This is also why I don't usually ask for help.)

Ignoring the serious issue of not having enough sleep all month, and really only being able to sleep well in the daytime, what am I supposed to do? I need some hard answers here and she just won't give me any. I honestly don't think she KNOWS outside her limited experience, but I wish she would at least consider my feelings... -..-;

[Ed3: She says I don't express them. Well, the same could be said of her, and her husband. Some of this comes down to him, and some of it comes down to being convinced/terrified of rejection were I to share my identity. In the end, metaphorically speaking, none of us are getting comfort or hugs. So it should make more sense I stay upset about everything, having noone to go to. That is one of my biggest problems, and needing work falls out of that, in a catch-22 sort of fashion. I hope I can work something out with the counsellor eventually.

I suppose one could argue against putting this stuff in a public post. Well, soddit. It kinna stops being private when it affects me, and (rather indirectly) some of my friends. Nor am I ashamed to have problems. I need an outlet and a place to keep track of my thoughts, and the feedback might be helpful.

And I think most of my friends list knows better than to judge everything from a few sparse LJ entries. This is, after all, spur of the moment and colored by mood, not an impartial biography. Disclaimer off.]

December 29th, 2006

Well, amongst smaller things, I requested (and got) a DS lite over Christmas. This should be no surprise to anybody, what with the supplied Pointy Thing and all the talk of touching... gah! Nintendo is so flaming gay now. AC is proof enough of that...

Which is probably exactly why I'm pleased, thus far.

(See, all you teen gamers? The lesson is, don't make fun of the artsy folks. If you do, their revenge will be a series of games focused on coffee shops, mortgage payments, gardening and interior design! See: The Sims, Sims 2, Second Life—okay it's not a majority but JUST YOU WAIT!)

Well seriously, the whole thing is better built than the $400+ PDA I got a few years ago, and it has smexier hardware too. I'm definitely gonna order a key and a media adapter and see what I can do.. The SC has 32MB (!) of RAM in it, and reads nice large SD cards, which should be more than enough to run things like an organizer, MP3 player or a port of Gaim. I don't think there's a compelling browser yet, but I don't really need to squint at LJ either...

Anyway!—
Mario Kart DS060217 402007
Animal Crossing WW4811-2421-4391

M'still figuring out how all this stuff works, and the wireless doesn't reach too well upstairs. But hey, someone might be interested?

December 1st, 2006

Brrrr!

Add to Memories Tell a Friend
the inscrutable starfish
See also, visuals.

November 26th, 2006

Dream distraction

Add to Memories Tell a Friend
colorful yawning kah
Last night I dreamt about little subworlds. There was one peculiar thing about them—they had more "there" there. What I mean is, if you did a quarter turn four times, as measured by a house wall for example, you wound up looking down a fifth hallway. Indeed, outside, the square buildings were five-sided.

Some guy had set them up and was showing people around. It was a subtle thing you tended not to notice for a minute, until you got lost. Also, one of them had a society living there that seemed under threat somehow—unsure whether it was meant to be real or fictional. (Insert lots of colors and details that probably made more sense at the time.)

My geography and chemistry teachers also made reappearances, doing catchy presentations ala Bill Nye on things I can't quite remember.

Ed note: Google says this is called hyperbolic space. And in fact it is very easy to get lost, because instead of having cubic amounts of "here and there" in an increasing radius, it's exponential! I feel sorry for the search teams, don't you?

Unfortunately I knew about that before my dream did. But I love the notion of quaint old houses and school buses and green fields pulling these tricks.

November 23rd, 2006

State of things

Add to Memories Tell a Friend
warped innocence
Hurrrrrgh. What a morbid night.

Actually it hasn't been that great a year, either. Besides that nothing much has happened, this is another reason I haven't been posting much. I hate to write despairing entries. I just feel like I'm guilt-tripping the one or two people who probably still read this. And it feels like needless brooding. (Then again, I've been sort-of brooding on and off all year, I'm just used to it.)

That nothing has happened is exactly the problem. Abstaining from LJ was in retrospect probably a mistake—it just leaves the days free reign to blur together. More like weeks and months, now. And as a result I haven't given more than token thought to where I'm going.

Not that I would necessarily remember if I did. I'm horrible at organization and goals. I can't even get my damn feelings set on one. They're always shifting, it seems.

The glasses are amazing, though. I can't help looking back. This is the first real sign of aging and the notion that, if these last three or four years went so much faster than the three before that, my time is running out faster than I thought. I can't stay here too much longer...

Of course, now I feel I have nowhere to go. It quite frankly scares me to think I logged onto Chaotic almost nine years ago, because I know I'm not the same person today, because I fear I'm losing important parts of myself I gained there...

I don't think I even know who my friends there have become anymore, because virtually all I ever see of them is LJ. Though I hesitate to say anything, I find it rather painful to hear about them now. It makes me wonder why I'm not over there, with them, what I'm doing wrong, what I should be doing, if I even belong anywhere anymore. And I wonder how well they remember me...

Everyone makes it look so easy, and I don't even know where to start.

I did start volunteering at the library. It probably says a lot about the situation—that I'm only too eager to get out of the house, because that's pretty much why. I'm willing to work for free just to get away from my parents. Well, I'm sure the library folks appreciate the help too, which is some small consolation. Better to be wanted somewhere...

Which I'm sure will sound like typical teenage emo, but I'm not sure how else I'm supposed to feel.

Consider that my father-if-you-can-call-him-that hasn't even tried to talk to me in months, and hasn't made reasonable effort in years... the idiot somehow manages to get promoted to a job in the Pentagon, and he can't even apologize to his own son! Or at least openly refuse to change. At least then he'd be showing a spine. But he acts like the silence is normal, and/or he just doesn't care.

Consider that I couldn't truly talk to my mother if I wanted to. I hear no fondness in her voice; if the conversation ever drifts to my future, something I avoid, it will inevitably turn into a rant on her part on how much money they spend, how I need a job but apparently can't work, and any amount of hurtful venting that just ends in an argument. (While it's partly a matter of opinion, don't even get me started about what they spend it on. :P)

Still, being starved, I wind up talking to her anyway. Way more than I wish I did. But it's hard to engage her in intelligent conversation. Whether it's art, computers, politics... I feel like I'm talking to a wall. This might not be intentional on her part, as she hates reading and avoids anything but the tv and the newspaper... but the effect is the same. I can see now why she responded the way she did when I tried to come out many moons ago. This alone is bad enough; it makes me feel ignored at best, rejected at worst.

I'm already 23, so I guess everyone thinks I should be self-sufficient or something, but no. I wish I knew what to do. The parents—well, parent—aren't making me leave. They hardly ask me to cook, they don't ask me to clean, my rooms aside (though sometimes out of sheer boredom I do it anyway).. I've been here so long I'm afraid to leave the house without them, yet I'm excruciatingly lonely in a twisted way that makes me feel a bother to anyone online...

So I don't try to talk much over IMs. Quite a few I've met there seem to want snuggle (among other things) instead of conversation as it is. I never really figured out why, but it just makes me feel worse.

I'm afraid of a lot of things. I'm afraid of the freaking cat dying. I'm.. well, not as much afraid of art or coding anymore, moreso because I'm finding it harder and harder to care. I have nobody around here to appreciate it, even myself for very long it seems... since there's no way I'm displaying all of it in here, with the parents around. And nobody to talk or compete with about it, which is one of the best things...

Well, I guess it's Thanksgiving. Quite an ironic time for such a post. I'm sure there's someone to thank (indeed some of them already have been)... erf. But it doesn't change the situation as is.

I'm off to brush and sleep, so I can go try and get up and bake a pie before the turkey goes in. I can at least enjoy the cooking, if not so much the company... -..-;

November 21st, 2006

Code omens...

Add to Memories Tell a Friend
oof ergh *blat* d'oh!
template<> struct promote<byte, unsigned shirt> { ... }
Hmm, might be enough coding for today. You know—first it's shirts, next thing it'll be volatile unsigned dryer lint. Then I'll be casting off box<short>s and long johns; and destructing Tokyo().

A purely virtual notion I'm sure, but you just can't be too careful...
Nothing much up, really. [Ed: Except a proper Jamber post. OMG, the world ends.]

I did get computer components, unfortunately not the upgrade I would have liked though. They work, for now. Still need a USB2/FW card for the hard drive. Didn't realise how slow USB1 is.

The pumpkin fuzzed up before I settled on what to carve, so all I got were seeds out of it. I don't feel that inclined to do NaNoWriMo either, no matter how cool it is. I guess that's the caveat of too many latent hobbies.

The parent took me for an eye exam last week, since they'd been paying the health plan and simply forgot to take me the past couple years. Turns out my eyes have, to put it politely, "aged" slightly during that time (betrayal! BETRAYAL!), and that this vaguest of groggy haze I've been walking through has less to do with grog (or various bits of TMI ;p) than I'd thought. The glasses aren't desparately needed by any means, but they make things interestingly more pleasant in some ways.

At first I felt like I was walking around Second Life with all the hawk-sharp edges. (Well, not SL, but certainly something with an actual framerate. You know what I mean.)

Speaking of SL, I remain simultaneously irked and "ooh! shiny art-things!" with it. In particular, making avatars is just too damn hard. But! I have partly deciphered the avatar model, and I'm looking at ways to make av creation easier.. especially getting a good preview without spending a bundle on L$ or just living with the flaws. This is sommat an issue for free accounts, and even more an issue for less average shapes, as I am.

I still keep putting off art, and art posts. I'm sure I could dig up something, but.. meh. I could rather use the encouragement, and more artist-friends, it's boring drawing alone.

This morning's dreaming consisted of a lot of tangentially related things, including but not limited to:

* Drawing eyes with Mysterious Eastern Coily ThingTM Brand Levitation*;
* Large crowds;
* Boring trips to the relatives' retirement home;
* Stumbling on a presidential speech by the Shrub;
* Being suddenly embarrassed because I was prancing and rolling about in the grass at the time, and I hear you can be apprehended as a terrorist simply for having fun these days;
* Pretty sunsets wherein in its haste, the sun forgets to hide first, and turns into the moon as it rushes to set;
* Forgetting my camera, erf;
* Finding some old fart's camera, thinking it was ours, then putting it down, which leads to..
* My getting framed (cue cryptic SL name/group title that isn't mine) and subsequently descended up upon by a throng of 400lb, presumably rival, gang members.

Unfortunately I woke up before I had the sense to cook and eat them all. Damn this dream-self.

About the Mysterious Eastern Coily ThingTM Brand Levitation: It's kinda weird.

Way back while hop-skipping across the playgrounds of yesteryear, I never quite managed to defy gravity. But inexplicably, in my dreams gravity is sometimes more tenuous. I find I can often glide a few yards before settling back down. It's a bit (only a bit) like Cave Story <= go play this now :3, or Yoshi's Island without all the squinting and wriggling. Another thing that feels oddly natural by the way—despite my incongruous human sensory map—is galloping.

This time I nailed it, and settled into a steady state a few inches off the floor, drifting around the crowds.

Which really only helps my impression that porky though Jamber is, he is as much a Coily Dragon as one of the Wing-a-Lings.

October 3rd, 2006

Syntax, mark two

Add to Memories Tell a Friend
mooooose!
I wish I could write in two or three languages at once. Witness the following hypothetical example which might be used to disassemble machine code:
(decoderGroup new: `x86ArithmeticRegOps
    memberWhen:   `($code[0]  ~ @00??????
                 && $code[0] !~ @00????11)
    memberIndex:  `($code[0] takeBits: %00111000)
    members:      [ADD OR ADC SBB AND SUB XOR CMP]
    details:      [
        `(if `($code[0] ~ @???????1)
            ($dataSize = [32 16] choose:
                (bits16 in $cpuMode
                    ^^ toggleSize in $prefixes))
            ($dataSize = 8)
            )
        `($args = ($code[0] takeBits: %00000110)
            selectFrom: [
                (ModRMArgs bytes: code[1..] dest: regOrMem  src: reg)
                (ModRMArgs bytes: code[1..] dest: reg       src: regOrMem)
                (ImmedArgs bytes: code[1..] dest:
                    ([8:regAL 16:regAX 32:regEAX]
                        choose: $dataSize))
            ])
    ])


Compared with typical Pascal )

This sort of want happens to me a lot. Can you count how many languages I've plagiarised? How about the number of features missing from C++ or Delphi?

Myself, I see a little Smalltalk, Lisp, C++, even Perl and (oh gods) INTERCAL. There are literal lists, tri-valued booleans, hashes, class fields, and closures with named parameters.

I know people are going to tell me, 'learn LISP.' And I would agree, but there needs to be an infix expression syntax for numerical work. Haskell is interesting that way, as it sort of has both.

The lack of closures alone pains me so much, I can't imagine why anyone would leave them out! I love them in JavaScript. JS also has some great LISPy structured literals. These really should be a standard language feature--literal code, structures, and arrays, just like literal numbers or strings.

I don't know there's any language that does what I want. That's the thing... they all have different strengths. It would be great to be able to use the right syntax/structure for the right problem.

Hurrrf. Guess I'll be expecting that right around the time programmers stop treating language and technique as religion...

September 17th, 2006

Not quite C++

Add to Memories Tell a Friend
colorful pixelly kahmynx

I thought I'd try the Visual .NET Forms stuff in MSVC++ 2005. I hoped I could get a decent GUI up and keep the rest of my code as clean, platform-independent C++.

Maybe I'm just stupid, but this is the simplest way I could find to get a std::wstring path out of an explorer icon dragged atop the form:

System::Void MainWin_DragDrop(
    System::Object^ sender,
    System::Windows::Forms::DragEventArgs^ e
) {
    array<String^>^ dropList =
        dynamic_cast<array<String^>^>(
            e->Data->GetData( DataFormats::FileDrop ));
    
    String^         filePathCLR = dropList[0];
    std::wstring    filePathSTL;
    	 
    // "Obvious" method
    //for each( wchar_t c in filePathCLR )
    //	filePathSTL.push_back(c);
    
    // Suggested method (MSVC documentation... srsly)
    using namespace Runtime::InteropServices;
    const wchar_t* filePathRaw = (wchar_t*)(
        (Marshal::StringToHGlobalUni( filePathCLR )).ToPointer()
    );
    filePathSTL = filePathRaw;
    Marshal::FreeHGlobal(IntPtr( (void*)filePathRaw ));
    
    m_MyObj = new SomeDocumentObject(filePathSTL);
    // ...
}

There are several interesting things to be seen here. I'm not sure what to think of them.

For one thing, this isn't even C++! They've added a whole chunk of C# as completely new syntax. Seen here are the ^ which is their garbage-collected heap pointer, array (which is a keyword and derives from System::Array), and a few bits of their class library. Also notice the for each, where each and in are context-sensitive (!!) as keywords.

Oh, and don't even get me started on the freaking casts.

This syntax is completely required. The form designer generates it, and their library depends on the special references. That's because if you compile in "safe" mode, hoping to run under someone's tight security policy (and they encourage you to)... pointers aren't even allowed!

Naturally, this breaks just about every useful piece of C and C++ out there, including the all-important STL which sets C++ apart. While I understand the security motivation, I think this is misleading on MS's part, since at that point, it's not C++ anymore! It's just another dialect of C#, or maybe C# with templates. :/

I could simply compile in "pure" mode (effectively, insecure bytecode), and use the STL with the bureaucracy above, but it's still annoying. Mmmfeh.

September 12th, 2006

Too smart for me

Add to Memories Tell a Friend
colorful yawning kah

So tonight, I was perusing some annoyingly table-y tech reference, and I wondered if it was feasible to print this out, four pages to a double-sided letter sheet, and bind it into bookish form. To my surprise, OpenOffice actually has some basic stuff documented, and I was able to get proper page headering and left/right page margins.

Time to print! I checked the Bookbinding Page Calculator, and got the following 2-up page orderings:

Front: 32,1,30,3,28,5,26,7,24,9,22,11,20,13,18,15,
1,33,1,35,1,37,1,39,1,41,54,43,52,45,50,47
Back: 2,31,4,29,6,27,8,25,10,23,12,21,14,19,16,17,
34,1,36,1,38,1,40,1,42,55,44,53,46,51,48,49

Feeling wary, I tried this first with the excellent PDFCreator. And fortunately so--can you guess what I got? Why, yes...!

1,3,5,7,9,11,13,15,18,20,22,24,26,28,30,32,33,35,37,39,41,43,45,47,50,52,54

So apparently some programmer thought he was ZOMG CLEVER!!@ and decided to "helpfully" union and sort the list. Except (nevermind, I think, that MS Word doesn't) that's not the purpose of this option at all! If anyone wanted foolproof consecutive numbers, they'd type a page range... yeah. Real smart.

*growls*

On another note, Windows Live Writer is still very sparse and beta, but actually kinda promising. For one thing, it works with LiveJournal (!) among others. I can take screenshots and paste them right in, and it uploads to Scrapbook without ever needing to save in between. They also try to grab your blog style and display it all WYSIWYG-like in the editor, although it doesn't completely work for me yet. Supposedly, it supports plugins.

Bah. I don't remember what else I wanted to say.

September 2nd, 2006

width   = 2{page} * 10.5{in} * 600{dpi};
height  = 2{Page} *  8.0{in} * 600{dpi};
iters   = 10,000;
samples = 10,000;

let pn+1 = µ * (1 - pn) * pn;

let pixels[] = 1.0;
let pixels[xc, yc] = 0,
where
  xc = floor(µ * width / 4),
  yc = floor(piters * height),
  p0 = 0.5 * index / (samples - 1),
  index = floor(x), x over [0..samples-1],
  µ over [0..4];

CPU: 88%
Working set: 9,420K
Virtual size: 478,228K
Page faults: 238,735

Rendering... 42.381%

I think this is gonna be awhile. :>

Yanno, I really wish there was a language like this. The compiler ought to be able to slurp up all these clauses at once, and then say:

"Hey, pixels at xc and yc should be zero, but what are those? Oh, I see xc is an integer coming from a formula involving µ which covers the range 0..4. So we'll try all the integers 0..width. And yc involves piters, and okay, I can get that starting with p0, but then I have to try all values of index... Of course with two variables involved I have to try all the combinations, and p is an iterated function so it's really a triply nested loop.."

Well, you get the idea. Maybe there is something like that already, but it sounds pretty academic. For now, the actual code's in Delphi.

[13:40] Edit: Well, it's always the littlest things. I rotated the whole thing 90° so it stopped thrashing the processor/page caches, and killed a couple (!) of redundant zero-fills in the graphics stuff. Kinda important when the graphics get that huge! And noticably faster. No trying to commit that virtual 500MB at once.

Still the same size, but now it's more like 90+% CPU, 6MB working set and 1,690 pagefaults. It should just stream out to the swapfile as it touches the rest, since it never reads them except to save at the end. Yay or sommin.

I wonder how much this sorta tuning conspires to wreck the notions above. In this case, the value (and not just the curse) of imperative languages is being, well, imperative! A good inferential compiler would have to think pretty hard about this stuff, maybe even experiment at runtime. (Now that I think of it, perhaps the SQL people have already been there, it's quite similar in spirit.)

August 30th, 2006

1-up?

Add to Memories Tell a Friend
colorful yawning kah
So. A few people have tempted me back onto Second Life lately, and it's got me itching for computer parts again. After a good bit of on and off reading, I finally felt good enough to sit down and check prices.

My budget is about $350 and I don't need new drives or peripherals. So this is the best I could find. I'll probably order these tomorrow (er, later today) if no disturbing revelations crop up.

List
price
DiscountMail-in
rebate
ShippingTotalItem
$120-$20-$50free$50Ultra MicroFly M-ATX Case with 400W PS - Black
$66free$66AMD Athlon64 3000+ Venice 2GHz HT 512KB L2 S939
$58-$10+$6$54Foxconn 6100K8MA-RS S939 NV GeForce6100 M-ATX AMD
$98-$8+$5$95OCZ Value Series 1GB (2x512MB) 184-Pin DDR PC3200
$69-$15+$5$59eVGA 256-P2-N437-LR Geforce7300GS 256MB GDDR2 PCIE

$411-$20-$83+$16$391 up front, $324 after rebates


Comments are of course appreciated if anyone gets to this before then. I look forward to having the spare cycles. :3

August 24th, 2006

So DietPower, the food logger I use, decided as long as I'm sitting here, I could wait two minutes for the food log to open. It was already slow, but now it's firmly in the realm of code that doesn't scale.

C'mon, it's clearly a C job. No excuse. I know people who write faster apps in Perl!

Another irritating thing is it's missing an export option, so the only way to get the logs out involves manual inspection, and then writing the code. The latter's not so hard, but I always used to cringe at binary files. Maybe the braver people would drag out a hex editor.

Well, the first thing I reach for is EDIT.COM. That used to be because it's all I had that reliably saved binaries... too bad it doesn't do hex, right? But after awhile I noticed that an ascii view is really useful, quite possibly moreso.

For one, you get the best use of screen space, which reveals a lot of patterns. Intel code is very dense, with the occasional word-size data thrown in. C structs with small numbers (e.g. most of them) leave a lot of zero padding. Pointers and offsets can be seen growing throughout the file. Text, of course, is immediately readable.

Repeated data shows up especially well, since nearly every byte has a unique glyph. The exceptions, 0x00/0x20/0xff, are blank. Happily, this includes various representations of nil: space, the integers 0 and -1, floating-point zero--and unused numeric precision.

Other values show up too, for example values centered around 0x3f (?, @, A) which are sign/exponent bits for small positive floats. "  Ç┐" happens to be 0xbf800000, or -1.0. At left, it marks unspecified nutritional values. (Sloppy coding has introduced other negative values as well!)

If the file is just a series of structs, it shows up as angular striations, betraying the length and number of the records. Usually somewhere nearby is the count. If you know your hex and ascii (essentially base-16/256), you'll quickly find it, and now you can write a skeletal reader.

And then you can go try all the program's special cases, and make note of what it spits out. This is how I wrote my OpenCanvas reader. Maybe I can get DietPower's logs into a spreadsheet or something...

It does give me thoughts, though. Using EDIT works great, but it's still a pain to do the math. I wonder if there's a better editor out there. I think I should be able to select regions, say "this looks like a record", and have the thing pattern-matched down the whole file. Then I could say "these are float fields", and it would update everywhere.

I think I would have circular tooltips, where you hover over some data and it shows you all the different values it could be in each representation it knows, and then the most likely one. (0's or 1's on the left = small int, high bits near 0xbf, 0x3f = small float, compare to values in other instances of the record...) Then you'd right-drag through a pie menu to choose one of them.

There could even be a hex view, either through a lens tool, or using a color mapping on top of the numbers, to show patterns. Or you could space things out and display assembler inline with all the other data, using heuristics (statistics, file headers) or manual selection to identify the code.

Ideally it would come with different plugins for the known formats, and people could write their own. You could use it as a teaching tool for Operating systems 101, or to help debug things, or repair corrupt files.

Ohwell, I'm probably dreaming. But it would be helpful right now.

July 26th, 2006

Level up!

Add to Memories Tell a Friend
16-bit dracus

If you can stand the quirks/don't need C++, Tiny C is amazing. Where GCC takes entire seconds per file on my machine, a Makefile running TCC spills output faster than the xterm can display. I only wish I was kidding!

TCC also comes in a library form that you can plug into your apps to compile C "scripts", can do optional bounds and pointer checking at runtime, and it even squeezes onto a floppy. Mind, it doesn't generate the best code, but then again, most isn't time-sensitive—and if your algorithms depend on a clever optimizer to be usable, they probably won't scale as it is... But I digress. In fact, there was a problem...

Kahmynx@FRANCIS /c/Code/Magenta_bloo $ make run
tcc -g -o build/magenta.exe Fuschia.o Cyan.o White.o
  -L/Dev/gc6.6 -lkernel32 -luser32 -lgdi32 -lgc
build/magenta.exe
Segmentation fault

make: *** [run] error 5

Kahmynx@FRANCIS /c/Code/Magenta $ gdb build/Magenta.exe
The debugging information in 
  `c:\Code\Magenta_bloo/build/Magenta.exe' is corrupted.
The file has a `.stabs' section, but no `.stabstr' section.
(gdb) break main
No symbol table is loaded.  Use the "file" command.
(gdb) . o O ( wtf? )
Further investigation revealed that compiling *.c to a binary worked, but compiling to *.o and linking these somehow mangled the debug symbols. And sure enough, an incriminating remark in tcc/src/tccelf.c:
/* load an object file and merge it with current files */
/* XXX: handle correctly stab (debug) info */
static int tcc_load_object_file(
  TCCState *s1, int fd, unsigned long file_offset)
{

"Correctly?" Erk!! Well they don't call it v0.9 for nothing, but it's not the sort of commentary one wants to see in a compiler!

But with the company of lazyweb, and some quick if mind-numbing research, things are looking up. Many hours later:

# Why not? Btw, no visible delay here
Kahmynx@FRANCIS /Dev/tcc/src $ ../tcc -g tcc.c -lkernel32
Kahmynx@FRANCIS /Dev/tcc/src $ ./tcc -g mathtest.o win32/lib/crt1.o
  -L./win32/lib -B./win32/lib
Kahmynx@FRANCIS /Dev/tcc/src $ gdb mathtest.exe
(gdb) break main
Breakpoint 1 at 0x4011da:
  file c:/Code/Magenta_bloo/scraps/mathtest.c, line 94.
(gdb) list
85              unsigned overflow = xor & (x ^ modulo) & 0x80808080;
86              unsigned over_p = overflow & modulo;
87              over_p = over_p - (over_p >> 7);
88              unsigned over_np = overflow - (overflow >> 7);
89              return (modulo ^ overflow) & ~over_np | over_p;
90      }
91      
92      int main(int argc, char**argv)
93      {
94              if( argc < 4 )
(gdb)

And right now this is the most gratifying thing, being able to go and hack on the compiler, and even sort of comprehend what I'm doing. It's the wonderful feeling of a warm light shown on things that are black magic to most people...

Or maybe the feeling I might take over the world next Tuesday. That doesn't seem substantiated, though.

July 13th, 2006

Cute bitwise math tricks

Add to Memories Tell a Friend
colorful yawning kah
Some months ago I found a couple of brilliant pages (1, 2) on dealing with graphics data. By which I mean, four-component vectors packed into machine words. E.g. 0xAARRGGBB or struct { uint8_t r, g, b, a; }.

Applications like Photoshop or OC, are really just a slick interface over all these vectors. Since there are naturally quite a lot (e.g. tens of megabytes) of them, the authors have invested quite a lot of effort to speed up the math.

This is the lovely part. You don't have to know calculus, but you do need a twisted mind. For example, these two snippets add and subtract vectors, limiting the results to byte range. So annoying to do componentwise, but look!
sum = x + y;
low_bits = (x ^ y) & 0x010101;
carries = (sum - low_bits) & 0x01010100;
modulo = sum - carries;
clamp = carries - (carries >> 8);
result = modulo | clamp;


(modified, the original page did 16 bits)
diff = (x - y) + 0x01010100;
low_bits = (x ^ y) & 0x01010100;
borrows = (diff - low_bits) & 0x01010100;
modulo = diff - borrows;
clamp = borrows - (borrows >> 8);
result = modulo & clamp;
They compile to 12..14 intel instructions, adding in parallel and saving up to three expensive branches. Some manual assembler can even fix the carry problem (on the add) and do the full vector.

Here's a premultiplied alpha blend, resembling code from the linked page. They are computing destC = destC*(255-srcA)/255 + srcC. The first is approximate, and the second (in a not so obvious way) exact:
dest_ag = (dest & 0xff00ff00) >> 8;
dest_rb = dest & 0x00ff00ff;
alpha = 0x100 - (src >> 24);
dest_ag *= alpha;
dest_rb *= alpha;
dest_ag = dest_ag & 0xff00ff00;
dest_rb = (dest_rb >> 8) & 0x00ff00ff;
dest = dest_ag + dest_rb + src;
dest_ag = (dest & 0xff00ff00) >> 8;
dest_rb = dest & 0x00ff00ff;
alpha = 0xff - (src >> 24);
dest_ag = alpha * dest_ag + 0x00800080;
dest_rb = alpha * dest_rb + 0x00800080;
dest_ag = ((dest_ag >> 8) & 0x00ff00ff) + dest_ag;
dest_rb = ((dest_rb >> 8) & 0x00ff00ff) + dest_rb;
dest_ag = dest_ag & 0xff00ff00;
dest_rb = (dest_rb >> 8) & 0x00ff00ff;
dest = dest_ag + dest_rb + src;
This is based on the principle that 4 * 1020304 = 4 * (1000000 + 20000 + 300 + 4) = 4081216. The coefficient multiplies digits independently, preserving their place values. So while it looks complicated, it saves two multiplies and (in the second case) four (!) divides. The remaining logic is easily parallelized on its own, a cinch for modern compilers and CPUs.

Finally, here's one I noticed! It's just a componentwise product, treating the bytes as unit fractions:</tr>
dest_ag = (dest & 0xff00ff00) >> 8;
dest_rb = dest & 0x00ff00ff;
src_ag = (src & 0xff00ff00) >> 8;
src_rb = src & 0x00ff00ff;
dest_ag *= src_ag + 0x00010001;
dest_rb *= src_rb + 0x00010001;
dest_ag = (dest_ag >> 16 & 0xff000000) + (dest_ag & 0x0000ff00);
dest_rb = (dest_rb >> 24 & 0x00ff0000) + (dest_rb >> 8 & 0x000000ff);
dest = dest_ag + dest_rb;
This one's approximate, and needs a 32x32->64bit multiply (usually an inline library function or some assembler). Though 0*0 = 0, and 255*255 = 255, as intended. It's actually not so obvious why this works. The short story is that it's based on the expansion of (a + b)(x + y)...

(216*b + a) * (216*y + x) = 232*b*y + 216*(b*x + a*y) + a*x

explanation )

July 4th, 2006

So I just realized what OpenCanvas is doing. It's almost bad enough to make me stop using it entirely.

Thing is, this beautiful 17" (~13"x11") flatpanel is simply too big for my 6"x8" tablet. Everything I draw is enlarged, and never fits onscreen. I can try to draw smaller, but it's quite awkward given the smoothness of the tablet pen and the urge to stroke with my arm. I would be much better served with the 12"x12", if I could ever fit it on my desk. Barring that, the next best thing is to map the smaller tablet (in painting apps) to about half of the screen.

Well OC hits a little snag here. Turns out it totally bypasses the normal tablet logic and uses raw tablet coordinates, mapping the tablet to the entire screen. This is wrong for two big reasons:

* The aforementioned remapping doesn't work, I'm stuck with fullscreen;
* My screen is 1280x1024, i.e. a shape of 5:4, and not the 4:3 of the tablet. Wacom accounts for this, but OC does not. That means everything I draw in OC is the wrong aspect ratio!!

Nnngh!

...

The fireworks were pretty decent, though. I always wanna make a screensaver afterwards, 'cause I've never seen a simulation that looks enough like the real thing. Hmm.

The people behind us were amusing, but the car alarms were outright hilarious! I never heard the fireworks trigger them before, but this time it happened with a good 10-25% regularity, and half the time I couldn't stop laughing...
In reply to http://doubletake.livejournal.com/63656.html:
(Spilled off into a rambly entry, 'cause it got so long and random that it might as well be a note to myself... sorries, I'm just grasping at straws here.)

Oh gods, I do pretty much the same thing. Maybe not on such an explicit level, but it is just as bad.

When I got my palm pilot for example, it was exquisitely easy to make memos and lists. So aside from micro-journalling and doodling and games of Rogue, I naturally took to the ToDo application.

Indeed, I soon outgrew ToDo and migrated to the heirarchical Progect, constructing entire trees with pretty little checkboxes and progress indicators, exquisitely prioritized and organized by category. Like you said, it's actually more fun making and preening the lists than checking them off!

You can guess how much got done. Nrrgh!

Another problem I have with lists is that if it's a daily thing I look at, I cringe every time I do.. soon developing an aversion to the most neglected items, and gradually, to the entire list itself. Therefore much emo ensues, and I never look at them in the end, defeating all my effort. Still, if I don't make those lists, these things stay in my mind, instead, for months or even years... which is even worse.

Day-specific schedules and todos are even more of a guilt trap. I always wound up rewriting them for the next day, and then... you know.

So what to do?? @..@

The solution advocated in GTD is actually (in part) what you're leaning towards:

  • Eliminating the expectation on a given day (within deadlines, just do the next doable thing);
  • Never writing anything down, or thinking about it (to decide whether to actually do it, etc), more than -once-;
  • Reviewing the notes and such, so you keep them off your brain;
  • Making sure the "todo items" (as distinct from "projects") are actually things you can do in exactly one step. Otherwise, if it is sufficiently complex, it will be unclear and scary and confusing, and never get done (this stalls many of my programming ideas).


Another thing to consider is that if you have undone things of "top" priority, and the world hasn't ended... reconsider the priority. Sometimes enthusiasm and/or real-world use, fade with time, and that's fine.

Also, for things like 'clean cat box', he points out it's a waste of time to write them down. If you have nothing else pressing, just do the next small thing that comes to mind. If you don't want to spend all day, you could set a timer or something. This one small piece of advice, has, if nothing else, been a small victory over my emotions, and kept my room a lot cleaner...

Deadlines might work, but of course you need good time estimation skills, and I'm bad at that. An advantage in theory is that, when in doubt, you always know what you should work on first—order by due date.

"Should" is my dirty word, by the way. The very mention reminds me that I should and I haven't yet. Ye gah.

I personally don't feel so great about the self-punishment. Basically that's because I already do it: I feel bad about putting things off, and underconfident about finishing them, which is why I put them off, which is why... d'oh! If I had the heaps of physical evidence on my desk to say "Wow! Draci's a great artist!", I might be a little more motivated. I need to like myself, first. The Shame Game is easily self-perpetuating, and anyway I have not seen myself actually follow any supposed 'punishments.'

Hm, maybe now that I'm succeeding with the diet, positive junkfood reinforcement would work better. I'm not a big sweet tooth, though. n..n And I guess I could start printing art, and putting it back up on my desk/wall.

OMG, daily art... I am perpetually forgetting. >..< How could I get a reminder? This actually is near the core of my problem. I have no 'trigger' to task-switch, and if I'm on a roll and unprovoked, will go on coding for 6-8 hours. These days, with my stressing over things-to-be-done, I just end up reading blogs and messageboards and crap. Slowly reading less, which has resulted in me pacing the house (in a proportionately greater amount) and bothering the cat instead.

Now if I could just find a way to stop stressing over all the things I *won't* be doing if I make a choice to do *something.* I don't know if there's an antidote to that, aside from a nice cold dunking.

Blah, I dunno. Time for posty, then maybe some drive-by artings. And fireworks, if I'm feeling up to it.

June 28th, 2006

OC's *.wpb

Add to Memories Tell a Friend
colorful yawning kah

Not much progress on the code front, but I did take the time to work out OC's image format for future compatibility. I haven't seen this anywhere, so I might as well put it here. This is what goes into the *.wpb's.

OC 1.1 b71 *.wpb structure )

Powered by LiveJournal.com