Log in

No account? Create an account
Jess The Developer's Journal [entries|friends|calendar]
Jess The Developer

[ userinfo | livejournal userinfo ]
[ calendar | livejournal calendar ]

Unicode in MFC/C++ [25 Apr 2008|09:17am]


To make strings not barf when you switch back and forth between multibyte encoding and unicode encoding....

when defining string literals:
_T("StringValue") - works always
L("StringValue") - works if unicode rather than multibyte
"StringValue" - works if multibyte

when defining string variables:
LPTSTR myString = new TCHAR[25];

when changing control values:
controlName.SetWindowTextW( myString.c_str() );

post comment

Class.forName("[S") [11 Apr 2005|08:31pm]

Whoever invented the syntax Class.forName("[S"); should be shot.
Could the "[S" be any less documented? And good luck trying to google
"["...its not an indexed character... And then it turns out instead of using
reflection to do this you could just say short[].class...Though offhand I
seem to recall there was some cool but wacky stuff you could do by adding
multiple ['s and all...but I can't find any documentation on it...so its
1 comment|post comment

Dates in Java [19 Jan 2005|09:29pm]

how to get a non-deprecated time in java...

Date dateFromMessage = new Date(msg.getTimeAsMillis());
String expectedDateString = "1/19/05 2:50 PM";

DateFormat d1 = DateFormat.getInstance();
String dateFromMessageAsString = d1.format(dateFromMessage);

dateFromMessageAsString + " == " + expectedDateString
3 comments|post comment

Doh! of the day--stupid but legal... [16 Nov 2004|03:33pm]

Interaction interaction = null;
new Interaction(
i, j, k, l, m, n, o
return interaction;

note to self: don't do that
9 comments|post comment

[13 Oct 2004|10:47pm]

I figured it out! yay. Lightweight threads using just runable run in Swing's thread. I needed to use a heavyweight thread so it'd really use a new thread....fixing that and it worked like a charm
post comment

[13 Oct 2004|12:05am]

Wow, I found today at work I actually had to remember something I nearly forgot that I learned in CSE 11 (Intro to Java) in trying to fix a problem with updating GUI items in java.

So the dilemna is basically--I have this gui with a textbox. There's a function call it makes when you press a button. It takes a REALLY long time to run (Thread.sleep(2000) calls start adding up--and I absolutely have to "just wait" to allow something I don't have control over to finish).

The problem is mainly that in the function there's printouts to stdout which show up right away and shows incremental progress. There are also incremental calls to a function that had the sole line (pseudocode) jTextArea1.appendToTextArea( new progress text). Problem is, the text box doesn't update AT ALL until the end of the really slow function and then dumps all 15 or so of my appended strings on at once. I want it to start updating the GUI right away like it does on standard out.

I moved the call to the really long function into a thread. That fixed it a little. With that addition it prints "starting test" and then doesn't update the textbox again until its done. And I set the thread priority to lowest in hopes that it realizes that the really slow function is less important than my gui.

Then I remembered there was this great function called repaint()...maybe I need to use it? No, remember that game program we did in CSE 11? You need to use paintImmediately() or your gui update doesn't show up in real time. So I add a call to paint immedately, and presto, the box almost immediately prints a screen full of text.

The only problem is I'm printing a *lot* of stuff to my big text box, so much stuff that after 2 seconds of execution, you're scrolling like a madman to keep up. Only problem is, paintImmediately doesn't update the scrollbars and it doesn't respond to cliccking on the scroll bars until the entire really slow function is done processing/waiting. Adding a Thread.yeild() right after calling the appendToTextArea() and repaint() doesn't really seem to cause any change.

Bahhh, threaded programming is so complicated. I haven't figured out yet how to fix this...maybe I'll spend some time tomorrow figuring it out (hopefully). If any of you out here in livejournal-land have ideas on things I should look into or try, I'd be happy to hear them...and if not, well, Google's still my friend ;-)
post comment

My Computer Loves Me [30 Aug 2004|06:00pm]

My computer at work has developed a "fun" new hobby to keep me from getting
"real work" done. It spontaneously dies such that the monitor goes out and
the keyboard stops responding, and the only thing that you can do is cycle
power on the machine (no, it doesn't even have a reset button/hole cuz its a
lame machine like that). Event log shows nothing to give any hint as to
which hardware is bad, but it definitely seems to be a hardware thing and
not software.
1 comment|post comment

[05 Aug 2004|11:12pm]

I think I scared myself, when in normal conversation(and by normal, I mean normal for a software engineer), I used the word OBERON. Yep, that's right. And not only did I say it, I was complaining that Java is not more like Oberon.

"If only Java allowed nested comments like oberon..."

Because, as it seems, Java does not appear to have any embedded language features that let you quickly and non-destructively comment out a large block of code which includes /* c style comments */, function headers, and does not necessarily compile where you are teleporting it to. If it were C, I could just add a #if(0) around it. Two short lines, and the entire function is commented out, non-destructively.

