Syzygy

Tuesday, February 7, 2012

Why I hate programming (part 4 of n)

back to R:

1. Writing some code, seemed a bit slow, looked to stack overflow for help:
"First of all, for anyone who hasn't seen this yet, I strongly recommend reading this article on the r-wiki about code optimization."

status of link: dead
reason: R's wiki page is dead

2. Populating a matrix from a vector. (In R, a matrix is different from an array is different from a vector.)

vec <- 1:9
mat <- as.matrix(vec, nrow = 3, ncol = 3)
# mat is 9x1 (silent fail on invalid arguments nrow and ncol)
mat2 <- matrix(vec, nrow = 3, ncol = 3)
# mat2 is 3x3

3. How big is my vector?

vec <- 1:9
mat2 <- as.matrix(vec, nrow = 3, ncol = 3)
nrow(vec) # NULL
nrow(mat2) # 3
NROW(vec) # 3
NROW(mat2) # 3

Labels: , , ,

Wednesday, March 2, 2011

bibtex & capitalization

It seems that most of the default bibtex styles convert all non-first letters in titles to lowercase. This is problematic, since of course many papers have proper nouns (e.g. locations, species, named concepts) in their titles! Rather than go through and attach braces "{}" around all letters that need capitalization preserved, it makes more sense to edit the bibtex style file (*.bst) to preserve the title:
If you prefer to edit the bibtex style (.bst) rather than the bibliography (.bib), you can search for occurences of change.case$ in it. This is the function that capitalizes or title-izes fields that are not people names.

Typically, for the title field, you should find something like title "t" change.case$. Since you want the title unmodified, replace that by just title.

All I needed to do was copy the bibtex style file into the local folder with my tex document, edit it, and re-compile. Voila!

From here.

Labels: , , ,

Tuesday, February 22, 2011

Streamlining the workflow

Yes, TexShop's keyboard-command typesetting is nice, but I couldn't figure out a way to get it to run through the whole 4-step process (latex/bibtex/latex/latex) for making a file with cited references with one keystroke.

Lyx will do the whole compilation in one command, but its interface doesn't allow me to edit just the latex code, instead forcing me to use some weird WYSIWYM viewing mode.

Luckily, I found some scripts that will integrate MacTex and TextWrangler.

I still needed a single keystroke full-compile-and-view command though, so I glued the "Full document compilation" and "Show result" scripts together and assigned it a keyboard shortcut (Window->Palettes->Scripts->Set Key...).

I also needed to edit the shell script to use Preview instead of Skim. Maybe this means I should play around with Skim a bit?

Anyway, this now allows me to select a bunch (or all) of references in Papers, export to bibtex, and cite them easily (assuming that the metadata in Papers is correct).

Labels: , ,

Thursday, November 18, 2010

MathJax Test

It works!
\[1+e^{i \pi} = 0\]
I basically followed this:
http://highly-distractable.blogspot.com/2010/07/math-math-everywhere.html
but used svn for easier updating and tweaked the access file to only outside access from my blog per the very last bit here:
http://www.mathjax.org/resources/docs/?installation.html

Labels: ,

Thursday, May 20, 2010

I used to like wall-jumping

until I started playing the Super Metroid Redesign rom hack.

On the one hand, I admire people who make rom hacks. Different maps, different items, different controls and interface, and increased challenge all sound like a really great idea.

However, I must say that the people who come up with these have taking the challenge bit so far to the extreme that it is no longer fun. Harder bosses = yes. Spending the first half-hour of the first dungeon without a sword = crap.

I figured I'd at least give the Super Metroid rom hack the same amount of time I gave to the Zelda: A Link to the Past one, given that I quit last time because I didn't know where to go.

This time, I actually stumbled across the fake wall that was necessary to go through to progress. The one fake wall I remember from Super Metroid (the original) at least had an enemy on the other side so that you would notice it...

