Category Archives: Tip

The Glyphcube: My Epic Rubik’s Cube Mod!

[A little backstory. I wrote this post back in October 2013, but never got around to publishing it since I hadn’t taken pictures of my cube. Now, I take a Rubik’s cube to school often. I’m also famous for my God-given ability to lose things. The unbeatable combination of these two things is responsible for the next two sentences. I lost this cube last year, and so you won’t see pictures of all the faces. They’re lost forever. Sob.]

Imagine an evening during Durga Puja here. Now replace the image of the grinning, phuchka-downing, pandal-hopping Bengali with an image of a (then) 14-year-old down with a cold and a fever, sitting at home. He’s obviously displeased. He takes a shaving blade, and…

…picks up his Rubik’s cube and starts making shapes on its faces (or cubies, or cubelets, or whatever you like calling ’em). Yeah, that was me.

OK, time for a little explanation. I scratched the paint off this cube to make nice symbols . Now, the white face was left alone, so five faces were left. And there are nine ‘facelets’ on each face, for a total of 45 symbols.

Here are some pictures (taken with the camera on my mother’s phone since I couldn’t remember where our H70 was):

 

What I did:

  • The yellow face
  1. The top-left shows a random bit string of length 18 (it evaluates to 742637, which is pretty uninteresting!)
  2. As for the middle-top one, let’s just say I’d been listening to Achilles’ Last Stand all day…
  3. The third one is an asterisk (duh) and was chosen for the supremely important top-right position because of its use as a symbol for multiplication, because it stands for convolution, and because it’s part of nearly every regular expression. And movie subtitles. Duh.
  4. The middle-left is a lambda. What can I say? From wavelength to lambda calculus to Python, Haskell and LISP (and awesome functional programming in general) to my previous desktop wallpaper – it’s pretty much everywhere.
  5. The center one is a warning sign – only with the foreground and background colors interchanged. (I should have made it red instead, right?)
  6. The sixth one. Yes, the middle-right one. (It’s all right if you’ve stopped breathing in awe. Take your time.) Beauty in a symbol. The Golden Ratio. Yes, 1.61803398874989484820458683436563811772030917980576286213544862270526046281890…!
  7. The bottom-left one was originally intended to be a simple plus-minus symbol (OK, if you want a philosophical explanation of why I put that here, it was to celebrate the duality inherent in everything – even the simplest middle school quadratic equation – no, just kidding, I like how it looks) but I kind of made the minus sign too thick and ended up joining the plus and the minus. It looked a bit like a grave now, so I scratched a thin line on each side of the minus to make it look like a convincing one.
  8. I intended the next one to be a water sprinkler (think Feynman’s inverted one), but somehow ended up drawing a shower. Hooray for 20-second baths (and for fluid mechanics, which I viscerally detest)!
  9. The last one is a sun. It represents a new beginni… oh, go read the ending of a Dan Brown for all that. We now turn the cube (an x rotation, fellow cubers. Then we do a y’ to make sure we’re looking at the symbols the right way.)
  • The blue face

