chenb•log

I don’t mind if I’m incomprehensible

Archive for the ‘Nerdy’ Category

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

with 4 comments

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.)

Advertisements

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 ,

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 ,

sudo beer me

leave a comment »

I learned that this year’s OSCON coincide with the brewfest.  So there might be a lot of nerds at the brewfest. Is this awesome? (Y/N) HINT: TOTALLY YES.

Oh god, I just hope we won’t start yelling memes after over 9000 beers…

Written by Barry

July 13, 2008 at 4:48 am

Posted in General, Nerdy

Tagged with , ,

Unaware and Don't Care

with 2 comments

I drove with a friend to Kent, WA to visit another friend last weekend.  Aside from getting high blood pressure when I found out my longtime friend is a Republican who voted for Bush and yet haven’t even heard of Scooter Libby or Abu Ghraib, and getting a painfully annoying sunburn, I also tried to explain what open source is to my friends.

During the course of conversation, Jeff, my friend Steve’s fellow SCCA Time Trial racing and Subaru STi owning friend, mentioned a couple of open source projects that allow him to flash the Engine Control Unit (ECU) of his car, which is friggin’ sweet.

I was slightly surprised later to find that neither of my friends knew what open source is.  That was because I know a bunch of geeky people who work on software and know what open source is and know IE is responsible for the death of Jesus.  (They are also left leaning, Democrat voting, socialist-commies!)  It was a reminder that outside the circle of software developers, CIOs, and tech company executives and lawyers, not many people know what open source is.  Or even care.

That’s totally okay.  It doesn’t matter.  The only thing that matters is the quality of the software.  How many among the millions of Firefox users use it because of it’s open source?  Or even know that it is?  (Please save Jesus by using Firefox.  Or Opera.  Or Safari.  Or…OmniWeb?  Just stop using IE!)

Anyway.  I don’t think I explained open source very well.  I used a counter example with Windows.

How would you explain open source to people who don’t know about software development?

Written by Barry

May 27, 2008 at 10:02 pm

Posted in Nerdy

Tagged with , ,