So I fight the boss, fall down the pit and finally get the wall-jump boots that will allow to me to climb back to the surface. Then, after 10 minutes of trying to wall-jump, I decided to quit. If wall-jumping is such a critical component of the game, it should not have to be this hard. (unless you don't want people to play your hack)

I am, however, amused that other people have wasted similar copious amounts of time on wall jumping in this game.

Labels: , ,

Friday, April 30, 2010

Why I won't be buying new desktop parts

Based on my normal computer cycle, I should have upgraded my desktop in late 2008, early 2009, but haven't. As a computer approaching 5 years old, my desktop is aged, if not obsolete. There are some things that it chokes on, mainly any computer game released after 2005, and playing back certain poorly-compressed HD video. Looking at the parts I would buy to make it new and fancy again, they are relatively cheap (in computer terms): ~ $600 for new motherboard, processor, and RAM. I could probably make do with spending half as much if I were planning to replace it sooner (i.e. in 3 years instead of another 5).

Still, my computer is fine as-is (i.e. until something breaks), I don't need a slightly shinier and fancier new monitor, and $600 (or even $300) goes a long way towards buying more Legos. :)

Labels: , ,

Monday, April 12, 2010

Dynamic Range Compression

Taken at face value, Maaya Sakamoto's Everywhere is a pretty good value: 30 pretty famous songs spanning her career for just 700 yen more than a regular CD, and it includes a DVD with some promotional videos on it.

Here's the problem. At some point in the past, I stumbled across Richard's website, which really is just an index to his vast collection. (You should be aware that searching for "Animephile" now returns some rather sketchy results in Google -- this wasn't always the case...) Anyway, as Richard points out, dynamic range compression has now infected our beloved Jpop imports!

Compare, for instance, the waveform from the Nikopachi* version of Hemisphere looks like this:

The version on Everywhere, whioh I believe to be a remaster of the Nikopachi version (based on length and waveform) looks like this:

On first playing the two, the most noticeable difference is the increased volume in the "Everywhere" version. The obvious reason for this is simple psychology: people generally prefer louder music, hence increasing the volume on a song makes people like it more. With a hard limitation on the maximum amplitude in a given format, this naturally results in a reduction in dynamic range. In essence, the softer sounds become louder while the louder sounds get clipped. For a song like Hemisphere with both loud sections and soft sections, this makes a pretty big difference.

A good analogy is going to a rock concert vs. going to a classical music concert. In a rock concert, the music is blared at near pain-inducing levels to a point where it can be hard to make out subtleties in music. Contrast this with classical music concerts, where the venues are (usually) designed for acoustics, everyone tries to be super-silent (you'll notice a distinct increase in the number of coughs in-between movements). There's a ton more dynamic range between the softest solo portions and the bits where the orchestra is going full blast. Because of these differences, I avoid rock concerts even for artists I really like, but will go to any classical music concert if it's in my budget or if I really like the pieces.

* For those of you who are curious, the Nikopachi version looks noticeably different from the single version beyond the addition of some silence at the end. It looks like at least some parts may have been rerecorded or remastered. Here's the waveform for the single version:

Labels: , , ,

Thursday, April 8, 2010

The return of touchscreen?

Remember back in 2002, when Microsoft had these big plans for tablet PCs, with a whole separate version of XP?

Yeah, you probably don't, but back then I had this wonderful pipe dream for a slick note-taking application. First, it would obviously need to be able to open and write a variety of file formats, including plaintext, richtext, MS word, PDF, and PPT. Being able to annotate the last two formats would be especially wonderful for marking up papers and lecture slides. Couple this software with handwriting recognition, a computer-algebraic system, and graphing capabilities, and math nerds would eat it up. Imagine being able to note down equations, converting them into symbolic entities, manipulating and solving them in software. As a tool for doing math homework, it could be invaluable.

Separate pieces of software would probably be likely to simplify things, but if they were all made by the same company and shared UI structure...

Labels: , ,

Sunday, January 31, 2010

New Album from Maaya!

Apparently, Maaya is coming out with a new album for her 15th anniversary (of debuting with Yoko Kanno on Escaflowne). Of course,
here
is the requisite link to purchase it on CDJapan, so that I can get a few percentage worth of kickback. (which is quickly becoming necessary with the current dollar's weakness against the Yen) Yes, Nintendo, you're not the only one suffering.

In other news, they are using some fancy material/method called SHM-CD, which is supposed to "sound better". It may have been a factor in the past when CD quality was poor, but my understanding these days is that you really don't get bit errors anymore when reading CDs, so having a "cleaner" signal really doesn't mean much when it's all processed digitally anyway.

Labels: , ,

Sunday, December 6, 2009

Q: How hard can copy-paste be?

A: as overly complicated as anything else that comes out of the Mac BU of Microsoft. Hey Microsoft, stop playing around with multi-touch in Windows 7 and get some engineers working on very basic aspects of your OS and major software. (You'd think they'd have a better business strategy than developing features for 0.01% of their users when features used by 90% of the users don't work properly. But that's what you get when you have a de-facto monopoly on the industry. I mean, people still use Powerpoint instead of Keynote!)

Well, through trial and error, here is what I have discovered. Let's say you have some data. You plot it in excel and format it all nice and pretty. Then you copy-paste it into Powerpoint for your talk at an upcoming conference. Uh-oh, it doesn't work! Turns out, you need to go back, and save that spreadsheet in .xls format (previous version format). Then you've got to copy and paste-special as a Microsoft Excel Chart Object. Now your format is screwed and your chart looks like shit. No worries, double-click it, tell it to convert, wait a ridiculously long 5 seconds, and now you can edit your chart directly in Powerpoint.

To review:
1) you can't copy and paste from .xlsx to .pptx format directly.
2) when copy and pasting from .xls to .pptx, you need to paste-special (Microsoft Excel Chart Object)
3) the pasted chart needs to be converted before you can format it and for it not to look like crap

I had similar problems copy-pasting from pdf. Solution? save as png and then paste it in.

Labels: , ,

Saturday, November 28, 2009

Digital Distribution

It seems to me that Netflix streaming and Hulu are pretty much the main players now, having large libraries that are either free (Hulu) or free with associated subscription (Netflix). Compare to iTunes, where you can purchase (or maybe rent?) individual movies/TV episodes. Unfortunately for me, I prefer physical copies for my media - much easier to lend to other people. (While I buy some games on Steam, it's a bit more of a hassle for sharing my account info. Plus, who still shares computer games?)

Anyway, the point of this post was to note how "unique" indie films pop up on Netflix. The last time this happened, I ended up with Primer. My feelings about that are probably best summarized by the relevant XKCD strip (http://xkcd.com/657/)...

But recently, I stumbled across Ink (http://www.imdb.com/title/tt1071804/), which is rather amazing for multiple reasons:

- visual atmosphere
- great soundtrack
- ontological paradox

Labels: , ,

Wednesday, November 11, 2009

Physics do not apply in the Star Wars universe.

I'm not just referencing Solo's "Kessel Run in less than 12 parsecs" claim, which can be explained away as a boast about navigational and piloting ability rather than ship speed. (Though there may be relativistic reasons for why speed would affect the ability to accomplish the Kessel Run in a shorter distance.)

In the latest BrickMaster (LEGO's magazine), there's a fake ad from Koensayr for the Y-Wing that claims "Goes from 0 to 2,700G in less than a parsec!" I was going to try and figure out what that meant, and then realized that 2,700G is acceleration and parsec is distance! When car manufacturers boast that a car goes from 0 to 60 in 4 seconds, what they are bragging about is acceleration, that within 4 seconds, the power is such that the car can be accelerated to 60 mph from rest. What the hell does 2,700G mean? (Besides the fact that G is meaningless in Star Wars unless it references a specific planet.) If we take G to be 10 m/s^2, then 2,700G = 27,000 m/s^2. At that acceleration, it would take about 7 seconds to accelerate to lightspeed. I'm fairly certain that's not possible in the X-Wing flightsim games. Hyperspeed, yes, STL acceleration, no way.

Labels: , , ,

Why I hate MS more and more...

I used to be fairly positive towards Microsoft in the past: sure, OS X is a much nicer experience, indie applications for the Mac are polished to a much higher degree than on Windows, and the free (!) IDE in XCode is quite good, but Windows has to deal with backwards-compatibility, it is *the* platform for PC gaming, and sometimes Microsoft Research churns out some cool stuff.

Still, I find myself more and more annoyed by Microsoft's UI design sense (or lack thereof). Perhaps I have merely become spoiled by living on a Mac or become more observant due to reading Siracusa's rants (exhibit A, exhibit B). Yes, Apple doesn't listen to its own UI guidelines - everyone (well, anyone in the "know") admits that - but sometimes this gives us good things. (And sometimes, horrible abominations), but at least it has the good sense to make sure at least one engineer brings key interfaces up to new UI standards. (Yes, I'm talking about the control panel UI crap shown here.)

I feel like Microsoft has become a company with no guiding vision - some people work on cool things, some people work on the behemoths known as Windows and Office, but there's no one there with the bullwhip making sure things are consistent. Just look at the Office UI - for something that is the de facto office productivity suite, you'd think they wouldn't just up and change the interface on us. (but that's what Office 2007 did). And then when they released the next update for OS X, you'd think they'd fix things or add functionality, but instead they removed VBA scripting. And if the Ribbon is such a GREAT UI idea, why isn't it in Office 2008? Yes, I hate the Ribbon, but it's super-annoying when I'll work on something at school, transfer the file to home, and suddenly wonder why everything behaves differently. Formatting titles in Excel charts used to be so easy! I do like the fact that Office 2008 UI behaves more traditionally, but what I don't like is the formatting palette that is clearly an Inspector Tool wannabe. Do the people at the Mac BU not know how to make OS X native apps, do they just don't care, or are they hideously understaffed? (maybe all 3?)

One would think that Office 2008 would run faster than Office 2004 on an Intel Mac (because 2008 is a Universal Binary and 2004 is PPC-only and requires Rosetta). Nevertheless, I find that Office 2007 running on emulated Windows XP using half the memory and one core still runs rings around both "native" Office versions. (at least as far as computation in Excel is concerned.) Any version of Excel still seems to be faster than the Numbers app in iWork, though...

I already use Keynote for presentations, and Pages / LaTeX for word processing - can someone please make me a good/fast spreadsheet app so that I can put Office out of its misery?

Labels: , ,

Tuesday, October 20, 2009

The quest for resolution independence

I sent this in an e-mail to a friend who was complaining about the lack of high DPI (dots per inch) consumer-grade LCD desktop displays. (Some models do exist, but are intended for the medical community and are pricey.)

A comparison of DPI for previous/current Apple computers and display products

Laptops:
13.3" (1280 x 800) = 113.49 DPI
15.4" (1440 x 900) = 110.27 DPI
17" (1920 x 1200) = 133.19 DPI

Cinema displays and old iMacs:
23" (1920 x 1200) = 98.44 DPI
24" (1920 x 1200) = 94.34 DPI
30" (2560 x 1600) = 100.63 DPI

New iMacs: (note that these are now 16x9, suitable for watching "widescreen" video without black bars instead of the 16x10, which is much more common for widescreen computer displays)

21.5" (1920 x 1080) = 102.46 DPI
27" (2560 x 1440) = 108.79 DPI

And while Apple has touted a push for resolution independence (along with 64-bit) for a while now, some things still appear to be broken (at least in the first Snow Leopard release. I haven't installed Snow Leopard yet, so I can't say if it's been fixed since then.):

http://arstechnica.com/apple/reviews/2009/08/mac-os-x-10-6.ars/21
(scroll down to the Resolution Independence section)

On a further note, I do have minor gripes about the 16x10 computer displays, since my current HP display scales up widescreen input (via component) to the full size, so video games are stretched vertically ever so much (+11.1%). I believe this is simply because component is analog, and is being decoded by an onboard chip that then gets sent into the analog to digital converter (probably the same one that would decode a VGA signal). Not sure if this is still an issue on the newer LCD displays from HP and Dell that take consumer digital inputs like HDMI. (not that I have a PS3 or 360 to test anyway) I imagine it's still an issue with component video in. On the other hand having 16x10 IS useful for watching 16x9 video, because the black bars allow for UI popup that does not obscure the video at all.

Labels: , , ,

Sunday, September 6, 2009

clever spam

For the quick comic intro, see here.

In the latest round of human-blogs vs. spambots, I received this "interesting" comment on an oldish post. Since it's rather long, I'm only going to excerpt a particularly funny bit:

"School officials in Democratic-leaning New England say they have received relatively few charm bracelets." (with "charm bracelets" linking to what I assume is a jewelry site, but which probably sells viagra, too.)

Basically, it seems as though it's pulling random sentences from news clippings and then performing some basic parsing to replace certain phrases with its own links to create sometimes-grammatically-correct-but-always-humorous sentences.

Labels: ,

Tuesday, September 1, 2009

The Snow Leopard Cometh

Well, Snow Leopard is out, and I've read the review. Here's my brief rundown:

Pros:
- performance improvements (resolving that dreaded kernel_task/CPU/overheating issue somewhat, I hope)
- decreased size (freeing up a few GBs for my paltry 80GB hard drive)
- gamma 2.2 (so I don't have to worry about color differences when my website is viewed on Mac vs. PC)

Cons:
- 64-bit apps (breaking the widescreen hack to Mail and the SIMBL-based color hack to Terminal) [these are not insignificant UI fixes that would not be particularly difficult for Apple to implement natively...]

Things I'm excited about that don't affect me at all:
- XCode 3.2 & Clang (cuz who doesn't like a compiler with a metallic silver dragon logo that doesn't support the programming language you use)
- QuickTime X (cuz hardware-based H.264 acceleration is nice IF your graphics card/chipset is supported)

Labels: , ,

Wednesday, August 12, 2009

the future of SSD drives

After reading about half of Accelerando and thinking about the nature of technology, I got to wondering about what was going on in the field of SSD development. Last I read, one of the major factors limiting SSD speed had to do with differences between read and write speed as well as write-leveling algorithms to ensure a drive-life as long as possible. However, in thinking about this problem of optimal use of SSD given their physical limitations, I got to remembering that other innovation in low-level data storage: separation of the physical drive from the storage methodology (in the form of zfs). Before I read up on it, I was confused about what zfs really brought to the table beyond traditional filesystems. (And the answer for most consumers is, none.) However, it does present some major advantages for those running large servers. (hence why it is a feature relegated to the server version of Snow Leopard) So now the question becomes, when will we get a filesystem (or operating system) specifically designed to not collide with the physical limitations of an SSD? Right now, Apple is in love with many small files, which makes incremental backups feasible and easy, but runs counter to effective SSD management.

I realize that at the moment, standard magnetic recording is still used in 99%+ of the market, but presumably people are going to realize that having TBs of storage space is not going to be useful when media creation has not drastically increased (nor pipe bandwidth). And if SSD development continues, we should soon see the advantages of dramatically faster / slightly more expensive data storage. After all, to the average consumer, the 1 TB (traditional) has very little marginal value over the 256 GB (SSD).

Labels: ,

Wednesday, July 1, 2009

wonderful security lesson from UCSD

From UCSD (summarized by me):

How to use the UCSD encrypted wireless network:

1. download this file from our website
[note: safari wouldn't let me save it as it was, forcing me to change the extension when saving, and then changing the extension back after it was downloaded]

2. double-click the icon

3. if it asks you for your password, enter it in and click ok

[...]

Yes, I was told to download a file, open it, and enter in my computer's password. Hmmm, if I didn't know what was actually going on, this would set off all kinds of warning bells. It is so nice that UCSD neglects to explain what it is I am doing and why I should click the "always trust" button when "this root certificate is not trusted", because any potential scammer/botnet creator/hacker/identity theft is sure to explain the mechanics behind why a root certificate is not verified and why entering in my password is ok.

Labels: , ,

Friday, May 22, 2009

Mmm, technology

There's an interesting new feature on Amazon, where you can "upgrade" your book purchases, allowing you to view the entire contents online, make annotations, and print pages. Seems like an excellent idea, except for the price. For the benefit of viewing the books you already bought, you have to shell out some extra dough. I'm not sure exactly what the rate is, but it looks to be around 20% of the book's retail price. That's quite a lot of moolah to digitize your collection. I understand that redoing old works in new technology costs money, but there should be few costs once the infrastructure is in place. Plus, I'm sure there is the potential to have much higher volume of sales for pure digital works via Kindle and the like.

My belief is that if you buy a book, you shouldn't have to pay extra for different formats of the same thing (well, audio recordings are a bit different, as are different editions). I think a better business model would be to charge some sort of flat rate for books of different genres/lengths that is reasonable, rather than something based off of retail prices. (Actually, I'm not sure what the pricing scheme is, it would certainly be ridiculous if they charged more to upgrade a hardcover book than the identical paperback version.) As it is, I'm already miffed at the prices to buy things for Kindle. I would like to see a world where pure digital downloads are 3/4 price with the option to have the physical copy packaged and shipped for the 1/4 difference, with free digital versions included for all physical purchases.

Labels: ,

Tuesday, February 17, 2009

Why Carbon Sequestration is Probably a Bad Thing

The US Department of Energy is planning to start this week on a large-scale project for carbon sequestration in Illinois. So why is this a bad thing?

Well, let's suppose, in hypothetical candyland where government projects do what they are supposed to, without negative side effects, on-time and on-budget, that this project succeeds. Ok, good for us, we've removed CO2 from the atmosphere. I applaud your efforts DOE.

This does NOT solve the problem of rising energy needs. Rather, I believe the effect may even be in the opposite direction. Psychologically, the idea that CO2 emissions can be reduced "magically" will diminish efforts to change behavior to reduce CO2 emissions in the first place. And that IS a major problem. Fossil fuels WILL run out (or be hideously expensive) within a few decades at current rates of consumption (and growth in consumption). Running out of fossil fuels without the energy infrastructure to replace them is going to cause a major global crisis that will not be resolved easily. Not to mention, petroleum by-products (plastic) have vital uses and are even more important for a lot of products we commonly use.

Climate change is only one of the major global problems that needs to be addressed in the near future (i.e. this century). And CO2 emissions are only one facet of that problem. As reported by Arstechnica from the AAAS meeting, the numbers for replacing fossil-fuel energy production with "renewable" sources is already extremely daunting. The most economical/efficient way to address that problem is to tackle it from multiple directions: improved efficiency (less usage, less waste), increased production from "renewable" sources (e.g. solar, tidal, wind, etc.), and finally carbon-scrubbing to reduce CO2 concentrations back to pre-industrial levels (i.e. 280 ppm atmosphere, and slowly equilibrate the oceans to that level). Introducing a carbon sequestration project is putting the cart before the horse: we should be focusing on the SOURCE of the problem (energy consumption) rather than simply mitigating the aftereffects because it is the most publicly recognized facet of the problem.

But, in the end, I guess Congress is a lot better at punting the problem and buying time, than in spending preemptively to alleviate future problems. Unfortunately, I happen to be one of those young'uns who is going to end up paying for the mistakes of the past. (*cough* war on terror, social security, etc.)

Labels: , , ,