Shinobu’s Secrets

June 26, 2009

On Sleep

Filed under: Productivity/Perspectives, Rant — Shinobu @ 12:36 am

The wave of interest in recent times of so-called polyphasic sleep has become very pervasive. I’ll have to admit that even I took keen interest in it around the time I started this blog. I’ve read countless articles on sleep, and now, I’ve come to the following conclusion: the problem is not figuring out the bare minimum of hours of sleep you need each day; rather, the real problem is figuring out how you can be more active/productive while awake. If you cannot confidently say “I spend all of my awake-time doing productive things”, then there is no point of “hacking” your day so that you sleep less hours; what’s the point of buying more books if you cannot finish reading the ones you have already?

I think most people initially accept the proposition that if you sleep less, you’ll get more done. The common one-liner you’ll read in most articles goes something along the lines of “even if you shave off just 1 hour off of your usual sleeping cycle, this meager saving will net you X extra years of life!

This kind of thinking is plain wrong. Unless you are narcoleptic, sleeping too much is NOT the problem. The real problem is figuring out what you are going to do while you are awake. You can sleep 6 hours, 4, hours, 2 hours even, in a single day. Nobody cares. The only thing you should care about is how you spend your time.

Now, I do understand that for some people, spending more hours out of bed will guarantee more productivity. But this is only true if the pending task is very simple and does not require much decision-making. Unfortunately (or fortunately, rather), very few people in the modern world today share the same working career as child laborers did at the dawn of the Industrial Age. Unless a supervisor directs all of your attention to predefined goals from the minute you wake up to the minute you go to bed, so that you are reduced to a drone working for the Hive, sleeping less does NOT mean increased productivity.

Besides, there are far more important problems to tackle than “hacking” your brain to get less sleep:

  • How can I spend more quality time with my family?
  • How can I stay healthy?
  • How can I improve my relationship with my partner?
  • How can I improve my mind?
  • How can I conquer my fears?
  • How can I stop procrastinating?
  • …etc.

None of these important questions involve sleep as a material part of the solution. Sleep, my friend, is irrelevant. All of the questions above instead have the goal of increasing the quality of life. So don’t fool yourself into thinking that sleeping less is an integral part of self-improvement. Sleep, like everything else in life that can be objectively quantified, must be taken in moderation.

October 5, 2008

FYI: Text Files from Linux to Windows XP Notepad

Filed under: FYI, Rant — Shinobu @ 4:01 am

Sometimes when you open up in Windows XP a text file that was created by someone using Linux (e.g., an open source project developer), you’ll get a really ugly block of solid text, with the lines all wrapped around each other. For a long time, I used to get ticked off at whoever had created this file. Well, now that I’ve gotten into programming (Ruby a while back, and now, C++), I’ve now realized that it’s really Windows’ fault, not Linux’s.

In Linux, if you press ENTER to type text on a new line, the program inserts an invisible character called a newline character. This character is represented as ‘\n’ by the program. When you open up the text file later, the text editor will look at all the newline characters, and create a new line each time it finds them.

In Windows XP, and for example in Notepad (and other simple applications), the program expects two characters to denote a newline — the regular ‘\n’ AND another character, the carriage return character, or ‘\r’. Isn’t this redundant and unnecessary? If we’re editing a text file — the only thing we need is a newline character, not a newline AND a carriage return, to denote the beginning of the next line of text.

So take your frustration to Windows. Linux wins once again.

August 27, 2008

Evolutionary, Not Revolutionary

Filed under: Rant — Shinobu @ 8:03 am

Take a look at this article. And this one. And this one. And this one. And this one.

The common thread is this: the authors are all from the venerable www.anandtech.com tech news/reviews website, and they all express themselves with the play on the words “evolutionary” and “revolutionary.”

Oh, kill me now.

When I first encountered this combination of words some years ago (from Anandtech), I thought, “Ha, that’s cute — but is it really necessary to use two six-syllable words to convey that idea? Can’t they just say that the product is or is not very, oh I don’t know — innovative?” It just seems a little bit stupid to work the reader through the hurdles of e-vo-lu-tion-ar-y and re-vo-lu-tion-ar-y. Certainly, it doesn’t look, or sound, very intelligent either as far as the author(s) are concerned.

