thinking

Note dump: Scraps and debris, part 2

Since the ACM Programming Competition allows schools to send multiple teams that can earn different scores, I wrote a script to produce "average" scores per school. SSU usually places in the middle of all of the schools, but both of SSU's teams got crushed in 2010, giving the school an overall second-to-last place finish by my formula. Did everyone spend the night before partying or something?


Could mutexes be a language feature? Imagine a language where "mutex" is a keyword and mutex name { BLOCK } would cause the compiler/interpreter to add whatever code is necessary to create a mutex with that name over that block of code.


Some fun C++ errors:

xReader5.cc: In member function `bool nodeReaderContext<cxEnumType>::operator==(const nodeReaderContext<cxEnumType>&) [with cxEnumType = e_nodeReaderContext]':
xReader5.cc:33: error: passing `const nodeReaderContext<e_nodeReaderContext>' as `this' argument of `const cxEnumType nodeReaderContext<cxEnumType>::getValue() [with cxEnumType = e_nodeReaderContext]' discards qualifiers

The getValue() function doesn't dirty any value. It is simple enough that I defined it in the header:

virtual inline cxEnumType getValue() { return value; }

The solution, by way of some more IBM documentation, is to add a "const" in a place I've never seen a const placed before:

virtual inline cxEnumType getValue() const { return value; }

This turns the "this" pointer into a const for this function.


Now for the next compiler error. I have the .cc file define a cx_Scanning class derived from class nodeReaderContext that calls its parent's constructor.

class cx_Scanning : nodeReaderContext{ cx_Scanning() : nodeReaderContext(V_SCANNING){ ; } string toStr(){ return "Scanning"; } };

This produces the error message:

xReader5.cc: In constructor `cx_Scanning::cx_Scanning()':
xReader5.cc:41: error: class `cx_Scanning' does not have any field named `nodeReaderContext'

nodeReaderContext is the name of the parent and the parent's constructor, not a field or member of either object. The solution to this one comes from blind experiment. It turns out that I had to add a template to the part that calls the parent's constructor:

cx_Scanning() : nodeReaderContext<cxType>(V_SCANNING){ ; }

That solves whatever problem the compiler was having.

thinking

Note dump: Scraps and debris

More stuff found while cleaning old files:

Perl acquired bignums and smart string/int conversion. I had written an introduction to perl using these two examples:

my $million = "1" . "0" x 6; # Produces the string "1000000"
$million += 1; # Results in "1" because the string resolves to zero.

As of version 5.8.8, it produces "1000001".


One of the reasons I left my job a few years ago was that I was spending so much time supporting the call center -- after three of the employees left and were not replaced -- that my share of activity in the ticket system went from 5%-10% to 20%-30%, and I was only working half-time.


There was a movie a few years ago that had a good marketing campaign. It was going to be an entertaining review of advanced physics and of the mysteries that scientists are finding at the frontiers of modern theory here in the first decade of the 21st century, all explained in a way that normal people could understand it. I was taking a physics class at the time, and the teacher assigned us extra credit to see this movie that was supposed to be the best hard-science documentary since Sagan's Cosmos.

Of course, What the Bleep Do We Know!? turned out to be New Age bullshit. Here's a long takedown of the movie.


Here is a feature I suggested for a space-based video game that another student was developing.

Let's say we decided to make heavily populated systems with planets and features all over the place. The Sol system might have all of the nine or eight or sixteen planets or whatever it is now plus several of the major asteroids, Luna, Titan, and Jupiter's four major moons. Not all of them would offer interactivity, but they would be visitable and a scanner might return interesting reading material. There might also be starbases all over the place.

So, now we have this hugely populated system and we have to spread everything out to keep it from getting too cramped. Pluto is now very far from Earth in terms of game time. It might take a minute to get there! We can speed it up with some kind of autopilot system. You're on autopilot, you go fast.

We could merge this autopilot with a visual effect whereby if the ship is far from anything else, everything else zooms out. You see, you're in space and that stuff is falling back into the distance. The player's ship remains the same size and appears to travel at the same speed, but it covers more space. When you get close to a planet or an asteroid field or a ship that you want to interact with or vice versa, the view zooms back in as you get closer. Call it the "superman effect".

I think I've seen this in a game before, but I can't recall what it was.

"Superman effect"? That was a horrible way of explaining it. Essentially, I wanted to see your ship speed up when you went into an open area, coupled with a smooth dynamic zoom-out of everything but your ship, and you would cover the same number of pixels per second whether you were zoomed in or out.


I made a website for said game project. While it gave me a sense of accomplishment at the time, I looked at it again and gah it's ugly! It looks like it was made in 1995. That's why I'm a backend guy and not so much a frontend guy. I should have spent the time to make rounded corners and transparent backgrounds so it would look like it was made in 2001.

The site is busted since the apache configuration changed to disallow mod_rewrite in user directories. This is the second site for which this has happened to me. Don't rely on mod_rewrite if you don't admin the system yourself or unless you can point to it in a list of supported features.


By some combination of NFS and my working on the same files using two accounts on two hosts at the same time, I changed the ownership of one of my directories to another account that I no longer manage. Oops!


At one place I worked, I was hired twice. The first guy to hire me was my immediate boss. The whole contract was one to three sentences on a mostly blank piece of paper. It looked good, so I signed on. However, I then learned there was a parent company I had to deal with. The parent company's personnel duties were outsourced to a company in Texas, and I had to agree that this company in Texas could fire me for any reason. I also had to sign a non-compete clause that would be in effect for a year and a half after I left the job.

