chenb•log

I don’t mind if I’m incomprehensible

Cloning Windows 7 onto yer SSD (Yet Another Method Of)

leave a comment »

I bought a SSD (the Intel X-25M) for my computer, partly because I read on the interwebz that running a virtual machine on a separate physical drive would greatly improve its performance. I also read on the interwebz that it’s possible to clone an install of Windows 7 from a HDD onto the SSD.

Well, it’s all gravy until things don’t work. And they sure it didn’t for me. I tried various tools in many different combinations over two long night. The steps below are what worked for me. YMMV (but probably not).

First, if you are reading this on the Windows 7 instance you want to clone, resize the OS partition to a size smaller or equal to the size of your SDD minus 100MB. It is easier to just make it slightly smaller. A perfect match in sizes is not necessary. You can do this with Windows 7′s Disk Management tool, which you can find by typing “partition” into the start menu search. Now download and install DriveImage XML. It’s free (as in beer).

Now shutdown your computer, disconnect your HDD, and start installing Windows onto the SSD. The install process will reboot the computer at some point. When that happens, interrupt it by going into the BIOS or something, and then shut the computer down. You don’t not need to finish the install.

Next, plug your HDD back in and change the BIOS to boot from it. Once you are back in Windows 7, you can see in Disk Management that there are two partitions on your SSD. One system reserved 100MB partition and the rest of the disk in a second partition. Neither of these have a drive letter assigned.

Fire up DriveImage XML. Select Drive to Drive copy. While selecting the source partition, check the “Raw Mode” option for some hardcore sector by sector cloning action. Then select the unfinished Windows 7 partition on your SSD as the destination.

Once DriveImage XML finished copying the partition, reboot the computer. Go into the BIOS and change the settings to boot from the SSD.

It should boot. You will see a screen saying that Windows was not properly shutdown. That’s because it was cloned while it was running. It’s cool. And you’re done. (And you know what, you’re welcome.)

Written by Barry

July 9, 2010 at 3:34 pm

Posted in Nerdy

Tagged with ,

Installing and Using Google V8′s sample shell

leave a comment »

The sample shell that comes with Google’s V8 javascript engine is pretty nice for playing with naked, DOM-free javascript.  Here are some notes to augment Google’s download and build documentation.

If you are building on a Mac, download and install Xcode with the the Unix development tools option selected.  This will take care of the compiler and libraries required for the build.

I symlinked the shell to /usr/local/bin/v8 for easy access.  v8 below refers to that, not the project name or the project source directory.

Naturally, typing in v8 starts the interactive shell. v8 --shell does the same thing.

v8 -e followed by a string of javascript allows you to execute that piece of code.

v8 followed by one or more file paths tells the shell to load and run the javascript files in the given order. Now if you add the aforementioned --shell, the sample shell will load and execute the file(s) and then starts the interactive shell.

You could also load files while in the shell by calling the load function. For example, load('hello-world.js'); will load and execute the file hello-world.js from the current working directory. Since the sample shell provides the load function, you could also use it in your javascript code. So instead of typing in v8 followed by over 9000 file paths, you could specify a file that in turn loads the other necessary files.

Another function the sample shell provides is print. That one’s self-explanatory.

There is also a read function, which reads a file into a javascript string.

If you know of a more advanced V8 shell, please leave a comment.

Written by Barry

April 3, 2010 at 8:12 pm

Posted in Nerdy

Tagged with , ,

JavaScript Closures (a fairly simple explanation of)

with 3 comments

I had a job interview recently.  I started the day by missing a flight, and then it was mostly downhill from there.  However, I did pretty much nailed a JavaScript question where the solution involved using closures.  The interviewer sounded surprised that I gave the solution; I was surprised at his reaction because I thought higher order programming, anonymous functions, and closures are common knowledge in JavaScript programming.

Below is my attempt at an explanation of what was used in the solution.  Hopefully it will help someone in an interview.

In JavaScript, you could define an anonymous function and immediately execute it:

(function(){ alert('zombies!'); }())

The wrapping parentheses are necessary here to turn that piece of code into an expression.  Otherwise you’d have a function declaration without a function name, and the JavaScript console will say something about a syntax error.  Alternatively, you could also write

(function(){ alert('zombies!'); })()

or

var testo = function(){ alert('zombies!'); }();

In the last example, we could leave out the parentheses because the code is in an assignment expression.

Of course, a function can accept arguments, so now let us do