The only way I've successfully commented out entire functions is the macro and/or search and replace beginning of line technique to slash-slashify every single line. But that's ugly ugly. ESPECIALLY when the file already contains //ified code, which is NOT my doing...and you can't tell them apart. So then you start having to do something really ugly like //JRW// as the prefix for each line. Couldn't I just if-zero it all out of my hair? I don't want to be spending my time right now figuring out what includes I need, and what to do with these paramaters, and local variables I don't have here...

or if only you could do nested c-style comments like oberon. (* cuz comments like this (* could be nested and *) that made everything happy, cuz you could comment out code with comments in it...and easily and cleanly... *)
4 comments|post comment

I came across this at work reading some documentation.... [07 Apr 2004|09:08am]

Q: I need to program ISD chips with prerecorded audio files in exact
locations. How can I do this?
A: ISD/WINBOND no longer makes programmers for our products.

Taken out of context that just is amusing... Awww, shucks, you don't make
engineers anymore!?!?...you know, once the Govt cracked down on our
Cloning/DNA research department it just wasn't economically feasible to
breed programmers... ;-)
1 comment|post comment

[23 Mar 2004|09:46pm]

This is lame...maybe because I don't understand it...

so I had this definition:
typedef struct {

but it was getting garbage data in "day of month" because the
EVENT_SUBCODE was something like 12423 that just should
NOT fit in a BYTE.

So then, obvious fix, right? Just add the bit-field sizes, and everything
should be hunky dory, right?

typedef struct {

well, not quite. If you do that, then where I was trying to use the event
subcode field I was now getting a compile error on this line:

Accept_Event( (const void *)&miles_event->EVENT_SUBCODE, FALSE);

But if you make a local variable and copy the value out of the struct, and
pass that
copy into the Accept_Event method, suddenly it all works again.

So my question is...What's so different about adding the :8 to the type
that you can't make a void pointer to that field of the struct and use that
as a
parameter to a function? Its still just an address in memory, and that whole
BYTE struct is just an overlay over an incoming byte stream to make it
to get to specific data in the byte stream...its not like there's some magic

goin on here.

**If it makes any difference, the type in reference
was just a typedef that looked something like this:
typedef enum {
[...more values...]
/* 57 - 254 reserved, not used */
5 comments|post comment

Quick Question [23 Mar 2004|09:53am]

As applicable to the language c...
I have a global variable, sft_realtime_event_msg, which is a byte array declared as such:
BYTE sft_realtime_event_msg[] = {
now at some point in the code i want to "reset" or "reinitialize" the array back to that
exact list of values. What would be a simple way to do this? I could conceive a way
to do it using memcpy but that'd require me to declare a second variable to hold all the
values ot reset to. I don't want to have to assign each byte individually
like sft_realtime_event_msg[0]=AA; sft_realtime_event_msg[1]=AA; ... cuz that'd be
really cumbersome.
3 comments|post comment

Visual Slick Edit Rocks [25 Feb 2004|10:42pm]

[ mood | enthusiastic ]

Visual SlickEdit is becoming more and more my favorite code-editing ide. customizer's heaven. yeah, for being a $300 editor it better be a good editor right? ;-)

to put this in perspective, yesterday i was talking to Don, and he was saying i should put a phrase in all my comments about unfinished parts that i can search for to find them later--he uses "TestCode -" for his comment lable. So I was saying, Ohh yeah, i usually use "TODO:" just force of habit from having used visual studio long enough, and it has that cool little feature that every comment that starts with TODO: goes into this little todolist window that has clicky links to the lines with your todos. Its too bad SlickEdit doesn't have that feature.

So then today, unrelatedly, I'm sitting ther trying to write a macro to slash-slashify comment out/uncomment massive hunks of code and having a hard time with a bizarre error on the uncomment macro i wrote, so i went to the website for slickedit to see if they had any tips or example macros or anything. And boy did they, in their macros section, they had exactly what i wanted already done and working, as well, as you guessed it, a macro to do a visc++ style todo list window--which i proceeded to modify cuz i wanted it to take up less screen space with the window it popped up, but it works like a charm! yay, the one thing i missed from visual studio i now have. plus i also have cool macros like one to align columns of text so that your typdef structs look all pretty with all the assigned values lining up in an obsessively spaced perfectly order. and i put comment out on my right click menu. and i also got this cool macro to copy the selection to the end of a scratchpad type window to keep typedefs and message structures handy, quickly. oooh, this all is soo... *useful*. Ohhh, looking forward in that nerdy way to playing around with that more.

Also rearranged the toolbars and customized the menus a bit. added a toolbar button for my new todo list macro, and i think i want to redo some of the bmp's for a few of the ugly toolbar buttons to prettyify it, just cuz i can and itd be more aesthecially pleasing :-)

so yeah, i'm a nerd, cuz finding this cool stuff for my editor totally made my day =)

3 comments|post comment

this just cracked me up...and i figured...you nerds would appreciate it =) [21 Feb 2004|12:29am]

[ mood | amused ]

http://www.tenyearsofmylife.com/2004/02/15/ (click link to see picture)

HTML considered harmful to airport terminals
February 15, 2004
I was cracking up the other night when I walked past this monitor in the SFO terminal. I suppose airport info is xml fetched from a database somewhere, and that from time to time they have errors in the HTML conversion like this.

I always thought that United's redesigned arrival/departure listings looked slick though I had no idea it was just rendered HTML until now.

9 comments|post comment

cleaning off the hard drive [28 Jan 2004|09:38pm]

and on the old c drive...i found the remnants of the previous c drive...cairo. and inside that was the remnants of the last of two other windows installs that got reformatted over. and just for posterity's sake...before i delete the folders of the remnants of the partions, i thought i'd record the names i once picked for my hard drives.

past hard drive partition names:
cairo (c)
panda (c)
sparkle (e)
delta (d)

current partition names:
argo navis (although this will probably change when i reformat the drive and copy everything over from either c or d...just haven't decided which is being replaced or whether i want it all down to one drive, and have to reinstall window and apps to do that)
1 comment|post comment

[12 Oct 2003|03:09pm]

Opera is being retarded right now. Sometimes when I click the links on pages, it just won't respond unless I say open in a new window--like when I click the "full update" link from the update link on LJ. Irritating. Buggy. Weird. Guess I can add that to the "reasons I don't use Opera that often" list
4 comments|post comment

[01 Sep 2003|02:45pm]

i think internet explorer needs a setting like "do not allow font size to be less than x pt"

that way I could let websites pick whatever the fuck font size they want, but when they pick 7 pt verdana cuz it looks "cool" and microscopic, it wouldn't cause eyestrain to try and read it since it would cap font size customization by the webpage to not allow smaller than my minimum legible font size.
11 comments|post comment

[25 Aug 2003|06:37pm]

I keep getting these spam messages from aol postmaster telling me that messages I didn't send are bouncing. Most of them seem to involve mail.varsityent.com

duddde, its getting annoying. I mean, I set up a filter to delete it from the server, but I can't figure out why I'm getting these bounced messages or whether there is a way to get them to be never again seen by my mail notifier.
3 comments|post comment

[14 Aug 2003|07:12pm]

once upon a time, back when computers were slow and memory was scarce, someone had this ingenious idea of how they could make their computer boot faster: add some delays!

now offhand this sounds rather stupid, but considering where the user was coming from it was actually a very good idea. so the reasoning was that there's a lot of programs in the startup group, and since the computer is trying to start them all simultaneously, it spends more time doing disk paging loading things into memory and then swapping them out to disk so it wouldn't get anywhere and would take forever to load. So this guy thought, if I load the programs sequentially, it will reduce paging and that will make the overall bootup much faster.

So then, once upon a time, software engineers started writing little utilities that you could give a list of programs to along with the delays desired and it would time delay their startup, and then quit after it starts up everything.

Now where oh where did all those programs go? I can't think of the right search engine keywords to find some shareware or better yet freeware type program that will still today do that same job, just for other evil nefarious shenanigans of my own contrivances.
1 comment|post comment

[07 Aug 2003|07:33pm]

is the current newest version of opera better than version 6.03? why or why not? would you suggest upgrading?

my biggest hangup about opera is that despite all the cool features like javascript and pop up toggling, it renders pages like shit. Like it doesn't get the hang of "underline links in whatever color the link is" and does some crummy alignment. But maybe some of those problems have been fixed?
8 comments|post comment

[25 Jul 2003|09:59am]

i feel like such a nerd.

I'm working on the laptop...well, sorta. I plugged in the usb keyboard and mouse, and hooked up the big monitor... so I got all this extra screen space and stuff.

The nerdy part comes in when I start hearing a punk voice singing the line "California here I come" and made me think back to how just last night I was talking to chris and it came up that traditional song "california here i come" cuz like angel island day camp's theme song was almost a parody of it.

But anyway, this song is not the same one, but I just hadn't ever heard this song before and I had no idea what the artist and song title were in case I wanted to find it again. New download perhaps?

So what do I do? The monitor for the desktop is plugged into the laptop, and the spare monitor isn't plugged in because both power strips by the computer are full. The song only has a couple minutes left before I loose it and won't be able to see what winamp calls the song.

so I vnc into the desktop...sitting at my friggin desk. Actually I've even typing this entry through vnc cuz I'm using semagic on the laptop to type another entry at the moment. vnc is pretty speedy with two computers connected directly by a hub....now if only it would refresh good and not leave little portions of the screen rendered incorrectly.
4 comments|post comment

[ viewing | most recent entries ]
[ go | earlier ]