21 October 2017

Of Batch Files, Double-Quoted Comma-Delimited Text Files, and VBScript

Hello World!

It's been such a long time since the last post. Almost 2 years! Time does fly.

Why the sudden resurrection of this blog? Let's just say it's the desire to learn rekindled again!

I'd mentioned on several previous posts (I think I did at least) on this blog that I used to work as technical translator for a software dev company back in the Philippines. The team I served with my language skills (greatly diminishing instead of improving - I cringe at the multiple and redundant grammatical errors my posts here contain!!) were Java developers. They tried to teach me how to code in Java. I remember that "Beer Song" exercise that when I'd resolved, I dropped Java like a too hot pancake in my hands. Since it had splattered on the floor already, why bother picking it up? There were more interesting and yummy pancakes at that time (ehem - like hackintoshing) to get my hands on!

I remember explaining to my team mate - who was a freakin' awesome Java programmer - and close friend that I just couldn't accept why methods, objects, etc. must be declared first. On retrospect now,  perhaps there was just the general lack of a motivation for me to force my brain to wrap itself around the proclivities of decent Java coding: i.e. the need to make things work.

For I realize I did dip my elbows in code when I was finding my way through the cog works of hackintoshing, specifically DSDT patching. I was surprised to learn that it involved, in fact, coding at a much much lower system level than say the commonly known object-oriented programming languages like Java, Python, etc.. Java worked inside the Operating System and interacted mostly with the files and file system therein, while dealing with DSDT meant interacting with the BIOS. (More info on DSDT here)

I had to patch my own DSDT to make sure low system level processes like wake-up from sleep triggered by mechanical actions like closing the lid, hibernation, fan speed, etc. for my own hackintoshes because most of the hacking guides available were for North America models of said machines and I was in Asia. I had to do a lot comparison and reading the code lines of those other hackers posted and looked out for patterns. Some object names would differ by one character between those posted codes and the actual DSDT extracted from my own Asian release model laptop or netbook. It was trial and error, testing, and squeezing out comprehension from cryptic lines as the example section here:

/*        Name (\LIDS, One)   */   //comment out as per code structure
        Device (LID)
            Name (_HID, EisaId ("PNP0C0D"))   //LID detection
            Method (_PRW, 0, NotSerialized)
               Return (Package (0x02)
            Name (\LIDS, One)   //added as per code structure
            Method (_LID, 0, NotSerialized)
                Store (^^SBRG.EC0.ELID, LIDS)   //LID register
                XOr (LIDS, One, Local0)
                If (Local0)   //If LID is closed
                   Notify (SLPB, 0x80)   //puts system to sleep
                    Store (One, LIDS)
                Return (LIDS)

I remember this is to correctly trigger sleep from closing the laptop lid and if my memory serves me right, after long hours of sleepless nights, I tried adding 'S' to the 'LID' entries in there just because I had ran out of logical things to try even after scouring the interwebs and even downloading HP's BIOS manual. Miraculously, it was the key! I don't regret reading the HP BIOS manual because I was able to deduce some of the lines' function . I put my learning after "//". It was fun to discover "Oh so that 0 there is closed lid and 1 for open lid!". Perhaps it was akin to how Jean-Fran├žois Champollion felt when he finally deciphered the Egyptian heiroglyphs after years of studying the Rosetta Stone.

Of course, if you asked me if I still understand DSDT now, the answer is an honest not at all. Hehehe. There's just no urgency for my lazy brain to even switch on and make an effort to re-learn, after all, I've been blessed now with a real Mac ;)

Recently, I had to find a way to manipulate .csv files (comma-delimited text files) to do a sort-of-vlookup process and all to be done via batch file.

I hate Excel, formulas, and numbers in general. It's beyond question that I even try to learn macros much more VBA. It's natural human instinct to stay away from things we abhor, right?

But the problem of making that vlookup routine work in an automation project piqued my interest and I was hooked in. I gave up my time for watching Korean dramas for lurking on Stackoverflow forums for which I was rewarded with a VB Script.

I resulted to that familiar method of trial and error and pattern search. Finally, the lines of heiroglyphs - err, sorry code - made sense. I present to you for scrutiny and judgment, the discoveries

'Load dictionary entries from text file of replacements
Set oInFile1 = oFSO.OpenTextFile(cInFile1, cForReading)
Do Until oInFile1.AtEndOfStream
aLine = Split(oInFile1.Readline, ",") 'reads lines in File1, taking items as spearated by a comma
If Not oDict.Exists(aLine(0)) Then 'adds each item and corresponding values to the dictionary array where we will use later (loaded into memory?)
oDict.Add aLine(0), aLine(1) 'there are 2 items per line, 0 and 1 - begins with 0!!
   End If

'Read input file, lookup replacement, write new output line'
Set oInFile2 = oFSO.OpenTextFile(cInFile2, cForReading)
Set oOutFile = oFSO.OpenTextFile(cOutFile, cForWriting, True)
Do Until oInFile2.AtEndOfStream
aLine = Split(oInFile2.Readline, ",")
ReDim Preserve aLine(UBound(aLine)+1)
aLine(5) = aLine(4) 'moves 3rd item in row to the 4th 
aLine(4) = aLine(3) 'moves 2nd item in row to the 3rd
If oDict.Exists(aLine(2)) Then 'this is the lookup part - checks if 3rd item in a row has a dictionary entry
aLine(3) = oDict.Item(aLine(2)) 'loads the value of that item found rom the dictionary in memory to the 4th item in a row
End If
oOutFile.WriteLine Join(aLine, ",") 'joins the items in a file


12 January 2016

Pebble Time Round

I've always been skeptical about smart watches. Don't we have loads of variations from Apple and Android wear manufacturing companies that dole out the features included in this devices supposedly tiny and to live on your wrist? To me, it's another complication to add to my life plus, they all seem to scream out "smart watch! look at me!" from the get go.

