Thursday, October 16, 2014

Keyboard / trackpad non-functional after winclone restore for macbook pro 2014 mid retina

Problem first, I restored one windows 7 using winclone, when I boot back to the new restored windows 7 partition. Gosh, neither keyboard/Trackpad works, tried several external USB keyboard/mouse no lock at all.

then I Googled, found the official faq from winclone, tried the bless tips. No luck. then after 2 hours struggling. Here is the step to make it work.

Boot into Mac, remove the windows partition through the disk utility. Don’t Create a new windows one using the disk utility.

open the Bootcamp Assistant utility, check the all the options. and continue, then it will load the ISO and download the drivers, after that, you get chance to resize the bootcamp partition. Now it’s the time to create the bootcamp partition .

once done, it will reboot and enter the setup process. Stop here, reboot and press option then select the mac partition.

Now it’s safe to recover the bootcamp partition using winclone. after done, here is what I did. not sure which step is important, but this works.

  • go to utility, terminal
    • sudo /usr/sbin/bless –-mount /Volumes/BOOTCAMP –nextonly –legacy –legacydrivehint /dev/disk0
  • in the windows boot time, press any key to cancel the disk check.
  • that’s it, it works now. both keyboard and touchpad. download and install the new driver for windows now 
    • check this table and select the right one/ good luck
  • http://support.apple.com/kb/HT5634
  • image

Tuesday, October 14, 2014

Git tips, how to generate patch and apply it

we have one version , for demo. just called file.txt with version1 as the content.

image

after we change it to version 2 , we can run git diff  and redirect output to a patchfile.

by default, diff put  a/b as the prefix.

image

then we reset the workspace and try to apply the patch

image

for some version, you might put patch –p1 to apply the patch , basically means ignore the a/b prefix.

for the generation, we can put –-no-prefix to remove the prefix

image

 

for binary file, we can put –-binary option to generate the patch.

and use git apply –binary to apply the patach.

to tell the diff difference summary you can put the –-stat option.
image

there might be several commits after the last update, you can use format patch to generate one by one if you like

image

 

to apply stacks patch

image

Regular expression tips, match repeatable characters.

Regular expression has a powerful support for submatches (subexpressions). here are some powerful match.

if you user got a sticky keyboard, you may enter something like ‘gooooooooooooooooooooooooooooood’, or ‘happppppppppppy’ how to remote the duplicate o or p.

you can use (.)\1{1,} to match. basically the first group means match any character, \1means this is a subexpression or a variable. {1,} means this have to be repeated for 1+ times.

image

but if you user got a stick paste key, it mays shows a lot repeated words. like the good example .

we can put (.+)\1{1,} , you can tell it only match 4 good, not five. why? 

image

because it try to find a repeatable patter , so two good, as a variable, and occur 2 times. , if we have even number of good, it will match all.

image

what if we want to match all , basically certain word been repeated for 1+ times, we can put a ? in the subexpression, means non-greedy match. so it will just match one word which is not greedy, then repeat for 1+ times.

image

Wednesday, October 8, 2014

Node.js tips-1, put your configuration in a special .json module, selenium webdriver

if you use node selenium-webdriver to do a basic UI test, here is a quick sample code to open google, enter the keyword and do the serach, then validate the title. https://www.npmjs.org/package/selenium-webdriver

image

if you check the code here, a lot hard coding, bot the url and title are hardcoded here. to prevent this, we can create a json file, put the configuration there. and save it as a .json file.
image

then in the json file, put a require module there, and we can use it directly. no parsing needed.
image

after this, run again, make sure we never break any logic.  can we still improve it?

image

we have to key in the whole helper method webdriver.By.name, let’s improve it. create another module called makenameselector.js

image

now in the test.js , we can promote the selector string to nameselctors.

image

then no more hardcoding, no more duplicate webdriver.By.name

 
Locations of visitors to this page