You are viewing tangaroa

Warrior Tang's Journal
 
[Most Recent Entries] [Calendar View] [Friends]

Below are the 20 most recent journal entries recorded in Warrior Tang's LiveJournal:

    [ << Previous 20 ]
    Thursday, June 2nd, 2011
    5:04 am
    Monday, May 30th, 2011
    10:44 pm
    Friday, May 27th, 2011
    10:07 pm
    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.

    Thursday, May 26th, 2011
    10:15 pm
    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.

    10:56 am
    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.

    Friday, May 20th, 2011
    7:36 pm
    Observing files

    kowh informs me that Linux has inotify() for this purpose. BSD has kqueue. Since the novel idea in my post already exists and has been implemented for years, I've put the rest of the post below a cut.

    Read more...Collapse )
    Wednesday, May 18th, 2011
    5:28 pm
    Thursday, April 21st, 2011
    4:40 pm
    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?

    Wednesday, April 13th, 2011
    12:15 pm
    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 Mood: nerdy
    Sunday, April 3rd, 2011
    8:57 pm
    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 )
    Monday, March 7th, 2011
    3:24 am
    Flash injection through patience and bankruptcy
    Many flash games have an ad service like MochiAds which fetches some extra flash content from the net when the program loads.

    MochiAds recently are serving up advertisements for other Mochi-advertised games instead of ads for companies that pay for MochiAds.

    So the MochiAds company is probably not doing so well.

    When a company like MochiAds goes out of business, their domain name will eventually lapse.

    Then someone could buy the dead company's domain name and serve hostile content.

    The Mochi system seems to use two domains (thx Eltima). The record for Mochibot.com expires on 09-Feb-2012. Mochiads.com expires on 21-Jan-2012.
    Tuesday, February 22nd, 2011
    9:39 pm
    About effing time

    Windows Update says:

    "Install this update to restrict AutoRun entries in the AutoPlay dialog to only CD and DVD drives. After you install this item, you may have to restart your computer."

    Been waiting for this one since the problem was autorunning CD and DVD drives, and we've gone through a few UI revisions that make it harder to turn autorun off. Now black hats will have to leave CDs around parking lots and cafeterias instead of dropping USB sticks. Bonus points for printing a music album cover on the disk (anyone know how much it costs for the equipment to do that?) and for laying down the tracks on it in addition to the data.



    Current Mood: geeky
    Saturday, February 19th, 2011
    6:39 pm
    Some simple assembly
    Good resources: Read more...Collapse )
    2:40 am
    The Facebook Panopticon, Part 6

    My dad either created a Facebook account with a fake name or he changed the name on his existing account to a fake one. I know this because Facebook is telling me to friend this account with a fake name, and I recognize his old BBS nickname. My guess is that we both used parts of our real names in our email addresses and Facebook is matching us on that.

    Earlier posts on this subject:

    1. Facebook recommends a co-worker with no apparent connections
    2. Facebook recommends my dad -- when I'm using a fake name
    3. Facebook recommends an organization that spammed my email account
    4. Facebook gives me its French version after I read Le Monde
    5. Facebook recommends pages for interests that I removed from my personal information
    Tuesday, February 8th, 2011
    5:05 am
    Saturday, February 5th, 2011
    10:48 pm
    Game review: Meritous
    The game Meritous (available from apt-get) is interesting in several ways.

    The player is in a gigantic procedurally-generated maze, like a Nethack level with thousands of rooms. A bit of fun comes in exploring, discovering the different monsters, and collecting $ to raise your stats.

    The combat interface is amazingly simple. You hold down the space bar and let go to launch an attack that hits everything in the room. Enemies don't take damage, but they either die or they don't depending on how long you held down the space bar.

    Elegant simplicity is repeated in how the game uses colour. It looks monochrome, but the game's one colour changes from blue to black due to how far the player is from a safe area.

    There are hidden items in the game, and all of them are passive-effect. Simplicity reigns.

    There's more to the game, but it would spoil it if I told you. I will say that right when I thought I'd played it out, adapted to all the monsters and discovered everything interesting, the game decided to double all the monsters' speed, endurance, and fire rate. The core gameplay may be repetitive, but the game has a few ways of making itself interesting.
    10:12 pm
    Quick thoughts on the Linux patch workflow
    Patches for a software product flow like this:

    (Core developer) --> (Distro) --> (Sub-Distro)

    Example:

    Linux Kernel --> Debian --> Ubuntu --> Mint

    The core developer produces a product and incrementally improves it. Each distributor may have its own set of patches to the product. The sub-distributors take the patched product and may patch it further.

    There are many, many, many core developers and it can be a lot of work to catalogue them all and keep up to date with their development. Sub-distros are based on the distros that already did this work.

    If a sub-distro does not keep up to date with its upstream distro's patches, any value its uniqueness may have added to the Linux world is quickly offset by its obsolescence. Consider "Bob's OS, based on Red Hat 6.2!"


    Problems:

    * If distros are lazy, the different software products offered by different distros may all claim core version number "1.2.3". This leads to confusion when the behaviour of "version 1.2.3" is not as documented. The patching vendor should change the version number to be like "1.2.3.rh-6", indicating who the vendor is and how many different patched versions of the product the vendor has released.
    * If distros fail to keep up to date with core product releases, sub-distros may go around them and release the later versioned core product themselves. The sub-distro then risks failing to keep up with the parent distro's patches if the parent catches up and continues patching.
    * If a distro in the middle of the chain slows development, those further down have to take over their work or suffer the same slowdown.
    * A distro may not notice when core development obsoletes its patches.



    Patches will also flow backwards from users, by the vendor's development of ideas offered by users and by direct development by users who are also coders.

    (Core developer) --> (Distro) --> (Sub-Distro) <-- (Customer complaints and ideas)

    The distro may then send the changes upstream. When a patch reaches the core developers, it gets integrated into the main product. Many Linux users are savvy enough to go straight to the core developers themselves.


    Problems:

    * Patches produced by distros and independant developers are sometimes not up to the standards of the core developers and are not integrated into the core product.
    * Distros have an incentive to keep their patches from their upstream in order to distinguish themselves from their competition. The GPL helps, but it takes work to dig through a distro's source and see if they patched anything.


    It is possible for a sub-distro to take patches for different products from two different parent distros. A cause for this occurring would be if the second distro's patches had a good reputation. At this point the product is forked, as that distro has become a second core developer.




    Imagine something like Distrowatch with a graphical map of distros and the distros that they are based on, a way to pull up lists of packages that differ between distros and their upstream, and a way to pull up the differences. It would be a visualization of the Linux software ecosystem. I'm not sure how useful it would be, but it would be cool to see.



    I once diffed my distro's kernel against the official kernel and there were so many changes that I wondered if anyone was keeping track of them all.
    5:41 pm
    Web security online resource

    Stanford's web security course has enough text in the projects and lecture notes to learn a few things without attending the school. There are a few tricks in there that I hadn't heard of, like a Javascript port scanner that is both badass and bloody obvious in hindsight; just make lots images load from target:port and see if they time out.

    Wednesday, February 2nd, 2011
    6:44 am
    On Egypt, Obama is fucked either way
    He backs Mubarak? The evil Americans oppress the people again and get worse relations with the Arab public.

    He backs the revolution? He's backstabbing an ally again and showing that America doesn't care about its friends.

    He sits back and leaves it alone? He's incompetent and not showing leadership.

    He draws a middle path respecting both sides and calling for moderation? All of the above.

    It's a no-win. The situation reminds me of that Mad Magazine cover showing him all stressed out.




    The above thought is several days out of date since the revolutionaries have by now won, which makes supporting them the obvious choice. I still felt it worth posting.
    Wednesday, January 19th, 2011
    6:33 pm
[ << Previous 20 ]
My Website   About LiveJournal.com