Besides, it’s not a case where one word out of the pair is confused for the other. Stylistically, that’s when such combinations really shine. For example — “apposite” vs “opposite”. The two are completely different in meaning (almost antonyms, really), and are sometimes confused to mean the other because of their 1-vowel difference. Another such pair is “accept” and “except.” And maybe even “accrete” and “accrue.” But evolutionary and revolutionary, when used together in the sense of “hey, reader, check this out,” is just annoying. And it’s moronic if you keep repeating it over and over again, like the folks at Anandtech. Lastly, it gets a little bit retarded if you keep mentioning the same pair to say the same message every time — that it’s evolutionary, not revolutionary (and never the other way around).

UPDATE August 27, 2008: OK, I just realized now that Anandtech isn’t the only source of the horrible wordplay. Google evolutionary “not revolutionary” and see for yourself.

May 28, 2008

“Leon” (1994) and “Most Wanted” (1997) – Plagiarism!

Filed under: Film, Rant — Shinobu @ 7:04 am

Summary: Most Wanted (1997) copied many, many parts out of Leon (1994) — action sequence for action sequence, camera angle to camera angle.

I watched a 5-minute clip of Most Wanted on TV a couple weeks ago, and it bothered me so much that I have to let it out here in this post.

The scene I watched had the main character escape from some cops in an upstairs apartment room. This action sequence copied so many things from Leon, that I was left with disgust. So here are all the things that were copied from the Leon’s last action sequence:

  • when the main character gets almost shot by sniper fire from a nearby building, through the windows (and just before this happens, the main character sees the sunlight reflect off of the lens of a sniper rifle’s scope — which is exactly what the main character Leon describes to Matilda in Leon when he is teaching her about sniping); in Leon, the main character gets almost shot by sniper fire when he tries to save his potted plant
  • after some policemen raid the apartment room, the main character shoots all of them, and in response, an outside policeman says something like “man down!”; in Leon, after Leon takes out all of the first wave of policemen, a policeman outside the room says to his radio transmitter, “man down, man down,” and Stansfield (the villain) responds “I told ya”
  • the main character dresses up into a dead (or unconscious?) policeman’s uniform (SWAT uniform), and escapes; in Leon, Leon switches clothes to escape the hundreds of SWAT policemen lined up outside his apartment room

Seriously, the director of Most Wanted, David Hogan, copied all of this out of Luc Besson’s Leon. Shame on him. Yes Mr. Hogan, you have an artistic license as a director, or réalisateur as they say in French, to draw inspiration from primary source material. But to copy everything down to a line in a 5 minute sequence is just too much. It’s unacceptable. That’s why I flipped channels instead of deciding to sit down and finish the movie, which seemed interesting at first.

(By the way, Leon is probably my all-time favorite movie for its blend of comedy, tragedy, action, suspense, and even a touch of romance. There’s no movie quite like it.)

February 3, 2008

My Newbie Experience With Ruby on Rails

Filed under: Rails, Rant — Tags: , , — Shinobu @ 7:06 am

So for the past month, I decided to learn Ruby and also its popular web framework, Ruby on Rails (or just “Rails”). The motivation behind this learning spree was the creation of my own website that I could use to help me study better (as a sort of drop-in replacement for MS Word for writing outlines of law school subjects). First, let me say that learning Ruby was great and really fun. However, Rails was really, to be honest, a pain in the @ss for pretty much everything.