(function(thing){ alert(thing); })('zombies!');

Same thing, but more work.

JavaScript functions can also create and return functions.  That means we can rock

(function(thing){ return function(){alert(thing);} })('zombies!')();

That’s even more work, with more parentheses.  In the above example, we create a function and called it with the string ‘zombie!’ as the argument.  That (outer) function then creates a function and return it, then we immediately call it with that last pair of parentheses.

To make it (slightly) more readable

var testo = function(thing){ return function(){alert(thing);} })('zombies!');
testo();

testo is the function returned by the outer function. And it always alerts about zombies. That’s the closure bit. The string “zombies!” has been closed over in the returned function.

One instance where this is useful is when you need the value of a variable that’s being updated, let’s say, in a loop. For example

var things = ['ghosts!', 'ghouls!', 'vampires!', 'zombies!'];
var alerts = {};
for (var i in things) {
    alerts[things[i]] = function(thing) { return function(){ alert(thing); }; }(things[i]);

}

There we go, closures.

Written by Barry

March 13, 2010 at 4:52 pm

Posted in Nerdy

Tagged with ,

(Small) Profit!!!1

leave a comment »

Hey, sexy readers, I’m in the process of selling my domain, so I’ve moved my blog to http://thatsobscene.wordpress.com/.  Everything will be automatically redirected until the domain is actually sold and transferred.  But you should update the feed url on your fancy blog reader.

Written by Barry

October 26, 2009 at 9:03 pm

Posted in General

Tagged with

X-Ray'd

with one comment

It has been more than six months since my surgery.  Here’s an update, with photos and grammatical errors.



Six weeks post-op.

Pretty much everything I read before the surgery said that I will be able to eat after six weeks.  Naturally I was pretty excited when I reached six weeks post-op, and then I was equally disappointed.  I tried but I couldn’t really eat.  My mouth didn’t open very wide, I couldn’t move the food once I got some in my mouth, and I couldn’t feel what the hell my teeth were doing.  Oh well!


Three months post-op.

Not that different from the photo above.  Although it was nice to kind of have my chin back.  (That’s my “good side” of course!)

My forehead and the tip of my nose always have been fairly oily, but during the healing process my entire face became extremely oily–something about healing nerves.  I considered applying for an OPEC membership.

Also, using a sonicare toothbrush on a mouth full of healing nerves is the most ticklish thing ever.  Srsly.


Six months post-op.

Ok, I don’t know what’s with the this picture. I look like I was high or been hypnotized or something.


Six months post-op. My less-good side.

(Thanks to Joe for taking these photos.)

Ok, X-rays…

That’s a month before the surgery, after about two years of braces, of which you can see in the picture.

That’s after, without the braces.  That shiny stuff are my fillings.  Notice all that stuff holding my upper jaw.  The effect is slightly exaggerated compared to the before picture because I was looking down a little more in the after picture.

You can see the screws for lower jaw better here.

As for the results, I don’t have an underbite anymore, but my bite still isn’t great.  My molar aren’t touching when I bite together, so while I can bite I can’t grind my food.  My orthodontist said I should wait a year before I should do anything about that because my bite could still change.

My lips still feel numb and a little stiff, especially the upper.  Occasionally I still get muscle spasms, which make my teeth clank together.  Not particularly painful, but annoying nonetheless.  I had a burger yesterday and I was just barely able to open my mouth wide enough for it.

Anyway, enough bawwwing.  The healing process could take up to a year.  I’ll post some before-and-after pictures then.

Written by Barry

May 10, 2009 at 11:41 pm

Posted in General

Tagged with ,

Do I?!?

leave a comment »

I have a fake date o’ birth on Facebook, because that’s just how I roll.  Combine that with my relationship status of “Single” –since Awesomely Free wasn’t an option– it means that 99% of the ads I get are “LOL U R OLD AND SINGLE MEET OLDER SINGLE WIMMINZ”.  These ads are usually accompanined with photos of college aged women.  Ridiculous.

(I use Google Chrome on mah super old PC at home –sorry Mike and Wil!– so I don’t get the AdBlock goodness.  And my hosts file can only do so much.)

And earlier tonight I saw this:

If I’m not mistaken, and I certainly am not, that is Elisha Cuthbert, who is famous for being hot.  C’mon now, if you gonna do that, put up a picture of Salma Hayek, who is actually over 40.

The last time I saw Elisha Cuthbert’s image misused without permission was on one of those cards “they” hand out on The Strip in Vegas.

