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

Can your SQL database do this?

New to LucidDB-dev (and soon 0.9.4) are a handful of scripting modules that support many different languages, such as Jython. Writing code in Java and loading it as a JAR in LucidDB is fun, but cumbersome; thanks to the standards in Java 6 though one can use JavaScript (bundled with Java) or, my preference, Python. As a fun example, let's grab a list of tweets to insert!

There's a Python twitter client here: http://code.google.com/p/python-twitter/ whose dependencies are easy to satisfy. (For Jython, see http://old.nabble.com/Easy_install-on-jython-2.5-td23525500.html for getting an "easy_install" on Jython to get the dependencies.) Just run the Jython's easy_install with "oauth2" and "simplejson" as arguments, and then run jython build.py install inside the twitter client's download folder. If you're good to go with Jython, go get a dev version of LucidDB. Make sure you add your Jython JAR to the classpath.gen file before starting it! For me, that's /home/kevin/jython2.5.2/jython.jar.

There is a caveat here: because we're relying on packages in Jython's site-packages folder, and because we're using the jython.jar in a ScriptEngine behind the scenes, we have to load the sys path ourselves. Fortunately this is done by adding the code import site to our Python, which the standard Jython does behind the scenes by itself.

See Full Post and Comments

Hello Unicode!

I introduce you to a cross product of A×B! Or something.

Anyway, my blog now officially supports unicode. That was fun! Or not. My blog is programmed in PHP, and as anyone who's done much PHP knows, nice Unicode handling is a far-off dream in the magical PHP 6. Python handles unicode so much nicer... To convert a code base in PHP to unicode, there are a bunch of functions you have to change and watch out for. Luckily this isn't too tedious as most of them are string functions, and with some clever scripting we can find all the spots in the code that need fixing up. (I also thought about some scripting to do the replacing for me, but I didn't have that many and I like to verify things manually sometimes.)

First up is a helpful guide: http://www.phpwact.org/php/i18n/utf-8 You should definitely skim through that before starting any unicode conversion project, as there are quite a few things you have to worry about. For now, let's get a list of all the string functions we need to change.

See Full Post and Comments

Against explaining to grandmothers

The phrase "explain it so that my grandmother could understand" is horrible. Did your grandmother spend the last decade thinking about Fermat's Last Theorem too? (Mine didn't.) If not, then sorry, I don't think Andrew Wiles could explain his 100-page proof to her--he'd be lucky to explain it to a graduate student of mathematics.

The use of the phrase always seems so condescending, as if all complicated topics are so easy to understand that they can be explained to a random grandmother in a few minutes. When someone says this phrase, it's frequently code for "I don't understand the words coming out of your mouth--could you use less jargon?" But saying it flatly admits ignorance, and we monkeys can't have that--it'll lower our status! Especially if we're interviewing someone who is supposed to become a good subordinate if accepted into a position--we can't have someone smarter than us!

It's a weird exchange when the inferior (in the immediate sense) member of a pair is the one being condescending. It's a proud display of ignorance, a rude display of ignorance. Personally, I think rudeness should be restricted to those who have something to be rude about--e.g. the person who is trying to explain something while avoiding all the jargon-words that he's taken for granted 8 hours a day in his school or work. Phrases like "My grandmother could understand this!" or "My grandmother's dog already understands this and has moved on." are used by those in the knowledgeable position trying to teach, as a way of being rude as well as trying to say that the topic isn't so hard--any fool can learn it given the time.

See Full Post and Comments

The FFP Machine Implemented With An FPGA

Edit: If you're interested in reduction machines for functional programs in general, especially ones that work and have had three years of development as opposed to three weeks, checkout these guys: The Reduceron.
Edit 2: Also check out this Non-Von Neumann computer!

As I previously hinted, I worked on an FFP Machine recently for a school project. Unfortunately I only had about three weeks to work on it (along with everything else going on), so that time was largely spent just understanding the FFP Machine, and I didn't get very far in the code. (The code referenced in the paper to download doesn't even compile to Verilog yet, and I've actually scrapped what's there in a new project that I'll share if I work more on it. Also, the school won't have copyright over the new project.)

So my paper is largely a summarization of what the FFP Machine is and does, along with a collection of the best resources I found out there in case you want to learn more. I also may convert parts of it into a Wikipedia page since once does not currently exist for the FFP Machine. If you have any questions (or want any of the papers in the sources) feel free to email me (see the About page at the top), though I can't guarantee I'll be able to help. Anyway, below is my Paper in HTML form, for the benefit of Google and for my own word-count tracker. If you want to read on, I highly recommend reading the PDF version outputted from LaTeX. It is uploaded here.

See Full Post and Comments

Selfishness is clever

There are at least two groups who play with Selfishness in a clever way, and those two groups are evolutionary psychologists and objectivists / Ayn Rand followers. I say it's clever because it's like playing with a set of math theorems and seeing what some consequences are, it's like trying to put together a puzzle with all the pieces being more or less the same yet different enough that you can't arbitrarily place them.

In evolutionary psychology, it's a given that genes are selfish, and our genes determine what we are and set the limits on who we can be. (The human brain is very malleable, so those limits aren't always clear in humans but they're nevertheless there.) So we look at human universals like altruism, a sense of justice, honor, trust, guilt, friendship, sympathy, suspicion and hypocrisy, and many of these things defy explanation if you can only think that "everyone is out for themselves."

The long-standing explanation for these traits is based in Kin Selection, which in a nutshell (I recommend reading the linked paper or Robert Wright's The Moral Animal) is the idea that kin have more or less the same genes, and when a gene arises that increases the likelihood of altruism (through yelling a warning cry when a predator is spotted for squirrels and possibly sacrificing itself, or through sharing a banana), the individuals most likely to benefit from that altruism are closely related and may have that gene as well. Hence the genes still propagate and are selected for; the benefits to an individual's kin who share the gene outweigh any individual loss from the altruism that might make that individual lose out in the gene pool normally. This doesn't mean that conscious altruism goes away, or that conscious minds are therefore automatically entirely selfish, just that at the gene level, which is all that matters to evolution, high-level altruism got there from a low-level selfish process. The mechanisms of an altruistic brain are altruistic: altruistic people will feel like they're being altruistic, others will call them altruistic, and for all intents and purposes they are altruistic. At the gene level this altruism is a selfish benefit for that person's (and likely their kin's) genes.

See Full Post and Comments

A Fun, Dirty, Computer Engineering Comic

CE Comic

Horrible joke I know, and I suck at drawing, especially "anatomy". Computer Engineers have a trick to convert a bunch of resistors in a delta (triangle) formation to a Y (three prongs) formation and vice versa, and with that trick one can reduce the "hair circuit" shown (that some people apparently call a Christmas tree since it contains both a delta and a Y) to the nice single-resistor trim.

The "Christmas tree" appears in Giancoli, because usually Computer Engineers don't have to deal with it, and Giancoli's "solution" is to write down several equations of Kirchhoff current and voltage laws to reduce the circuit. Yuck! Here is the diagram, they want to know the equivalent resistance between points A and C.

See Full Post and Comments

10 Random Facts

Cross posted from my dA account, here's some blog filler so I don't feel like I wrote nothing this month. Also this will add my word-count score.

----

I just tried to read the same thing six times and still didn't parse it, so instead of going to sleep I'm going to do this instead! Tagged by :iconTechnologic-Skies: here are Teh Rules:

See Full Post and Comments