<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Erxin, Shang(Edwin, 尚尔鑫)&#039;s Home Page &#187; Uncategorized</title>
	<atom:link href="http://www.shangerxin.com/?cat=1&#038;feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://www.shangerxin.com</link>
	<description>Knowledge should be free.</description>
	<lastBuildDate>Tue, 24 Aug 2021 02:27:23 +0000</lastBuildDate>
	<language>en-US</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.8.13</generator>
	<item>
		<title>Tips for resolve pip install error for some of the python 2.7 package on window</title>
		<link>http://www.shangerxin.com/?p=343</link>
		<comments>http://www.shangerxin.com/?p=343#comments</comments>
		<pubDate>Thu, 21 Dec 2017 01:27:48 +0000</pubDate>
		<dc:creator><![CDATA[Shang Erxin]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://www.shangerxin.com/?p=343</guid>
		<description><![CDATA[Pip is a wide used python package management tool, it works properly most of the time. But occasionally there will be a few error when install some special package which may required local build after download. Here are two common ways to resolve these kinds of error 1. Use a prebuild binary, the most common [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Pip is a wide used python package management tool, it works properly most of the time. But occasionally there will be a few error when install some special package which may required local build after download.<br />
Here are two common ways to resolve these kinds of error </p>
<p>1. Use a prebuild binary, the most common library could be download from <a href="http://www.lfd.uci.edu/~gohlke/pythonlibs">here</a>. But the links seems dead for a while.</p>
<p>2. Install the necessary Cpp compiler for python 2.7 on window from <a href="https://www.microsoft.com/en-us/download/details.aspx?id=44266">here</a></p>
<p>After install the compiler rerun the pip install
<package> again</p>
<p>Good luck!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.shangerxin.com/?feed=rss2&#038;p=343</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Polyfill for Utf8toUtf16 for JavaScript</title>
		<link>http://www.shangerxin.com/?p=295</link>
		<comments>http://www.shangerxin.com/?p=295#comments</comments>
		<pubDate>Tue, 20 Sep 2016 09:30:50 +0000</pubDate>
		<dc:creator><![CDATA[Shang Erxin]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://www.shangerxin.com/?p=295</guid>
		<description><![CDATA[As we know the TextEncoder will drop support utf-16 and other legacy encoding types from Mozilla. Google also confirmed it and Chrome will only remain support utf-16 encoding. Here is a polyfill implementation for convert utf-8 string to utf-16le &#160; Reference: https://bugzilla.mozilla.org/show_bug.cgi?id=1257877 https://www.chromestatus.com/feature/5630760492990464]]></description>
				<content:encoded><![CDATA[<p>As we know the <a title="TextEncoder" href="https://developer.mozilla.org/en-US/docs/Web/API/TextEncoder">TextEncoder </a>will drop support utf-16 and other legacy encoding types from Mozilla. Google also confirmed it and Chrome will only remain support utf-16 encoding.</p>
<p>Here is a polyfill implementation for convert utf-8 string to utf-16le</p>
<div id="wpshdo_1" class="wp-synhighlighter-outer"><div id="wpshdt_1" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_1"></a><a id="wpshat_1" class="wp-synhighlighter-title" href="#codesyntax_1"  onClick="javascript:wpsh_toggleBlock(1)" title="Click to show/hide code block">Utf8toUtf16 Polyfill</a></td><td align="right"><a href="#codesyntax_1" onClick="javascript:wpsh_code(1)" title="Show code only"><img border="0" style="border: 0 none" src="http://www.shangerxin.com/wordpress/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_1" onClick="javascript:wpsh_print(1)" title="Print code"><img border="0" style="border: 0 none" src="http://www.shangerxin.com/wordpress/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://www.shangerxin.com/wordpress/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://www.shangerxin.com/wordpress/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_1" class="wp-synhighlighter-inner" style="display: block;"><pre class="javascript" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">function utf8ToUtf16(s) {</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">	var a = new Uint8Array(s.length * 2),</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">	view = new DataView(a.buffer);</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">	s.split('').forEach(function (c, i) {</div></li><li style="font-weight: bold; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">		//the third parameter equal to true indicate little ending</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">		view.setUint16(i * 2, c.charCodeAt(0), true);</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">	});</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">	return a;</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">}</div></li></ol></pre></div></div>
<p>&nbsp;</p>
<p>Reference:<br />
<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1257877">https://bugzilla.mozilla.org/show_bug.cgi?id=1257877</a><br />
<a href="https://www.chromestatus.com/feature/5630760492990464">https://www.chromestatus.com/feature/5630760492990464</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.shangerxin.com/?feed=rss2&#038;p=295</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hook All the Functions in JavaScript Files</title>
		<link>http://www.shangerxin.com/?p=274</link>
		<comments>http://www.shangerxin.com/?p=274#comments</comments>
		<pubDate>Tue, 29 Dec 2015 04:17:12 +0000</pubDate>
		<dc:creator><![CDATA[Shang Erxin]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.shangerxin.com/?p=274</guid>
		<description><![CDATA[During my daily development, I encounter a request to add code snippets before and after each function call for all the JavaScript files. I have figure out three ways to do this 1. Overwrite the Function.prototype.call, this will only effect the directly call the call method from a function object such as foo.call(&#8230;). The call [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>During my daily development, I encounter a request to add code snippets before and after each function call for all the JavaScript files. I have figure out three ways to do this</p>
<p>1. Overwrite the Function.prototype.call, this will only effect the directly call the call method from a function object such as foo.call(&#8230;). The call method will not triggered with directly call function with brace, such as foo(&#8230;)</p>
<p>disadvantage: not cover all the function even normal function calls</p>
<p>2. Use custom or use some AOP JS library to hook specify function. This is also could be extended by use a recursive method to hook all the function object in a give scope such as window in browser.</p>
<p>such as hooker lib, <a href="https://github.com/rcorp/hooker">https://github.com/rcorp/hooker</a></p>
<p>jquery AOP plugin</p>
<p>advantage: easy to use</p>
<p>disadvantage: not cover all of the functions in the JS files, such as anonymous functions are not included.</p>
<p>3. Use some script to parse all the JS files and inject codes before and after all the functions.</p>
<p>This article is mainly to talk about the tool which I created for automatic inject the codes before and after the function calls.</p>
<p>It is called hookjs, which is written in python. It could be checkout from my github repo(<a href="https://github.com/shangerxin/PersontalTools">https://github.com/shangerxin/PersontalTools</a>). The binary version could be download from the bin folder.</p>
<blockquote><p>$ hookjs -h</p>
<p>usage: hookjs.exe [-h] [-p PATH] [-s START] [-e END]                   [-f [BLACK_FILES [BLACK_FILES ...]]]                   [-d [BLACK_DIRS [BLACK_DIRS ...]]]</p>
<p>A command line JavaScript hook tool for inject start, end codes into every JavaScript functions. Currently only support uncompressed EMCScipt 5. Any errors will be output into the error.log file.</p>
<p>optional arguments:</p>
<p>-h, &#8211;help   show this help message and exit</p>
<p>-p PATH, &#8211;path PATH  The path to the JavaScript file or directory</p>
<p>-s START, &#8211;start START  The start code snippet which will be injected at the                         begin of each function</p>
<p>-e END, &#8211;end END     The end code snippet which will be injected at the end                         of each function</p>
<p>-f [BLACK_FILES [BLACK_FILES ...]], &#8211;black-files [BLACK_FILES [BLACK_FILES ...]]                         Use regex expression to define the black files list, the files will not be hooked</p>
<p>-d [BLACK_DIRS [BLACK_DIRS ...]], &#8211;black-dirs [BLACK_DIRS [BLACK_DIRS ...]]                         Use regex expression to define the black dirs list, the directory and sub directory will not be searched</p>
<p>Created by Edwin, Shang(Shang, Erxin), License under GNU GPLv3. Version 1.0.0</p></blockquote>
<p><strong>Example:</strong></p>
<p>Inject codes to a JS files, the original JS content</p>
<div id="wpshdo_2" class="wp-synhighlighter-outer"><div id="wpshdt_2" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_2"></a><a id="wpshat_2" class="wp-synhighlighter-title" href="#codesyntax_2"  onClick="javascript:wpsh_toggleBlock(2)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_2" onClick="javascript:wpsh_code(2)" title="Show code only"><img border="0" style="border: 0 none" src="http://www.shangerxin.com/wordpress/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_2" onClick="javascript:wpsh_print(2)" title="Print code"><img border="0" style="border: 0 none" src="http://www.shangerxin.com/wordpress/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://www.shangerxin.com/wordpress/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://www.shangerxin.com/wordpress/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_2" class="wp-synhighlighter-inner" style="display: block;"><pre class="javascript" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">x = findMax(1, 123, 500, 115, 44, 88);</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">(function(){</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">})();</div></li><li style="font-weight: bold; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">function findMax() {</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">     var i;</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    var max = -Infinity;</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">     for (i = 0; i &lt; arguments.length; i++) {</div></li><li style="font-weight: bold; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">         if (arguments[i] &gt; max) {</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">             max = arguments[i];</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">         }</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">     }</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">     return max;</div></li><li style="font-weight: bold; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">}</div></li></ol></pre></div></div>
<p>&nbsp;</p>
<p>run command</p>
<div id="wpshdo_3" class="wp-synhighlighter-outer"><div id="wpshdt_3" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_3"></a><a id="wpshat_3" class="wp-synhighlighter-title" href="#codesyntax_3"  onClick="javascript:wpsh_toggleBlock(3)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_3" onClick="javascript:wpsh_code(3)" title="Show code only"><img border="0" style="border: 0 none" src="http://www.shangerxin.com/wordpress/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_3" onClick="javascript:wpsh_print(3)" title="Print code"><img border="0" style="border: 0 none" src="http://www.shangerxin.com/wordpress/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://www.shangerxin.com/wordpress/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://www.shangerxin.com/wordpress/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_3" class="wp-synhighlighter-inner" style="display: block;"><pre class="bash" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">hookjs.exe <span style="color: #660033;">-p</span> e:\demo.js <span style="color: #660033;">-s</span> console.log<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #ff0000;">&quot;start&quot;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>; <span style="color: #660033;">-e</span> console.log<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #ff0000;">&quot;end&quot;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>;</div></li></ol></pre></div></div>
<div id="wpshdo_4" class="wp-synhighlighter-outer"><div id="wpshdt_4" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_4"></a><a id="wpshat_4" class="wp-synhighlighter-title" href="#codesyntax_4"  onClick="javascript:wpsh_toggleBlock(4)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_4" onClick="javascript:wpsh_code(4)" title="Show code only"><img border="0" style="border: 0 none" src="http://www.shangerxin.com/wordpress/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_4" onClick="javascript:wpsh_print(4)" title="Print code"><img border="0" style="border: 0 none" src="http://www.shangerxin.com/wordpress/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://www.shangerxin.com/wordpress/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://www.shangerxin.com/wordpress/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_4" class="wp-synhighlighter-inner" style="display: block;"><pre class="javascript" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">x = findMax(1, 123, 500, 115, 44, 88);</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">(function(){console.log(start);</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">console.log(end);})();</div></li><li style="font-weight: bold; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">function findMax() {console.log(start);</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">     var i;</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    var max = -Infinity;</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">     for (i = 0; i &lt; arguments.length; i++) {</div></li><li style="font-weight: bold; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">         if (arguments[i] &gt; max) {</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">             max = arguments[i];</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">         }</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">     }</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">     console.log(end);return max;</div></li><li style="font-weight: bold; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">console.log(end);}</div></li></ol></pre></div></div>
<p>&nbsp;</p>
<p><strong>Limitations</strong>:</p>
<p>The tool is not works with compressed JS file such as jquery-min etc. To add hook for these kinds of JS files, it required to format the JS first then use the tool the inject the JS codes.</p>
<p>Current it is not design for support arrow function syntax which is added in EMCAScript 6</p>
<p>Have fun.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.shangerxin.com/?feed=rss2&#038;p=274</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Automatic Export About:Config Content Compare the Difference between for Firefox</title>
		<link>http://www.shangerxin.com/?p=262</link>
		<comments>http://www.shangerxin.com/?p=262#comments</comments>
		<pubDate>Wed, 02 Dec 2015 03:24:07 +0000</pubDate>
		<dc:creator><![CDATA[Shang Erxin]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Autoit]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.shangerxin.com/?p=262</guid>
		<description><![CDATA[Requirement: We need to compare the difference between the configuration changes between the new vision of the FF and the previous version We wish to compare the configuration setting in plain text. Then we could use the compare tools such as beyond compare or winmerge to give us a quick visual for the difference. The [&#8230;]]]></description>
				<content:encoded><![CDATA[<p><strong>Requirement:</strong></p>
<p>We need to compare the difference between the configuration changes between the new vision of the FF and the previous version</p>
<p>We wish to compare the configuration setting in plain text. Then we could use the compare tools such as beyond compare or winmerge to give us a quick visual for the difference.</p>
<p><strong>The Problem:</strong></p>
<p>There is not a official way to export the <a href="http://aboutconfg">about:confg</a> page from FF into plain text file. There is a <a href="http://kb.mozillazine.org/Prefs.js_file">prefs.js</a> file locate in the firefox profile folder, it contains some of the configuration setting but not all.</p>
<p><strong>Known solutions to export the about:config but not well enough:</strong></p>
<ul>
<li>User prefs.js for only export the custom settings, check the link(<a href="http://superuser.com/questions/165164/how-to-export-firefox-aboutconfig-into-plain-text-file">http://superuser.com/questions/165164/how-to-export-firefox-aboutconfig-into-plain-text-file</a>). But it is not fit for our requirement.</li>
<li>User python to analyze the entire profile folder and parse the preference relative *.js files. But it is not sure works for the new versions of the FF(<a href="http://stackoverflow.com/questions/24548306/how-to-read-firefoxs-aboutconfig-entries-using-python">http://stackoverflow.com/questions/24548306/how-to-read-firefoxs-aboutconfig-entries-using-python</a>)</li>
</ul>
<p><strong>Solution for export the about:config</strong>:</p>
<p>Use the GUI automation tool(<a href="https://www.autoitscript.com/site/autoit/">autoit</a>) to help export the configuration directly from the <a href="http://aboutconfig">about:config</a> page. The script is export-opened-firefox-config.au3 which could be download from <a href="https://github.com/shangerxin/PersontalTools/">my github repot</a></p>
<ol>
<li>Install <a href="https://www.autoitscript.com/site/autoit/">autoit</a>, which double be download from official website follow the previous link</li>
<li>Download the export-opened-firefox-config.au3</li>
<li>Before run the script close all the Firefox process existed in the current system</li>
<li>Run the script export-opened-firefox-config.au3</li>
<li>Open the Firefox that you want to export the about the configure content</li>
<li>The script will start automatically and wait for it stops, please make any user input during the script execution</li>
<li>The output.txt will be generated at the same location of the script file export-opened-firefox-config.au3 which contain all the configuration values</li>
<li>Check the last line of the output.txt contain the last item of the about:config. If the values are same then all is well. If not please modify the sleep time for the script to give more calculate time for the low performance system.</li>
</ol>
<p><strong>Solution for generate the difference compilation results:</strong></p>
<p>Use <a href="https://www.python.org/">python</a> to parse and generate the previous generate configuration files and the current user.js settings which contain in the LR-INSTALL-DIRECTORY\dat\FFProfile\user.js. The python script could be check out from my personal tools <a href="https://github.com/shangerxin/PersontalTools/">repo from github</a></p>
<ol>
<li>Install python 2.7.x, if current system doesn&#8217;t contain python environment</li>
<li>Install <a href="http://www.python-excel.org/">xlsxwriter</a> from pip or download the package install manually. Check this <a href="https://docs.python.org/2/install/index.html">link</a>, if you doesn&#8217;t familiar with python</li>
<li>Download the script</li>
<li>Copy and replace the about config content files and the user.js into the data folder to make it follow this file structure</li>
</ol>
<p><a href="http://www.shangerxin.com/wordpress/wp-content/uploads/2015/12/2015-12-02_110835.png"><img alt="2015-12-02_110835" src="http://www.shangerxin.com/wordpress/wp-content/uploads/2015/12/2015-12-02_110835-300x104.png" width="300" height="104" /></a></p>
<p><a href="http://www.shangerxin.com/wordpress/wp-content/uploads/2015/12/2015-12-02_111617.png"><img alt="2015-12-02_111617" src="http://www.shangerxin.com/wordpress/wp-content/uploads/2015/12/2015-12-02_111617-300x196.png" width="300" height="196" /></a></p>
<p>5. Execute the python script the output files will be overwrite and generated automatically  Note: If the excel file is not required you could common the script lines relative to generate excel to only generate plain text report. The key/value pair is separate by semicolons like this:</p>
<p><a href="http://www.shangerxin.com/wordpress/wp-content/uploads/2015/12/2015-12-02_111832.png"><img alt="2015-12-02_111832" src="http://www.shangerxin.com/wordpress/wp-content/uploads/2015/12/2015-12-02_111832-300x157.png" width="300" height="157" /></a></p>
<p><strong>References</strong></p>
<ul>
<li>A addon for add description information for the <a href="http://aboutconfig">about:config</a> page <a href="https://addons.mozilla.org/en-US/firefox/addon/config-descriptions/">https://addons.mozilla.org/en-US/firefox/addon/config-descriptions/</a></li>
<li>The wiki page for the <a href="http://aboutconfig">about:config</a>, <a href="http://kb.mozillazine.org/About:config_entries">http://kb.mozillazine.org/About:config_entries</a></li>
<li>Some of the preference documents for the <a href="http://aboutconfig">about:config</a>, <a href="http://kb.mozillazine.org/Category:Preferences">http://kb.mozillazine.org/Category:Preferences</a></li>
<li>Document for user.js, <a href="http://kb.mozillazine.org/User.js">http://kb.mozillazine.org/User.js</a></li>
</ul>
<p>Note: the content of the wiki may adapt to the old version of FF to check the new version please follow the link supplied in the wiki pages.</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.shangerxin.com/?feed=rss2&#038;p=262</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Use Python to Create a Tree View Command Line Tool</title>
		<link>http://www.shangerxin.com/?p=258</link>
		<comments>http://www.shangerxin.com/?p=258#comments</comments>
		<pubDate>Thu, 12 Nov 2015 13:34:22 +0000</pubDate>
		<dc:creator><![CDATA[Shang Erxin]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Algorithm]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.shangerxin.com/?p=258</guid>
		<description><![CDATA[In recent days I need to generate a directory free from the window command prompt. As I known there is a DOS tool called tree could do this. But it is not quite fit for my requirement. Here is an example which the graphic generated by built-in tree command in window. D:\PersonalTools&#62;tree D:\emacs-24.5 /A 卷 [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>In recent days I need to generate a directory free from the window command prompt. As I known there is a DOS tool called tree could do this. But it is not quite fit for my requirement. Here is an example which the graphic generated by built-in tree command in window.</p>
<blockquote><p>D:\PersonalTools&gt;tree D:\emacs-24.5 /A<br />
卷 WareHouse 的文件夹 PATH 列表<br />
卷序列号为 64CA-A0C3</p>
<p>D:\EMACS-24.5<br />
+&#8212;admin<br />
|   +&#8212;charsets<br />
|   |   \&#8212;mapfiles<br />
|   +&#8212;coccinelle<br />
|   +&#8212;grammars<br />
|   +&#8212;notes<br />
|   +&#8212;nt<br />
|   \&#8212;unidata<br />
+&#8212;build-aux<br />
|   \&#8212;snippet<br />
+&#8212;doc<br />
|   +&#8212;emacs<br />
|   +&#8212;lispintro<br />
|   +&#8212;lispref<br />
|   +&#8212;man<br />
|   \&#8212;misc<br />
+&#8212;etc<br />
|   +&#8212;charsets<br />
|   +&#8212;e<br />
|   +&#8212;forms<br />
|   +&#8212;gnus<br />
|   +&#8212;images<br />
|   |   +&#8212;custom<br />
|   |   +&#8212;ezimage<br />
|   |   +&#8212;gnus<br />
|   |   +&#8212;gud<br />
|   |   +&#8212;icons<br />
|   |   |   +&#8212;allout-widgets<br />
|   |   |   |   +&#8212;dark-bg<br />
|   |   |   |   \&#8212;light-bg<br />
|   |   |   \&#8212;hicolor<br />
|   |   |       +&#8212;128&#215;128<br />
|   |   |       |   \&#8212;apps<br />
|   |   |       +&#8212;16&#215;16<br />
|   |   |       |   \&#8212;apps<br />
|   |   |       +&#8212;24&#215;24<br />
|   |   |       |   \&#8212;apps<br />
|   |   |       +&#8212;32&#215;32<br />
|   |   |       |   \&#8212;apps<br />
|   |   |       +&#8212;48&#215;48<br />
|   |   |       |   \&#8212;apps<br />
|   |   |       \&#8212;scalable<br />
|   |   |           +&#8212;apps<br />
|   |   |           \&#8212;mimetypes<br />
|   |   +&#8212;low-color<br />
|   |   +&#8212;mail<br />
|   |   +&#8212;mpc<br />
|   |   +&#8212;newsticker<br />
|   |   +&#8212;smilies<br />
|   |   |   +&#8212;grayscale<br />
|   |   |   \&#8212;medium<br />
|   |   \&#8212;tree-widget<br />
|   |       +&#8212;default<br />
|   |       \&#8212;folder<br />
|   +&#8212;nxml<br />
|   +&#8212;org<br />
|   +&#8212;refcards<br />
|   +&#8212;schema<br />
|   +&#8212;srecode<br />
|   +&#8212;themes<br />
|   \&#8212;tutorials<br />
+&#8212;info<br />
+&#8212;leim<br />
|   +&#8212;CXTERM-DIC<br />
|   +&#8212;MISC-DIC<br />
|   \&#8212;SKK-DIC<br />
+&#8212;lib<br />
+&#8212;lib-src<br />
+&#8212;lisp<br />
|   +&#8212;calc<br />
|   +&#8212;calendar<br />
|   +&#8212;cedet<br />
|   |   +&#8212;ede<br />
|   |   +&#8212;semantic<br />
|   |   |   +&#8212;analyze<br />
|   |   |   +&#8212;bovine<br />
|   |   |   +&#8212;decorate<br />
|   |   |   +&#8212;symref<br />
|   |   |   \&#8212;wisent<br />
|   |   \&#8212;srecode<br />
|   +&#8212;emacs-lisp<br />
|   +&#8212;emacs-parallel<br />
|   +&#8212;emulation<br />
|   +&#8212;erc<br />
|   +&#8212;eshell<br />
|   +&#8212;gnus<br />
|   +&#8212;international<br />
|   +&#8212;language<br />
|   +&#8212;leim<br />
|   |   +&#8212;ja-dic<br />
|   |   \&#8212;quail<br />
|   +&#8212;mail<br />
|   +&#8212;mh-e<br />
|   +&#8212;net<br />
|   +&#8212;nxml<br />
|   +&#8212;obsolete<br />
|   +&#8212;org<br />
|   +&#8212;play<br />
|   +&#8212;progmodes<br />
|   +&#8212;term<br />
|   +&#8212;textmodes<br />
|   +&#8212;url<br />
|   \&#8212;vc<br />
+&#8212;lwlib<br />
+&#8212;m4<br />
+&#8212;msdos<br />
+&#8212;nextstep<br />
|   +&#8212;Cocoa<br />
|   |   \&#8212;Emacs.base<br />
|   |       \&#8212;Contents<br />
|   |           \&#8212;Resources<br />
|   +&#8212;GNUstep<br />
|   |   \&#8212;Emacs.base<br />
|   |       \&#8212;Resources<br />
|   \&#8212;templates<br />
+&#8212;nt<br />
|   +&#8212;icons<br />
|   \&#8212;inc<br />
|       +&#8212;arpa<br />
|       +&#8212;netinet<br />
|       \&#8212;sys<br />
+&#8212;oldXMenu<br />
+&#8212;site-lisp<br />
\&#8212;src<br />
\&#8212;bitmaps</p></blockquote>
<p>A quite complicate file structure for emacs 24.5. There are several limitations for this command.</p>
<ol>
<li>It can&#8217;t control the iteration depth</li>
<li>When display with files it doesn&#8217;t generated the dash lines which is not clearly to indicate the file structure</li>
<li>If we could give a depth parameter I also want to display the sub items as ellipsis to indicate there is something under but which is omitted</li>
</ol>
<p>So I use python to write a custom version to enhance this command called <a href="https://github.com/shangerxin/PersontalTools">treex</a>. It support generated the same structure as the tree command but also provide additional control switch. The source code is already pushed to my personal repository in GitHub. Feel free to check it out.</p>
<p>The help information is</p>
<blockquote><p>usage: treex.py [-h] [-f] [-d DEPTH] [-m] [-e] path</p>
<p>A Cmd Line Tool for Graphically displays the folder structure of a drive or<br />
path</p>
<p>positional arguments:<br />
path</p>
<p>optional arguments:<br />
-h, &#8211;help            show this help message and exit<br />
-f, &#8211;file            Display the names of the files in each folder<br />
-d DEPTH, &#8211;depth DEPTH<br />
Display the depth number<br />
-m, &#8211;mark            Mark the item is file or directory<br />
-e, &#8211;ellipsis        Mark the next sub-item with ellipsis</p>
<p>Create by Edwin, Shang(Shang, Erxin) License under MIT. Version 1.0.0</p></blockquote>
<p>Try to use the treex to generate a depth 2 directory structure</p>
<blockquote><p>D:\PersonalTools&gt;c:\Python27\python.exe treex.py D:\emacs-24.5 -d 2<br />
Folder path listing<br />
D:\emacs-24.5<br />
+&#8212;admin<br />
|   +&#8212;charsets<br />
|   +&#8212;coccinelle<br />
|   +&#8212;grammars<br />
|   +&#8212;notes<br />
|   +&#8212;nt<br />
|   \&#8212;unidata<br />
+&#8212;build-aux<br />
|   \&#8212;snippet<br />
+&#8212;doc<br />
|   +&#8212;emacs<br />
|   +&#8212;lispintro<br />
|   +&#8212;lispref<br />
|   +&#8212;man<br />
|   \&#8212;misc<br />
+&#8212;etc<br />
|   +&#8212;charsets<br />
|   +&#8212;e<br />
|   +&#8212;forms<br />
|   +&#8212;gnus<br />
|   +&#8212;images<br />
|   +&#8212;nxml<br />
|   +&#8212;org<br />
|   +&#8212;refcards<br />
|   +&#8212;schema<br />
|   +&#8212;srecode<br />
|   +&#8212;themes<br />
|   \&#8212;tutorials<br />
+&#8212;info<br />
+&#8212;leim<br />
|   +&#8212;CXTERM-DIC<br />
|   +&#8212;MISC-DIC<br />
|   \&#8212;SKK-DIC<br />
+&#8212;lib<br />
+&#8212;lib-src<br />
+&#8212;lisp<br />
|   +&#8212;calc<br />
|   +&#8212;calendar<br />
|   +&#8212;cedet<br />
|   +&#8212;emacs-lisp<br />
|   +&#8212;emacs-parallel<br />
|   +&#8212;emulation<br />
|   +&#8212;erc<br />
|   +&#8212;eshell<br />
|   +&#8212;gnus<br />
|   +&#8212;international<br />
|   +&#8212;language<br />
|   +&#8212;leim<br />
|   +&#8212;mail<br />
|   +&#8212;mh-e<br />
|   +&#8212;net<br />
|   +&#8212;nxml<br />
|   +&#8212;obsolete<br />
|   +&#8212;org<br />
|   +&#8212;play<br />
|   +&#8212;progmodes<br />
|   +&#8212;term<br />
|   +&#8212;textmodes<br />
|   +&#8212;url<br />
|   \&#8212;vc<br />
+&#8212;lwlib<br />
+&#8212;m4<br />
+&#8212;msdos<br />
+&#8212;nextstep<br />
|   +&#8212;Cocoa<br />
|   +&#8212;GNUstep<br />
|   \&#8212;templates<br />
+&#8212;nt<br />
|   +&#8212;icons<br />
|   \&#8212;inc<br />
+&#8212;oldXMenu<br />
+&#8212;site-lisp<br />
\&#8212;src<br />
\&#8212;bitmaps</p></blockquote>
<p>Here is another result for generate with ellipsis and marks</p>
<blockquote><p>D:\PersonalTools&gt;c:\Python27\python.exe treex.py D:\emacs-24.5 -d 2 -e -m<br />
Folder path listing<br />
D:\emacs-24.5<br />
[d]+&#8212;admin<br />
[d]|   +&#8212;charsets<br />
[d]|   |   \&#8212;&#8230;<br />
[d]|   +&#8212;coccinelle<br />
[d]|   +&#8212;grammars<br />
[d]|   +&#8212;notes<br />
[d]|   +&#8212;nt<br />
[d]|   \&#8212;unidata<br />
[d]+&#8212;build-aux<br />
[d]|   \&#8212;snippet<br />
[d]+&#8212;doc<br />
[d]|   +&#8212;emacs<br />
[d]|   +&#8212;lispintro<br />
[d]|   +&#8212;lispref<br />
[d]|   +&#8212;man<br />
[d]|   \&#8212;misc<br />
[d]+&#8212;etc<br />
[d]|   +&#8212;charsets<br />
[d]|   +&#8212;e<br />
[d]|   +&#8212;forms<br />
[d]|   +&#8212;gnus<br />
[d]|   +&#8212;images<br />
[d]|   |   +&#8212;&#8230;<br />
[d]|   +&#8212;nxml<br />
[d]|   +&#8212;org<br />
[d]|   +&#8212;refcards<br />
[d]|   +&#8212;schema<br />
[d]|   +&#8212;srecode<br />
[d]|   +&#8212;themes<br />
[d]|   \&#8212;tutorials<br />
[d]+&#8212;info<br />
[d]+&#8212;leim<br />
[d]|   +&#8212;CXTERM-DIC<br />
[d]|   +&#8212;MISC-DIC<br />
[d]|   \&#8212;SKK-DIC<br />
[d]+&#8212;lib<br />
[d]+&#8212;lib-src<br />
[d]+&#8212;lisp<br />
[d]|   +&#8212;calc<br />
[d]|   +&#8212;calendar<br />
[d]|   +&#8212;cedet<br />
[d]|   |   +&#8212;&#8230;<br />
[d]|   +&#8212;emacs-lisp<br />
[d]|   +&#8212;emacs-parallel<br />
[d]|   +&#8212;emulation<br />
[d]|   +&#8212;erc<br />
[d]|   +&#8212;eshell<br />
[d]|   +&#8212;gnus<br />
[d]|   +&#8212;international<br />
[d]|   +&#8212;language<br />
[d]|   +&#8212;leim<br />
[d]|   |   +&#8212;&#8230;<br />
[d]|   +&#8212;mail<br />
[d]|   +&#8212;mh-e<br />
[d]|   +&#8212;net<br />
[d]|   +&#8212;nxml<br />
[d]|   +&#8212;obsolete<br />
[d]|   +&#8212;org<br />
[d]|   +&#8212;play<br />
[d]|   +&#8212;progmodes<br />
[d]|   +&#8212;term<br />
[d]|   +&#8212;textmodes<br />
[d]|   +&#8212;url<br />
[d]|   \&#8212;vc<br />
[d]+&#8212;lwlib<br />
[d]+&#8212;m4<br />
[d]+&#8212;msdos<br />
[d]+&#8212;nextstep<br />
[d]|   +&#8212;Cocoa<br />
[d]|   |   \&#8212;&#8230;<br />
[d]|   +&#8212;GNUstep<br />
[d]|   |   \&#8212;&#8230;<br />
[d]|   \&#8212;templates<br />
[d]+&#8212;nt<br />
[d]|   +&#8212;icons<br />
[d]|   \&#8212;inc<br />
[d]|       +&#8212;&#8230;<br />
[d]+&#8212;oldXMenu<br />
[d]+&#8212;site-lisp<br />
[d]\&#8212;src<br />
[d]    \&#8212;bitmaps</p></blockquote>
<p>The key technical point is the depth first traversal algorithms, and I implement it with nonrecursive mode to reduce the stack usage.</p>
<p>The other key point is how to generate the graphic. There is a pattern between the second line and the previous line. So I use it. The implementation could be found from the source.</p>
<p>That&#8217;s all. Happy coding.</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.shangerxin.com/?feed=rss2&#038;p=258</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
