TheJach.com

Jach's personal blog

(Largely containing a mind-dump to myselves: past, present, and future)
Current favorite quote: "Supposedly smart people are weirdly ignorant of Bayes' Rule." William B Vogt, 2010

Flex XMLList Set Intersections, Unions, Differences

Here's some code I wrote recently I felt like sharing with the world, just because. Consider it public domain, no warranties, guarantees, etc. Don't know how it will work with XML with children. (Actually it works as expected. These functions and some array-versions I implemented have been quite useful.)


// The following XML set functions are not implemented with efficiency in mind;
// probably best not to use them for large sets.

/**
* var l1:XMLList = new XMLList('<user name="bob" /><user grade="4" name="alice" /><user name="susie" />');
* var l2:XMLList = new XMLList('<user name="alice" grade="4" /><user name="frank" />');
* trace("diff: " + CustomFuncs.XMLdifference(l1, l2).toXMLString());
* trace("union: " + CustomFuncs.XMLunion(l1, l2).toXMLString());
* trace("intersection: " + CustomFuncs.XMLintersection(l1, l2).toXMLString());
* trace("symm diff: " + CustomFuncs.XMLsymmetric_difference(l1, l2).toXMLString());
* (Output:)
* diff: <user name="bob"/>
* <user name="susie"/>
* union: <user name="bob"/>
* <user grade="4" name="alice"/>
* <user name="susie"/>
* <user name="frank"/>
* intersection: <user grade="4" name="alice"/>
* symm diff: <user name="bob"/>
* <user name="susie"/>
* <user name="frank"/>
*/
public static function XMLdifference(list1:XMLList, list2:XMLList) : XMLList {
// list1 - list2 = set of nodes in list 1 minus any that also appear in list2
var diff:XMLList = new XMLList();
for each (var node:XML in list1) {
if (!list2.contains(node)) {
diff += node;
}
}
return diff;
}

See Full Post and Comments

The Perfect Ones

This is a short story I wrote for a class assignment in 11th grade (I think it was to write a Canterbury Tale) that a friend recently dug up to remind me about. She says she likes it, so I'm posting it here unedited. I think it's okayish. I may go back to this world and do a Part Two. Note that while I still share a significant number of the underlying views presented here, my 11th grade self (only a few years ago too!) is almost a completely different person to me now.




There once was a country, larger than any, full of people of all sizes and colors and opinions. The ruling force was well-begun, but by this time the whispers and shadows of its crumbling were near certainty for a large group of people. These people gathered together, discussed the situation, and debated on a course of action. War was no solution, for their country possessed the mightiest troops and machines designed for a hundred years with the sole purpose of killing in masses. Yet nor was a passive resistance the answer, as the government had suppressed many uprisings in the past (with rebel forces far outnumbering their own) and the general population was so deceived and mindless that they did not give a second thought, if they heard of it at all.

See Full Post and Comments

Eminem's New Album Rules

Just throwing that out there. Recovery wins.

I don't even think I have a really favorite song from it, either, because they're all such great tracks. I think I can make a list of my favorite five, maybe, but among those? Not sure how to rank them. I think this is a mark of a great album; with Relapse, Beautiful was clearly the best song, followed by Underground, and the rest were good but not fantastic.

Also, yay flac files!

See Full Post and Comments

Enjoy it!

Why all the focus on "live life in the moment, 'cause tomorrow you may die!"? Or "Enjoy it while it lasts!"? Why not simply live life, sometimes in the moment, and why not simply enjoy it? Why should something have to end in order for you to appreciate it more?

Of course it's not necessary, and humans have no problem whatsoever with valuing "everlasting" things. I can find some stories about valuing old trees if necessary, but surely everyone can see it?

Life's great, I don't know why people have to use death to justify its greatness. And in the end it just makes us rationalize it all the more when one of our number decreases, some people going so far as to suggest it's a good thing. It boggles my mind.

See Full Post and Comments

Role Playing Is Like Chess

I started doing online role playing roughly 6 or 7 years ago, though for the past 2 years at least I've been on an RP hiatus. I just lost interest, and I lost contacts with people. My primary source of RP has always been Furcadia (before you ask, no I don't consider myself a furry and don't think yiffing really constitutes RP), in addition to the once-in-a-blue-moon forum RP or quick session in an IM window.

Anyway, I did an RP earlier tonight that lasted a long time, and it was fun, interesting, cool. I'm using a classic character I've had for years, but I'm re-inventing him in some aspects and giving him at least temporary oddities such as communicating through metaphors, symbols, and examples. (It's fun to think that way.)

And I realized: RPing is fundamentally quite simple. You put yourself in situations, and write about it with other people. The nature of this makes pretty much every RP unique in many respects, even if there's strong similarity at some points or there's an overall theme. So this is a lot like Chess. Chess is fundamentally simple, you only have a certain amount of pieces with a certain amount of valid moves. But while each game may have similar openings and other aspects, they nevertheless tend to be fairly unique. And fun, interesting, cool because of it.

See Full Post and Comments

Why I Sometimes Really Dislike Java

I don't hate Java, but the formalities really annoy me sometimes. And I wrote this code, so I don't hate it at all. (Well, the XML design wasn't mine, and it will be refactored.) Anyway, this is why. Mainly just the first line.


Map<String, Map<String, Map<String, Map<String, String>>> > meta_data = new LinkedHashMap<String, Map<String, Map<String, Map<String, String>>> >();

while (rs.next()) {
int c = 1;
String type = rs.getString(c++);
String schemaName = rs.getString(c++);
String name = rs.getString(c++);
String col_name = rs.getString(c++);
c++;
int col_len = rs.getInt(c++);
boolean is_null = rs.getBoolean(c++);
String data_type = rs.getString(c++);

See Full Post and Comments

Is Environmentalism a Religion?

I heard an interesting argument in this vein today, and I want to explore it. So first of all, let us be rational about this, and determine what it is we mean by religion. That is, picking two concepts such as Environmentalism and Christianity, what criteria can we select to promote either of these two concepts to "religion-hood"?

First, however, I must make it clear what Christianity and Environmentalism are, or rather what their members are. Christians are anyone claiming to be such, which includes Mormons and fundamentalists. (It doesn't make sense to call a Muslim "Christian!", so what a Christian is should be left to who declares themselves one.) Now, who constitutes an Environmentalist is a trickier notion. Are hippies environmentalists? Are people who just care about not destroying the environment, environmentalists? (That is, people who would vote to nationalize a Park but don't have any moral issues about chopping down trees for paper (just not all trees!).) For the purposes of this post, I think I'll pick Al Gore as an example of environmentalism, and consider hippies on a similar level as I consider fundamentalist Christians.

Now I will make my list, and briefly mention how Christianity and Environmentalism do or do not fit the list. The Black Belt Bayesian has, fortunately for me, created most of this list after accusation of the Singularity being similar to a "Rapture of the Nerds", which, upon examination, is absurd. So, let's discuss Christianity and pull out criteria that we might use when classifying Environmentalism as a religion. I'll start off with BBB's list.

See Full Post and Comments