I still signed on despite the bait-and-switch. The terms weren't that offensive and the pay was excellent. At least I was not an hourly "independant contractor", and there was no arbitration clause.


Hint to anyone making a web page based on any non-HTML document; If you make edits to the text like spelling and grammar fixes before posting it, don't send back diffs or a plain English explanation of your changes. Send back a modified file in the original format that it was sent to you, or else the next version you are sent will have the same spelling and grammar errors.

thinking

Note dump: asm and what does -O1 do?

I'm cleaning out files and found these half-written notes. See also earlier: some simple assembly


useful assembly links
http://www.penguin.cz/~literakl/intel/intel.hmtl
http://jsimlo.sk/docs/cpu/index.php/jz.html

The first difference between -O0 and -O1 is that -O0 starts with pushq %rpb followed by movq %rsp, %rbp and -O1 doesn't. -O1 immediately starts with movqs from registers onto the stack, including extra registers %r12-%r15 that -O0 does not seem to be aware of.

Interesting: this link lists registers B and r12-r15 as preserved, while r8-r11 are "scratch registers". Definition of "scratch registers": "their contents should be considered (from caller's perspective) clobbered after a function call".

Lawler lists ESI and EDI as "scratch registers" that you can use for any purpose. They seem to have been imagined as "index registers" that contain the offset from an address in another register.

The -O1 code also uses more branching and is hard for me to follow. In a diff, there are few parts which are not changed.

A list of flags turned on by -O1, from man gcc: Long story short: no single flag made any difference to the asm sourceCollapse )

so it's not clear what caused the use of the new registers and all of the code rearranging. It must have been an undocumented flag or a combination of several of the above.

Differences between -O0 and -O1:

-O0 runs push %rbp followed by followed by movq %rsp, %rbp and then subtracts $32832 (2^15+64) from the stack pointer %rsp. It does not use preserved registers %rpb, %rbp, and %r12-%r15.
-O1 copies all of the preserved registers %rsb, %rbp, and %r12-%r15 onto the stack before subtracting $32856 (2^15+88) from %rsp.

-O0 has a leave instruction, which I assume undoes the first two instructions of pushq %rbp and movq %rsp, %rbp.
-O1 does not use a leave instruction. I assume it restores %rsp and %rbp on its own.
(Note: I once tried coding a very small assembler program without leave or those first two lines, and it crashed. Will have to try that again.)

-O0 uses cmp $0, %reg and je to test for zero.
-O1 uses test %reg %reg (itself) and je to test for zero.

-O0 moves function arguments to the stack at -32792(%rbp) through -32812(%rbp).
-O1 moves function arguments to registers %rbp, %r12d, %r13, and %ebx. This cuts down on the number of lines of code because there are fewer movls to and from the stack.

-O0 allocates space for a variable and sets it immediately.
-O1 waits until the variable is first used.


Concept for a renaming tool.

#pragma RENAME $varname %eax

Operation:

  • Parse the next line containing that register.
  • Determine which register is modified by the instruction, if any.
  • Go forwards until the target register is modified again, renaming the register to a variable.
  • If the register was not modified on this line, also go backwards until the target register was last modified; and rename that line.

Result: Your viewer can display registers as variables named $foo, $bar, etc, to make assembly code easier to read. Changing them back to registers for assembly is done in the same way. The difficult part is determining "is modified" when jumps are involved. If it is assumed that any jump outside of the original range could modify any register, the tool would be little help for reading the spaghetti code produced by -O1. This idea might only work for code that is already cleanly written.

thinking

Phone oddity

Someone called on the telephone asking for me. When I answered and identified myself, they said "sorry, wrong number" and then hung up after I asked "who is this?". So they were looking for me and ran away when they found me.

It sounds like somebody shady was verifying information about me. Are there any specific scams that I should be on alert for?

thinking

HTML 6 wish list

I had another nifty thought about where I think HTML6 ought to go, so I'll add it to that "spec" that I spilled some of my thoughts onto earlier. Call this Tang's Awesome Markup Language version 0.002.

Major changes from my last post:

  • New "aka" attribute replaces proposed "define" node.
  • Added idea of "src" attribute merging retrieved contents into the current tag... and removed it.
  • Added idea of copying Docbook's nodes for HTML.
  • Renamed proposed "span" and "block" nodes to "a" and "div". I'm trying to strike a balance between building from the current standard and intentionally throwing it all out and falling on the side of ease. It's difficult. Expect v.0.003 to change "div" back to "block".
  • Sections have been reordered and renumbered.

And I still haven't gotten around to properly reading the HTML5 specs. TODO, TODO, TODO...


Read more...Collapse )

And that's that so far.

In the spirit of the the HTML 5 Boilerplate, I present the HTML 6 Boilerplate. This should be everything you need to create an HTML 6 web page:

<html version="6">

</html>
  • Current Music
    Pearl Jam - Do the Evolution
thinking

Urgent minor pension reform

I recently become aware of a most "urgent" issue that is "necessary for the immediate preservation of the public peace, health, or safety" -- one of them, no one is sure which -- of the state of California. Governor Jerry Brown proposed a few minor reforms to the state pension system. What makes these reforms so urgent? The reforms can apply to the upcoming fiscal year if he says they're urgent and the Legislature passes them. It's a little bit of unprincipled legislative trickery for The Greater Good.

There are seven proposed reforms which I'll list followed by my five-minute analysis.

Read more...Collapse )