I’m not going to go off on a long rant here (like what this ex-Rails core contributor did); instead, let me just point out some of the biggest weaknesses of Rails:

  1. Its documentation is pathetic. The Rails API doesn’t really mean anything to me–it’s just an index of every feature of Rails with short tidbits that are often sorely lacking in coherence. Or at least something that a newbie programmer like me can understand. And, I don’t know why, but the Rails community decided to put together a Wiki that is, at least for everything I was interested in, either obsolete, or poorly organized. It’s like reading a IRC chat log, except with prettified code blocks. Like this page.
  2. Somewhat related to #1, Rails has few, if any, tutorials that work. This is because Rails changes every 2 weeks. For some reason, every book I’ve used on Rails so far had to be modified by myself to work on my Windows XP box (I’d like to get into the world of Linux and open source operating systems more, but the last time I tried to install Ubuntu 7.04, it refused to work with my dual LCD monitor setup). And that means every time I want to do something–say, add a feature to my Rails app–I need to first google some vague description of it, and hope that someone on the Rails mailing list has it figured out. And about 75% of all useful tutorials on Rails seem to come from blogs. This gives me the impression that Rails developers don’t want to share clear, concise knowledge with other people in general. That’s why crappy sites like the Rails Wiki I mentioned above pops up in the top ten search results on google so often.
  3. Aside from horrible documentation and a sore lack of working tutorials, Rails seems hypnotized with its own mantra of “do everything in 20 minutes or less!”. By this I mean–so many articles about Rails are caught in the hysteria that it’s always better to write less lines of code, that it’s so great to do something in 5 minutes. There’s a common thread running through these tutorials/blog articles about Rails–they’re concerned first about quickly implementing something instead of creating something that is sturdy, reliable, and is general enough to work in a wide variety of situations. Usually, many of the Rails “solutions” or “recipes” that I encounter across the web while googling for Rails developer wisdom are too specialized to be of any use to anyone but themselves. If you’re going to share something with other people, it better be easily adaptable/changeable so that people can actually make use of it, and hey, perhaps make it better.
  4. In line with what I said in #3, I really despise how so many tutorials make use of Rails’s “scaffolding” feature. Good grief–I don’t want auto-generated code flying around in my Rails app to add just one little feature. You know what, I think the whole “scaffolding” feature is retarded. It’s only good if you want to create shit-looking websites that look as good as the tutorial’s scaffolded views. Seriously–do people really use scaffolding? I think it’s just a big joke–a marketing scheme. Scaffolding only lets you create something really fast–so that the Rails community can boast about development speed. And why is it that every tutorial out there on scaffolding is concerned about creating a weblog? With “Posts” and “Comments” as models? What if I don’t want to create a weblog? What then?
  5. Some features that should be really, really, really simple and built-into Rails don’t exist at all! For example, there is no simple way to upload files. Just google “rails upload files” and you will see. The answers do not converge to same/similar solutions. This is madness! Rails wasn’t built yesterday. It’s been several years since DHH became an international figure. And yet, all through that time, it has failed to create a simple feature that allows users to upload files to a basic Rails app! Also, did I mention that Rails migrations do NOT support the creation of MEDIUMBLOB/MEDIUMTEXT or LONGBLOB/LONGTEXT types in MySQL? Why? Why do I have to execute ugly SQL code inside my Rails migration files? Apparently, Rails likes to think that everything should be smaller than 64KB. What a joke!

That being said, I’ll still say that Rails has taught me a lot about web design and what it could be (my last foray into website design was in 2001 with pure HTML and Notepad). But it leaves a lot to be desired. I’ll keep playing around with Rails on my windows box for now, but my desire to learn the deeper intricacies of Rails has all but died out. The bad news is that Rails is the only heavily-developed framework out there based on Ruby–my favorite scripting language. Yes, I know of other alternatives like Merb, but bad documentation is better than no documentation (the only reason why I decided to learn Rails for what it was worth was because no other Ruby-based framework had a similar amount of documentation). And for the record, I did end up creating a decent website to suit my needs (a replacement for MS Word). But it could have been better, and more pleasurable, had it not been for the 5 annoying-as-hell points I listed above.

My advice to those wanting to learn a web framework is this: wait a couple years! Hopefully, either Rails or some other alternative will be mature enough to be easily digestible. But if you have countless hours to burn reading blogs and googling for things–you have my blessing.

UPDATE March 25, 2008: I see that people are visiting this blog for Rails tips (like what I was doing 3 months ago). If you want to learn Rails without the crappy feature called “scaffolding” that I ranted about above, try “Build Your Own Ruby Applications” by Patrick Lenz. It’s outdated, yes, and it has its share of typos, but once you get through at least the first few chapters (especially the ones where he builds from scratch how to make editable text input boxes and do the basic CRUD features on them), you should be able to make some basic but still functional (and not “scaffolded”–ugh) websites. The SitePoint publisher forum for this book is quite helpful for common typos, etc (Lenz even has a page dedicated to errata/corrections).The key is to copy code and modify them to your liking.