This face (part of it, at least) celebrates simple combinatorics, statistics and what-have-you (sorry if you expected me to scrawl the q-Vandermonde identity or the Dirac distribution on a facelet :D).

  1. This one’s k, the most commonly-used variable over which we iterate on a summation or a product. <says the next sentence in one breath> sumktothenegativekthforkfromonetoinfinityquick!
  2. The middle-top one is 26. Or… is it? The center of the six was scratched out intentionally (you didn’t think I did it accidentally, did you? mwahahaha <maniacally laughs at evil level of skill in scratching paint off Rubik’s cubes>) so that the six could be made to look similar to an opening  single quote. This makes it stand for two things: 26, the number of letters in the English alphabet, and 2 followed by a quote – 2′ – which could be taken to mean “double-quote”.  (I like quoted speech and string variables a lot.)
  3. The next one is, plain and simple, infinity. (Pedants, positive infinity.) (Malevolent pedants, positive uncountable infinity.) Often used for upper summation limits, never mind all those paradoxes and philosophical questions.
  4. The fourth was the first design I made on the cube. Don’t call it a random set of scratches – it’s modern art. (Or does it look like a river delta? Delta? That’s coming later.)
  5. The blue center is a percent symbol. It also stands for the modulo operation in C, Java and so on (and I remember every mark I’ve lost because I wrote % instead of MOD when we did QBASIC in school. Sad memories.)
  6. The next one is not a six turned 90 degrees clockwise. It’s a lowercase sigma. Standard deviation, yeah!
  7. The next one is about for the second-biggest* lie children are ever told. “NO NEGATIVE NUMBER HAS A SQUARE ROOT IF YOU SAY SO YOU’RE WRONG SHUT UP AND DO THE SIMPLE INTEREST SUMS I’VE SET YOU.” The imaginary unit. A high-school student’s version of the belief that one day, you’ll find out that everything’s possible.
  8. Bottom-left – capitalized, though it should have been lowercase –  is an n. It’s there because it’s often used as the upper limit for summation (though many people use this as an iteration variable as well). Oh, and it’s a common variable name anyway :)
  9. The last one is awesome. e. The “base of natural logarithms”, according to Wikipedia. Or, as the awesome Kalid at BetterExplained puts it, it is “the rate of growth associated with all continually growing processes.” Yeah, there’s a mathematical constant talking about what those health drinks claim to do! Time ter turn over to da green face. (x2 y’, cubers.)
  • The green face
  1. The first one, on the top left, is interesting. Srinivasa Ramanujan (once, and still, a role model for me) once scrawled “1 + 2 + 3 + 4 + . . . = -1/12″ in his notebook. Although that is (obviously) false, it is a case of what is called Ramanujan summation, and you can read about it here. I put it there because it’s compelling, mind-bending, and because I think that a person who solved problems by saying “I knew the answer was a continued fraction, so I simply asked myself – which one?” deserved, even demanded, a place on my cube.
  2. The second one is a symbol for the console. The command line. Terminal.app for Mac guys. The home sweet home for every self-respecting developer (I’m looking hard at you, Dreamweaver users) worth his line endings. (I rock oh-my-zsh, if you must know.)
  3. The third one is fire. Not Fire (IIRC the subject of a common question in quizzes), but plain old fire. Again, you can find everything it stands for (vitality, health, change and such-like) all over.
  4. The fourth is the uppercase Γ, which I’m using here for the gamma function. So you wanted to find the factorial of one-half, huh? Well… it’s actually quite pretty. it’s the square root of π. (Previously referenced malevolent pedants, the positive square root of π.)
  5. Σ, uppercase sigma, stands for summation. You can do a few things with summation, right?
  6. Pr stands for probability. It’s all about stuff like whether you have more chances of getting a six on six dice, or getting two sixes on twelve, or three sixes from eighteen. And NFL and La Liga winners. Chances.
  7. The seventh was rather random, so I put Ei – the exponential integral – on that. I remembered it from a PDF on numerical integration I was going through. (I think I should have put a Lambert W there, right?)
  8. The eighth is a tree. Freshness, growth, and the like.
  9. The ninth is the beautiful von Mangoldt function. I first came across it on Terry Tao’s blog. It’s very interesting, and it often crops up when one’s studying the zeta function. (Twice-referenced malevolent pedants, the Riemann zeta function.) Time for the red face. z’ y time, cubers!
  • The red face
  1. The first one is modern art, like one facelet we’ve seen before. If you forced me to interpret it I would say… erm, perhaps a comet orbiting the sun, as seen by an alien through a dirty telescope?
  2. The top-middle one is a theta in a picture frame. Wow. Sleek and angular. This is TIME LightBox material.
  3. The top-right one is a comet (or a meteor). I like ’em (and like the numbers behind them!), but I’ve never seen one through my telescope.
  4. The fourth is (embarrassingly) the second instance of a mundane fire – but it’s rotated through ninety degrees. What can I say? It was one of the first designs I made on the cube <sheepish>
  5. dx is straight out of calculus, and is the only thing common to a derivative (remember the dx in the ‘denominator’?) and an integral (that thing people forget to put at the end, and therefore decide to put at the beginning when they go advanced).
  6. Pi. π. The “best” number ever, according to many. The most profound number in mathematics. So much so, that I’ve got to stop beating myself up for not putting it on a center.
  7. ħ (h bar), the “reduced Planck constant“, is one of the lone physics references on this cube. It’s meaningful as it’s deeply related to how small things can be – you have a Planck time (the smallest possible meaningful length of time), a Planck length, a Planck mass, a Planck charge and everything else short of a toothbrush in Planck units.
  8. Delta, the mathematical symbol for change (as Robert Langdon unconsciously starts explaining to a physicist). Be the Δ you wish to see, said a certain wise old man once.
  9. This was supposed to be a ζ (for the Riemann zeta function – what is the probability that two randomly selected numbers are coprime?), but I couldn’t  make the shape properly, so I scratched it out. Go, do an x2 y’ and look at that orange face.
  • The orange face
  1. The top-left one is “America’s favourite pictogram” (why does Dan Brown keep cropping up?) and I really am proud that I put it there. A fork and a knife – because a spork can do everything a spoon can.
  2. R’ is one of the commonest Rubik’s cube moves, and means to turn the right face 90 degrees counter-clockwise.
  3. The third one is a misspelling (?) of -1, and it’s half of the world’s “most beautiful equation”<teary-eyed awe>
  4. The fourth one was nice. It’s an LED matrix, and it can show all the digits (and a few letters) if you light up parts. Old-school calculators, anyone?
  5. The fifth one was kinda crazy. This center was scraped into a likeness of a Rubik’s cube itself. (To get your mind bent, imagine that cube having a drawing of a cube on its orange center. And that one too… Recursion \m/)
  6. The right middle one was supposed to be a simple line drawing of Ma Durga (goddess Durga, a symbol of the victory of good over evil), but I botched it. You can still see the eyes, the nosering, and the shaft of her trident, though.
  7. The seventh is a contour integral (over the contour C**). It’s how you integrate crazy things like this.
  8. The bottom-middle one is the last random fire. This one looks like a blowtorch, though. Oxy-acetylene, maybe? (See, I added a bit of chemistry too!)
  9. The last one. Almost fitting. The Bernoulli numbers (at even indexes***). They’re applied almost everywhere – for example, remember that the sum of the first n positive integers is half of n times (n + 1)? That’s an example of Bernoulli numbers in action. They’re also found in quite a few other places.