Written by Barry

February 2, 2009 at 2:14 am

Posted in General

Tagged with

Post-op Photos

with 3 comments

I peeked at my files while I was waiting during a post-op appointment; the surgeon’s plan was to move my upper jaw forward roughly 3mm and down 2mm (apparently my upper teeth had a bit of an angle) and my lower jaw back roughly 3mm.
 

one day post-op
One day post-op.

A few people asked me about being in pain. There wasn’t much pain. The post-op experience is more pain in the ass than painful.

Imagine all the things you can do with your facial muscles. Well, now you can’t. You basically have no control of anything on your face below your eyes. (It would be totally fucked up if you lost control of your eyelids no?) Can’t smile. (It hurts to watch The Daily Show and Colbert Report.) Can’t spit. (You’ll miss this very much when you cough up stuff behind your banded teeth and after rinsing your mouth with stuff.) Can’t suck. (Some people brought up drinking through a straw when they learn of my surgery. I wish; milkshakes would’ve been very nice.) And so on. Oh, your face is also the size of Jupiter. And for about a week you’re constantly drooling, which is extremely inconvenient. And for a day you can’t breathe through your nose at all.

So there you are, standing over the sink, drooling out of the front of your mouth, sucking air through the back of it, and then you’d try to drink your meds and food without losing a quarter of it to the sink.

There’s more, but of course everything improved gradually. Very gradually. (Parentheses!)


Four days post-op.

Note the yellow bruising on my face and neck.  It didn’t stop there…


Six days post-op MySpace foto 5tyle.

It got even wider and moved slightly lower after that picture was taken. I still have a couple of spots on my chest after almost four weeks.



One week post-op.



12 days post-op.



Two weeks post-op.

Finally told my sister that we want to see the changes on my face, not the wall or my torso. In other words: zoom in plz.

When Joe and Sam got their kittens, I put up a picture of them with me. Now that they’ve got a child…


Barry: 20 days post-op. Penelope: 0 day post-birth.

Lil’ Penny: Uncle Barry, what the hell was wrong with your face?
Barry: Where the hell did you learn to talk like that? I know your parents don’t speak like that.

At any rate, when I score the x-rays, I’ll put them up.

Written by Barry

November 24, 2008 at 10:54 pm

Backwards, Forwards

with 3 comments

New York, New York

I was going to post a few photos and say some silly nonsense about my six day trip to NYC. But then I got lazy and busy. Now the appropriate window for a post-trip entry clearly has passed. And I’ve got something more important to tell my nine regular readers.

So just one protip if you are going to visit New York (and you should): go to the observatory at the Rockefeller Center, “Top of The Rock”, if you want to see Manhattan from above. Do not go to the observatory at the Empire State Building.

Surgery

On October 28th I will be getting orthognathic surgery to correct my epic underbite. My former, now retired, orthodontist said my underbite was the worst he has seen. I’ve been wearing braces for two years now; it’s about fucking time.

The surgery basically involves cutting and moving my upper jaw forward and the lower jaw backward. My case is too severe to move only the lower jaw back.

For those of you who are interested, the two procedures are called Le Fort I Osteotomy (upper) and Bilateral Sagittal Split Osteotomy (lower).  For the lower jaw there is also the Intraoral Vertical Ramus Osteotomy.  Although I haven’t asked my surgeon why he chose BSSO over IVRO.

Effects

This is what I really want to tell my readers: I will look different.  Mainly because someone will move parts of my face.

I don’t know how different.  After my sister’s surgery (only the lower jaw since her case wasn’t as severe), our uncle and the people at her orthodontist’s office thought she looked unrecognizably different.  I didn’t think she looked that different.  Her face was shorter and her cheeks got bigger.  But unrecognizable?  Nah.

I will also have titanium in my face.  How awesome is that?  (Very.)

Good News

My sister’s jaws were wired shut, and she was on a liquid diet for six weeks.  Since it’s difficult to sustain one’s weight on a strictly liquid diet (especially when it can be painful or tiring just to drink), she started losing weight and her body went into preservation mode and slowed down her metabolism.  When she started eating again, she quickly gain too much weight because of the slowed metabolism.  After she told me all that, I simply said “no, I’m not going to gain weight.”  It all made sense, although I didn’t check how the body respond to rapid weight loss.  And it’s not that I think my body is somehow different.  I’m just too god damn stubborned to let my body gain too much weight.  Plus if metabolism can swing one way, then perhaps a person can get it to move the other way too.

