Python / SQL — Remove all non ASCII characters from unicode string

Here’s a brute force method to force a unicode string to ASCII by removing all non ascii characters from a unicode string for those pesky Ordinal Not In Range errors or DB errors.

Though I found comprehensive solutions that replace the non ASCII characters and such with approximate values, I just wanted to get rid of them, ASAP, Yesterday.

''.join([x for x in 'YOUR_STRING' if ord(x) < 128])

Ending of Genshiken Explanation

The ending of Genshiken, my favorite manga explained.

Note: Chapter 56 is out there! Email me if you need it.

The ending:

I wondered what it meant at first, and I even looked it up online hoping for an answer. At the very last page of chapter 55, Ogiue is observing “I don’t think Kasukabe senpai realizes just how sensitive she is to conversations like this…”

I just came up with an interpretation that ends the whole series on a great note, summing up the whole message all along: that despite their differences these guys have mutually accepted (and respect) each other.


The very last page:

The top frame starts after Kousaka tells Kasukabe that she has no “moe”. She’s shocked (a “gaan..” reaction, not real shock) and responds with a smiling “hmph”.  The expression shows she’s not pissed.

The little sister is having fun watching this chaos (just like this interaction has happened before) but, this time it’s a little different: Ohno responds that it’s not fair not all that seriously, but I think the point here is to show she has respect for Kasukabe. The usual would be to do a “tsukkomi” and pitch into the mayhem for kicks.

Ogiue then pitches in, saying “you know.. I’ve always noticed..”  (getting ready for the last line in the damn series!)

The next frame has no text and no eyes to emphasize the group atmosphere. Kasukabe is yelling something (smiling) at the 3 on the right, who are all smiling.

The last frame is Kasukabe who looks back at the reader, still smiling, saying “huh?”

I wondered what this meant. They built up to the Kasukabe point so I wondered and wondered. This time, I get it.


The point?

The girls are commenting on how Kasukabe is actually sensitive to “conversations like these” — those being the otaku ish conversations. The series starts with Kasukabe being hostile to the otakus, wanting nothing to do with them (only trying to drag her boyfriend out of otakudom), being embarrassed about associating with them, etc.

The series ends with her actually being a part of the group. It’s mutual friendship / respect.  The moe comment was about that: she wouldn’t have cared at all about a comment like that at the beginning of the series. She might have even punched one of the characters for it : ).

I think that’s why she’s with the 3 characters she least converses with/ have the most Otaku specific personalities for the final scene. For example Kanji is purposely left out because I think as the main character, he would take away from the power of this scene if he was in the last page, since his presence kinda justifies any conversation.

“sensitive to conversations like these…” : you can’t be sensitive to conversations like the moe comment if you don’t give a crap about moe, or the people who you’re talking to.

The most important frame is the 2nd to last frame (there’s a lot to interpret in it): the 3 girls have the “drop” implying they are observing something very obvious. The 5 in the back are in their own world. Kasukabe is all heated up about the “usual” conversation. She totally gets along.

That is the meaning behind Ogiue’s comment about her being sensitive to “conversations like these”, followed by a full width shot of Kasukabe smiling.

The first time I read this, I thought the author was going for a “life goes on” kinda ending with no resolution on purpose. Turns out there is indeed a resolution, and a great one at that! The message of the whole series is finalized here.