I don't need a ton of features from a smart watch; those are what my iPhone should do. What I want from a smart watch are 2 things:
  • A reliable watch
  • Some smart features like notifications and fitness tracker

Then Pebble released Pebble Time Round and it fits the two demands I spelled out above just nicely.

It's a stylish watch with an always display thanks to its e-paper technology. Works perfect with the ample ambient light inside the office - I don't have to flick my wrist or fibble with the button to turn on the back light to see what time it is. Using e-paper meant that it's even much brighter and easier on the eyes in direct sunlight where other OLED based smart watches would leave you scrunching your eyes to check the time.

I opted for the 14mm band because I didn't want the hour markings along the white bezel that the silver 20mm version had. Although the 14mm band was just right for my wrist and the 20mm would've swallowed up my wrist whole, I'm still worrying about finding a good strap replacement. Most replacement bands are available in 20mm.

Currently, I'm still loving the stone colored soft leather that comes with the watch by default but I'm on the look out for a silver Milanese-like mesh loop in 14mm.

People would say the Pebble watches are too low tech compared with the other offerings already available and at around the same price point (I got mine during the holiday sale with USD 199 instead of USD 249). However, I do believe that the Pebble Time Round still holds its ground and delivers adequately and beautifully.

Due to Apple's locking down of its watch API, features on notifications interaction are more limited for iPhone users than Android users.

It doesn't claim to the "be-all-do-all" niche that most other smart watches seem to try to accomplish, having an identity crisis in the end: "Am I a smart watch or a phone?". 
What Pebble does is clearly define what it wants to be and do, and then it makes sure it ticks all those items nice and squarely, even the buttons on the watch give off a satisfying tactile click and pressed.

If you're looking for a gorgeous watch that functions flawlessly as a watch, comes with ample battery life, and performs perfectly on notifications and some added features to get organized and fit, then look no further than the Pebble Time Round.

28 November 2015

Pipo W4

I'd like to take this oportunity to pay respects to MacBook Mini; the HP Mini 311 I purchased on a 12-month installment scheme back in 2009 or something, when all the rage was on netbooks. I'd installed Mac OS X Snow Leopard on that little machine that I loved and even created a blog - this very blog - so that I could spout sonnets to the whole world about that love.

I'm grieved to announce that MacBook Mini has passed away. It has been acting up on my dad for quite some time now, shutting down when its fans whirred away, unable to tolerate the heat that would build up over a period of use that shortened as days went by, until one couldn't use it without blasting at least a fan towards its direction. Well, I blame myself partly because I subjected it to hackintoshing. Ok, I don't think I would've bought it in the first place if I couldn't hackintosh it. Me thinks it's the fact that the DSDT may not have been optimal for the hardware in terms of CPU throttling and heat dissipation. Add that to the fact that it's just so very hot in the Philippines and the HP Mini 311 was not getting any younger.

Although I did try to remedy the situation by installing Windows 7 on it, believing that the heat issue will be addressed by giving it to the OS it was designed to run in the first place. True enough, it did happily chug along after that and I was able to give it away to a young university student who needed to have a laptop for school. I was certainly convinced that heat issue was gone. Low and behold, only a few months with its new owner, HP Mini 311 breathed its last.

I'll be forever thankful for the wealth of hackintoshing knowledge I garnered and now have forgotten through that machine. However, the pressing issue remains: What will the university girl (which my mom and dad along with their Bible study group support through college) use for school now?

To find the solution, I racked my brain and thought: What if I were back in university - what gadget would I appreciate? Now, I certainly love working with the Samsung Galaxy Note 8.0 and now that is has a Zaggkeys Folio case, I'm really enamored by the portability and the added productivity I get with Microsoft Office 365 (thank you to my current company who gave each of its employee a good license bundle which allows me to install Office in other mobile devices aside from my office laptop). In fact, I wrote this entire post from my Note 8.0 + Zaggkeys Folio.

I just knew that giving "our scholar" anything less than that same convenience I now enjoy is not the answer.

She has to have a tablet for portability. But one that can let her write her school papers and create powerpoint presentations for class projects and stuff and install other full desktop applications. Android and iOS are already out the eligibility list.

That leaves one option: Windows tablet. And I have just the right soluion for that: Pipo W4

It's an 8" tablet with Windows 8.1 and Office fo 1 year. And I got a great bargain from Lazada Singapore at only S$99 (free shipping). It's the perfect size for her to carry around for consuming media and stuff.

How about the productivity part? Obviously the 8" screen won't offer the best experience for a student who will juggling several applications side by side, very unlike the way I use my Note 8.0 now.

Remember the Motorola Bionic Lapdock I bought for my Raspberry Pi experiment, which sadly didn't bloom into the coding heaven I envisioned partly because of my lazyness to learn coding seriously? We'll it's got everything to turn the Pipo W4 into a decent laptop.

Keyboard. 11" screen. Trackpad (serviceable but one is better off using a mouse instead). 2 additional normal-sized USB ports (female). Headphone jack. Micro HDMI (male). Micro USB (male).

Unfortunately, the Micro HDMI and Micro USB ports are oriented the wrong way on its cradle connector section and do not match up wit the Pipo W4's port arrangement. It's a good thing that I already have a micro USB extender cable and a micro HDMI to regular-sized HDMI cable as surplus from my Raspberry Pi experiment.

I only had to get an HDMI to micro HDMI adapter (S$1.69) and voilà! The Pipo W4 is now an 11" laptop.

I'm wrought to part with the Motorola Bionic Lapdock because I consider it my handy partner in Pi experimentation since it provides me the screen and input I need. But then, is it healthy for a 30 year old woman to be still playing with toys??