But I was very worried about weight loss, simply because I don’t have much weight to lose.  Fortunately, my surgeon told me that he won’t be wiring my jaws together.  Best thing ever.  While I won’t be able to chew for six weeks, I can still eat soft food.  That will make maintaining my weight much easier.

An Investment with Daily Dividends

Take out your health insurance member handbook and find “orthognathic surgery”.  Is it listed under exclusions or something like that?

On one hand, I should be upset that “insurance” won’t help pay for the surgery at all.  It’s the only thing I want done; I’ve never used my health insurance for anything.  (Hell, I actually waited until I had a job with dental and health insurance before I started orthodontic treatment.  Wrong move.  Wasted time and didn’t really save money.)

But I’m also thankful that I live in a country where a man of my modest intelligence is able to earn and save enough money to pay for such a surgery, and well-trained surgeons are readily available.  I was born into a place in China where no one had braces.  I certainly have never heard of them until I came to this country.  I don’t think our town had an orthodontist.  (Most people didn’t even have indoor plumbing.  But I don’t want to digress too much.)  I wonder how much things have improved.

 

tl;dr: orthognathic surgery soon; will look different.

Written by Barry

October 7, 2008 at 11:52 pm

OSCON Day 2

with one comment

So far: meh.

Right now I’m in the MySQL Storage Engines talk by Peter Zaitsev of the MySQL Performance Blog. Should be interesting.

zomg mindtouch win @ booth babe. Think a mix of Bridget Monahan and Morena Baccarin.

Written by Barry

July 24, 2008 at 4:48 pm

Posted in Nerdy

Tagged with ,

OSCON Day 1

leave a comment »

I’m live blogging from OSCON, bitches.  Just gonna be some random notes updated throughout the day…

I was working during the keynotes, so I didn’t pay close attention, but O’Reilly was talking about the popularity of some languages and frameworks, CakePHP was not on the list.  This is A Good Thing.

Yesterday I encountered a bug in Cake that gives me the rage.  I was doing a $model->findbySomething where the argument for something is a random generated string like `48784231410e978`.  Cake was like “oh an exponent, and since it’s a number I’m not a gonna qoute it in the SQL.”  Oh fuck you Cake.  Now I’m getting a MySQL error because you are passing a massive number (e978 is HUGE) to a varchar column.  WTF!

Anyway, the first session I went to was Terry Chay’s “The Internet is an Ogre“. It wasn’t that educational, but it was fairly amusing. I like that Chay said “shoot” when something with the presentation went awry, but dude was all “fuck” and “shit” during the presentation.

Right now I’m in the “Metaprogramming in Ruby” session. Too much Ruby this Ruby that, not enough meta-programming so far. Also, dark blue font on black background does not show up well on projection.

Of course, OSCON is same as always. Over 9000 nerds, but only 3 of them are female.

Today OSCON lunch was brought to us by Google. It was so much classier and better than previous years. And like I said to Montana, it probably cost about five seconds of Google’s revenue. (It’s probably less, but I’m too lazy to do the math.)

The dude from Google doing the Code Review session I’m in right now mentioned this book. This guy <3 peer programming.

Code review tools: rietveld, review board, codestriker, java code reviewer (written python and reviews more than just java code).

So far the dtrace session was the coolest. It spilled over by 14 minutes and almost everyone stayed, so you know people were into it.

The file IO talk was pretty interesting. One trick the speaker mentioned is to write to a temp file, fsync, close, and then rename. So if the write fails, the original file is still intact. Of course, don’t do for large files. Apparently Evolution does this trick even if your mailbox file is huge.

Also, on OSX fsync() doe NOT sync your shit to the disk. LOL

The speaker also recommend using sqlite when appropriate. This way you don’t have to worry about all the data integrity stuff.

Dude said WIN and FAIL way too much though…like, over 9000 times!

Whoa whoa whoa, free beer and wine during after hours? Too bad I’ve got this headache. (I’m staying after for a while because there are no internets at my parents’.)

EDIT: regarding the CakePHP thing I bitched about–it’s not totally Cake’s fault. is_numeric(’48784231410e978′) in PHP returns true. Perhaps Cake should check the column type or somethin’.

EDIT II: Cake 1.2 is totally checking the column type yo!

Written by Barry

July 23, 2008 at 12:12 pm

Posted in Nerdy

Tagged with ,

Follow

Get every new post delivered to your Inbox.