I wish it wasn’t over : ( I am clearly trying to pretend its not. I do have chapter 56 left to read, and I’m stashing it next to my crack. I will re-read the first 55 to get to 56 :3

To quote a memorable comment:

“I have to say, I’m taking the end of Genshiken surprisingly badly. I feel like a heroin addict who’s just been told that I’ve taken the last hit on the planet.”

BAH!

Django — MediaDefiningClass object is not iterable

For me, the cause of this error was sending arguments to the register function in the wrong order.

Check the order of registering a ModelAdmin: it’s the model class first, then the ModelAdmin class.

Example: admin.site.register(Model, ModelAdmin)

I suppose naturally the second one has to be the ModelAdmin since register(MyModel) works as well. That’s one good way to think about it.

Mastercam Gotcha: Two Same Contour Toolpaths / Different Bit Sizes Ruins Verify

If you have two contour toolpaths using the exact same drive chain and the verify is showing a ledge when it shouldn’t, it’s because the tolerances in the verify settings and not an actual deviation in the real toolpath.

0.01 tolerance on a .1 bit will render a slightly different verify than 0.01 tolerance on a 1.0 bit resulting in a ledge if you only have the smaller bit cutting deeper.

This can be reproduced: create 1 line anywhere.

Run a contour toolpath with your larger bit with any settings to any depth.

Right click-drag to copy the toolpath, and only change the tool to a new bit .1 SMALLER than the previous operation, and change the depth to go DEEPER.

Example:
.5 bit, -.25 depth for Contour1
.4 bit, -.5 depth for Contour2

Verify will show a ledge, when the real machine path will have none, as you might expect.

Tightening the tolerances will make the ledge smaller and smaller, but it’s still there.

I feel like relying on verify like it represents reality exactly has caused me the most trouble.

Mastercam — Peck Drill Toolpath Verify Problem

If you use a drill toolpath on Mastercam and try to use the peck option, the program uses a subroutine/subprogram for the pecking operation and will NOT show up in verify.

Your verify and backplot will show one swift drilling movement all the way to the specified depth, regardless of your peck settings. It turns out the g-code generated is only a line and has the pecking written in as one of the arguments, so if you’ve made it a habit to verify everything and you’ve stopped dead in your tracks with the drill toolpath, just forget verify and run it on your machine — the pecking will be there.

Find the things in life that make you cry.

I just read “Find the things in life that make you cry” and couldn’t agree more.

Life’s pleasures to me are the things that move me so much I am in tears.

Why do we cry? Sadness is obvious. But what about those times you are deeply moved by something? I seem to be chasing /that/ particular high my whole life.

Sad things make you “feel” but I think it’s the most basic of feeling. You can watch or read sad stories and cry. You’re filled with emotion and it feels good.

I’m not sure what crying is, but it’s definitely not always sadness. It’s appreciation, or something deeply moving. Something that hits your heart. Maybe pure emotion. What’s going on in the brain here? It’s definitely not a “joy”, or a high from a drug. It’s a pure expression of one kind.

A few things move me like that:

Music.

This is the most surprising to me. When music moves me to tears, I think I find myself in two camps for explanation. I’m not married to the first camp, while I know the second explanation has some truths.

  1. Sometimes, the music feels so “good” and I appreciate the complexities or uniqueness of the piece so much that I cry.
  2. Most of the time, I think music is tied to storytelling. Music tells a story, and I can be moved in the same way a story moves me. There are some beautifully melancholy songs that move me to tears probably with a mix of sadness and then appreciation.

For example this: http://www.youtube.com/watch?v=RtPm5GiJ_iM moves me to tebars. I associate it very strongly with the movie it was created for so I can’t get rid of my story bias here, but say minute 1:00, that strange instrument is so powerful. It’s so fluid and the tone so sad that I have a great appreciation for the raw emotion it can pull out of me.

Story.

Stories can move you. I always have this opinion that stories are “real”. There’s this thought that if something is fiction, then you won’t be as moved. Well, in my thought experiments I’ve come to the conclusion that “real” and “fake” mean nothing to a story.

An extremely touching story is touching fake or not. Imagine this: you were moved to tears by some rescue operation on the newspaper. Turns out that was fake. Ooops. It’s fake, but how it touches you is the same.

Sci fi fans have always appreciated this. Sci fi books are often all about philosophy that can only be explored through another world. If the world was like “this”, then what would happen?

What moves you in a story? Well unfortunately this one depends on how you were raised and thus your values. I can’t claim here that there are any universal values that will touch all.

Perhaps a story of a tragic love everybody might relate to, or perhaps not? Human attraction for one another is something we all have, but the values that would make a story tragic, heroic, disgusting or boring depend on the person.

Everything is in the eye of the beholder. Music? Music taste depends on which notes you were grown up with.

I asked this question once and found an answer. The human brain enjoys (as in releases “good feeling” chemicals, like when we eat food) musical combinations where the ratio between the two frequencies is simple, like 1/4, 2,/3, 4/6, etc.

Absolute frequency doesn’t matter (X hz), there is no truth in a specific absolute note, but it will sound appealing to YOU if your culture promotes those sets.  This is something that can be learned, so you can start enjoying music from another culture, it’s just that it is definitely a learned skill, not set by birth.

So, because I’ve been raised with the Japanese base notes (which use the same ABCD frequencies as Western music, but the core of it is a different pattern) I can enjoy that music as well as some crazy combination of my inter cultural tastes.

Anyways, as much as I want to go enjoy the things that make me cry, they don’t make any money for me, so I must keep moving on.

One day though, if I can work with what I am passionate for my life would be complete.

What is my PEM Pass Phrase?

Your PEM pass phrase is something you set when you generated your SSL key.

It turns out you can not ever retrieve it, so if you don’t know it, stop trying to figure it out and re-key your certificate!

Your site is probably down, so disable ssl for now and get your apache or nginx or what have you started, and go on to your SSL authority and re-key your certificate!

Good luck.

Firefox Untrusted SSL Issuer

Firefox error: sec_error_untrusted_issuer

If you are running into this problem with GoDaddy SSL check if you combined your .crt and gd_bundle.crt with the “cat” command if you’re running a linux server.

We renewed our SSL and our site had been unknowingly displaying this error for firefox users for a month, but not to Chrome or Internet Explorer users.

Check every browser folks. Who knows how many people we scared off.

Python / Django — Combine Querysets and Sort. Sort List of Any Objects.

Assuming it quacks like a duck, you can use operator.attrgetter()

Combine queryset by turning it into a list:
queryset_list = list(queryset1).extend(list(queryset2))

Sort the list by:
queryset_list.sort(key=operator.attrgetter(‘attribute to sort by’))

Update: 4/28/2010

Yeah, I forgot the sort function sorts in place. sort = list.sort would not be good.
Also, for those wondering, you can just import operator. “import operator”