I also recommend the NetBeans IDE. It’s superb. Also, get the HAML ruby gem (which comes with SASS support), and the corresponding NetBeans HAML/SASS syntax highlighter (google it), and you’ll be on your way to some mad-quick development. HAML will save you quite a bit of typing–hours of typing in the long run (no closing tags!). Oh, and I highly recommend the FireBug Firefox extension if you don’t have it already. The SASS + FireBug duo is probably 10 ~ 15 times quicker than plain CSS editing (I can’t believe there are actually sites that still talk about CSS, when SASS is ultra fast for development (you could, if you want, use SASS for development only and just copy/paste the resulting CSS generated by SASS, statically, on your non-Rails sites).

Oh, and lastly, use XAMPP (or any other similar package). Why? No need to type in MySQL commands, if you’re using MySQL (like me, b/c to me it seems that MySQL has the most dominant presence right now). I worked through Lenz’s beginning chapters without typing in any unpalatable MySQL commands. ;) Just use the phpMyAdmin web app that comes with XAMPP on localhost to browse through database entries and do CRUD operations on them with intuitive, easy mouse-clicks. (And since you’ll probably be using FireFox for phpMyAdmin, this means that you can keep your prototype Rails app on the tab next to it (and while you’re at it, a tab with FireBug enabled on another part of the site you’re fixing up, etc etc)).

And finally, if you’re NEW to Rails and am just starting out from almost no programming background (like how I was), DO NOT bother with creating unit tests, functional tests, or any other tests. It is a waste of time when you’re trying to create a simple, ultra basic web app for learning purposes. I cannot tell you how many hours I spent trying to fix typos in Lenz’s book (either that or the test code in the book was outdated by the time Rails 2.0 came around) to get every unit test to work. Besides, Rails by default will present you with EXACTLY where the source code encountered a problem. I still haven’t written tests for my app–but I made sure during development to try out bogus input and to purposely make my app break for every method I wrote. And now my app has reached a point where it hasn’t displayed any errors (or anomalies) for the past month or so of continued usage. It’s actually better this way, in my opinion, because you’re FIRST learning to write good, reliable code from the get-go, instead of getting into the mindset of (“I’ll just test it later”). Writing function tests are not easy (just look at Lenz’s book–he has like 30-something tests for his super basic web app… I mean, how does he know that he only needs 30, and not 31? Or 29? So to sum up: don’t bother with test code if you’re starting out in Rails. Get the “feel” of Rails down first, and how the app behaves/responds to input, and then implement tests if you wish (…to work as a Rails developer, that is, and not just as a hobby).

UPDATE April 25, 2008: OK, people are still visiting this page to find out about LONGTEXT/LONGBLOB types for migrations. Here is my SQL-command that I used for my migration (in the full context of my 001_create_articles.rb migration file:

class CreateArticles < ActiveRecord::Migration
  def self.up
    create_table :articles do |t|
      t.string :title
      # and some other stuff that look like t.text or t.string
      # or whatever else
    end # END create_table

    execute 'ALTER TABLE articles ADD COLUMN body_text MEDIUMTEXT'

  end # END self.up

  def self.down
    drop_table :articles
  end

end # END class definition

You can replace mediumtext with longtext or longblob or anything else. The command above adds a new column called body_text to the articles table that already exists on the database.

UPDATE March 11, 2009: I don’t want to give out bad advice. I should have stated a long time ago that you should NOT use any IDE, even NetBeans. IDE’s and their GUIs and all that baggage slow you down a lot. Personally I use Vim, but any solid text editor should do.

October 28, 2006

Stayin’ Alive

Filed under: Law School, Rant — Shinobu @ 5:30 pm

Finals is coming up–there’s only about a month left in fall semester now. I’ve noticed that several of my classmates are missing–permanently. And here I am, doing all this work and studying that would make some people cry and leave. What am I doing this for? Sometimes that question comes up right after I finish a nice study session in the library. I’m doing this for myself. To prove to every person I meet after 2009 that I was able to take all the pain and suffering, and still come out OK. Law school is the academic battlefield of this country, it seems, and I plan to become a distinguished veteran. Sure, I’ll lose 3 precious years of my youth–but it’s all worth it. It IS. That’s why I’m not a quitter. That’s why I’m going to kick ass and Q.E.D. those @!#$ing final exams. Every one of them.

Blog at WordPress.com.