Monday, November 9, 2015

Meteor Install Path on Windows

It is on
<Your User folder>/AppData/Local/.meteor

But if your problem is you cannot start meteor on Windows in Command Prompt, holds on. You do not need to set the environment with that path. Just RESTART your windows will do. Trust me.

Friday, October 30, 2015

Parsing JavaScript with Esprima vs ANTLR

My original thought is that, the compilation for ANTLR 4 Esmascript (I am using C# target)
(https://github.com/antlr/grammars-v4/blob/master/ecmascript/ECMAScript.g4)
should be faster than Esprima
(http://esprima.org/)

It turns out that it is not.

I use jQuery.Mobile 1.4.2 to experiment:
ANTLR 4 makes use of 1 minute,
while
Esprima only makes use of 100 milliseconds.

Esprima is much faster than ANTLR 4.

Not only I have observed this, I have found some complaints of the speed of ANTLR 4 for JavaScript by other people:
https://groups.google.com/forum/#!msg/antlr-discussion/AUN7BLSDIzo/KG5MQ95Us9gJ

If you are gonna decide which to use, I am here to save your time: choose Esprima.

Saturday, August 22, 2015

Produce problems for yourself

Netflix has moving their application to the cloud, leveraging the hardwards in Amazon EC2.
They adopt an architecture call micro service architecture, which breaks normal components in to microservices. These microservices work together to achieve a task.

Microservice could be failed - maybe due to network congestion or simply unavailable. To proactively deal with failure of microservices, they make use of Chaos Monkey in Amazon EC2 that could purposely turn off the microservices. This helps them to see their resilients against failure.

I feel this is a good approach. Rather than waiting for problems, PRODUCE problems for yourself. This allows yourself to have time for fixing or preparing it. Nicely done!

Thursday, August 20, 2015

Where is my quora credit?

Well, recently, quora has not discontinued the usage of credit. They have switched to another reward system which is introduced as follows.

====

How the new Ask to Answer system will work:
Ask to Answer requests will no longer cost credits. Anyone can send an Ask to Answer request to anyone else. Ask to Answer requests will be prioritized based on both quality and volume. High priority requests will go directly to the intended recipient and other requests will be aggregated. Prioritization will be based on a number of factors, including: 
  1. How many requests the target writer receives and subsequently answers over a period of time.
  2. Whether the specific question is tagged with a topic that the writer has expertise in and/or which is listed in the writer's Knows About profile section.
  3. Whether the request is sent from a person that the writer follows and/or interacts with regularly.
Regarding notifications about Ask to Answer requests:
  • For high priority requests: As before, for each of these requests, you will get individual notifications:
===

Find here for more details.

Sunday, June 7, 2015

BB Flashback setting for Youtube Video

Click on Tools>Options in Tools Options

Display (One Time Setting)
Checked the following options:
"Switched off windows graphics effects"
"Disable the "show window contents while dragging option"
"Change resolution when recording" (1280x720)

Use the following options when Exporting Video:
1. Choose AVI
2. Under XviD MPEG-4 Codec, Choose COnfigure [Can download it here:https://www.xvid.com/download/]
3. Click on "Target quantizer"
4. Type 1500 as bit rate (original is 700)
This is one time setting, after setting, if you choose export, just export it without extra changes.

Saturday, April 25, 2015

How to vectorize your signature with Inkscape

It’s often useful to add your signature to a Word document instead of manually signing the actual paper with one of those pen thingies. Of course, the easiest method is to just sign a piece of paper, scan it, and insert it as an image. It’s simple to do, but because the scanned image is a bitmap it often looks rubbishy and pixellated when you print it or save it as a PDF.
The solution is to create a vector signature that is guaranteed to look fantastic at every scale. There are lots of methods out there. Here’s mine – it uses free software and is quick to do.
1. Sign a piece of white unlined paper. Choose your best, most representative signature, and scan it (400 dpi or so is usually good enough). Here I’m using the signature of a famous personage that I found online, rather than my own embarrassing scrawl.
2. Change the image to grayscale, and adjust the levels – Auto Levels usually does the trick. You can use Photoshop if you have it, but I use GIMP (GNU Image Manipulation Program), which is free and awesome. Get it from www.gimp.org/downloads. Save the signature as a JPG at high quality (95 or so). It should now look more like this:

3.  Open in the file Inkscape (the open source SVG graphics editor). You can download it from inkscape.org/download – it’s also free and awesome.


4. Resize the page to fit your signature (File menu -> Document Properties -> Fit page to selection):




5. Create a vector version of the signature by using the Trace Bitmap function from the Path menu. You can play around with the settings to fine-tune things, but I find I get good results using a single scan, the brightness cutoff method, thresholds at 0.880 and 0.970, and a 2 colour output. Press OK.


6. Your vector image is now sitting on top of your bitmap image, which you no longer need. Delete it by selecting it, moving it to the side, and pressing the delete key.



7. Resize the page to fit your new vector signature (File menu -> Document Properties -> Fit page to selection).


8. Now save it! From the File menu, choose -> Save As -> Enhanced Metafile (.emf).  There are lots of different vector filetypes you can use (.svg for example), but .emf is a good format for inserting into Word.
Then just insert your signature into Word as a picture, making sure the scale is appropriate (this might involve printing it out a few times to check). Make the image sit “in front of text” if you want to allow it to slightly overlie the typed text.
So that’s it! The result looks very professional, prints really well (it looks jet black on a laser printer!), and withstands infinite zooming when it’s in a PDF:





Wednesday, March 4, 2015

Writing Clean Code

I accumulated some reference

1. Put good comments on SVN, like what you want to test.  Retain those code that might be used again in the svn, and delete it from your code to keep it clean.
2. When you want to try a new function, a good way is to create a new class. Not create a new function in the class, that will make the class looks too bloat.
3. When the function is working, congrats keep it for the paper. If not, just delete it (note that the version still contain in SVN).
4. People says read code vs write code, times is 10 vs 1. Can't agree on that more. When you create a new class, try a new algorithm, try to record your idea somewhere (written in comment, if too complex a video). so that you can recall it. When you define a function, comments on its purpose and so on.
5. When trying a parameter, define it at a centre place. Cleaning the parameters once in a while.
6. Should have a rule on variable naming. And be consistent on it.
7. Test-driven development will save you lots of time finding bugs, and recreate the same test case. Write unit-test forefront.
8. Define some common libraries when you are coding, and find yourself code the same thing over and over again. Replace all codes with the libraries code for easiness of maintainence.