That’s it! Tell me what you think of this in the comments :D

[I am pretty bad at cube rotation notation (rhymes!) so please correct me if something was wrong.]

* the biggest lie is that “the needle won’t hurt – it simply feels like an ant’s bite!”
** thrice-previously-referenced malevolent pedants.
*** or indices, if you like.

Advertisements

Clean, Simple and Updated: Three Awesome Regexes For Rails Developers [Tip]

Tip #1

Rails previously used a symbol and a hashrocket to declare/modify hashes, like so:

:name => "Mr. Foo B. Baz"

Now it uses this JSON-inpired style:

name: "Mr. Foo B. Baz"

Regex in ST2

In order to move to the pretty, concise new style (heh, I like it!) go a regex-replace in your text editor and replace this:

:(\w+) =>

with this:

1\:

This is what happens:

Screenshot from 2013-05-04 15:14:00  grey.arrow.right.md Screenshot from 2013-05-04 15:14:13

Tip #2

When you use something like Rails Composer(which is an awesome tool, BTW) you get a messy Gemfile like this:

A messy gemfile

You can fix some of that with the first tip, but for neat grouping, do this:

  1. In your editor’s find/replace box, enter this regex:
    gem .* (\w+): :development(?:.*)
  2. Select and cut all the lines.
  3. Create a new “group :development” block and paste the cut lines in.
  4. Repeat this with “group :test”, “group :production”, “group :staging”(if you have one) and “group :development, :test”. (For the last one, your regex should have “[:development, :test]”)

Note to self: write an awesome gem to cleanup Gemfiles :idea:

Tip #3

Jackie-Chan-WTFDo you have hardcoded version numbers in your Gemfile?

Select all text matching this regex:

, [\"\'][">=", "~>"]*.*[\"\'][,]*

Delete it and sleep peacefully.

That’s it. My Gemfile now looks like this:Awsum Gemfile

[I can’t write any further as someone has turned on a 3KHz sound. Stupid neighbours.]