tag:blogger.com,1999:blog-29736937003944455772024-02-07T04:01:49.064-08:00Inside Out Outside InA personal blog of Christopher Wigginton; a nerd by nature, programming polyglot, cooking enthusiast and fermentation practitioner.Christopher Wiggintonhttp://www.blogger.com/profile/02433309097120061094noreply@blogger.comBlogger52125tag:blogger.com,1999:blog-2973693700394445577.post-64500739370674087452023-11-17T07:37:00.000-08:002023-11-17T07:37:10.508-08:00ColdFusion: Comparing a selected list vs an existing list and determining which needs to be inserted and deleted.I've seen implementations in code, where in a database update all the records are deleted and new ones are inserted. Here's a simple method in ColdFusion using underlying Java array methods for determining from a given selection list and current list, which items need to be deleted and inserted.
<!--HTML generated using hilite.me--><div style="background: rgb(39, 40, 34); border-color: gray; border-image: initial; border-style: solid; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;"><span style="color: #f8f8f2;"><cfscript></span>
<span style="color: #f8f8f2;">selectedList</span> <span style="color: #f92672;">=</span> <span style="color: #e6db74;">"1,2,6"</span><span style="color: #f8f8f2;">;</span>
<span style="color: #f8f8f2;">currentList</span> <span style="color: #f92672;">=</span><span style="color: #e6db74;">"1,2,3,4,5"</span><span style="color: #f8f8f2;">;</span>
<span style="color: #f8f8f2;">selectedArray</span> <span style="color: #f92672;">=</span> <span style="color: #a6e22e;">ListToArray</span><span style="color: #f8f8f2;">(selectedList);</span>
<span style="color: #f8f8f2;">currentArray</span> <span style="color: #f92672;">=</span> <span style="color: #a6e22e;">ListToArray</span><span style="color: #f8f8f2;">(currentList);</span>
<span style="color: #f8f8f2;">deleteArray</span> <span style="color: #f92672;">=</span> <span style="color: #a6e22e;">currentArray.clone</span><span style="color: #f8f8f2;">();</span>
<span style="color: #a6e22e;">deleteArray.RemoveAll</span><span style="color: #f8f8f2;">(selectedArray);</span>
<span style="color: #f8f8f2;">insertArray</span> <span style="color: #f92672;">=</span> <span style="color: #a6e22e;">selectedArray.clone</span><span style="color: #f8f8f2;">();</span>
<span style="color: #a6e22e;">insertArray.RemoveAll</span><span style="color: #f8f8f2;">(currentArray);</span>
<span style="color: #a6e22e;">WriteOutput</span><span style="color: #f8f8f2;">(</span><span style="color: #e6db74;">"selected"</span><span style="color: #f8f8f2;">);</span>
<span style="color: #a6e22e;">WriteDump</span><span style="color: #f8f8f2;">(selectedArray);</span>
<span style="color: #a6e22e;">WriteOutput</span><span style="color: #f8f8f2;">(</span><span style="color: #e6db74;">"Current"</span><span style="color: #f8f8f2;">);</span>
<span style="color: #a6e22e;">WRiteDump</span><span style="color: #f8f8f2;">(currentArray);</span>
<span style="color: #a6e22e;">WRiteOutput</span><span style="color: #f8f8f2;">(</span><span style="color: #e6db74;">"Deleted"</span><span style="color: #f8f8f2;">);</span>
<span style="color: #a6e22e;">WriteDump</span><span style="color: #f8f8f2;">(</span><span style="color: #a6e22e;">deleteArray.ToList</span><span style="color: #f8f8f2;">());</span>
<span style="color: #a6e22e;">WriteOutPut</span><span style="color: #f8f8f2;">(</span><span style="color: #e6db74;">"Inserted"</span><span style="color: #f8f8f2;">);</span>
<span style="color: #a6e22e;">WriteDump</span><span style="color: #f8f8f2;">(</span><span style="color: #a6e22e;">insertArray.ToList</span><span style="color: #f8f8f2;">());</span>
<span style="color: #f8f8f2;"></cfscript></span>
</pre></div>
Christopher Wiggintonhttp://www.blogger.com/profile/02433309097120061094noreply@blogger.com0tag:blogger.com,1999:blog-2973693700394445577.post-31418564470172557982023-03-15T04:16:00.002-07:002023-03-15T04:16:56.799-07:00Sun Anomaly 3/15/2023<p></p><div class="separator" style="clear: both; text-align: center;">Via Reddit, an interesting circular anomaly on Sol. </div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi8BbnhQNk1kRkYSvarpbwNGn5G0sBYjTF-q129b-UJgB7xfm52_L-6LjfhEp8L40lZALjIDB66Qfd-QNMQuZIfc27sXKdOHls9sVSelhzF39Yp34C0QxsOidalk3Aa7whPd-IzVPdskMkt0PQirsVs3VP9TLgwFNMvZCr_MtOdlTR-Rm7wR6UK611hEg/s3311/2AF481E5-6AAA-40FB-9F1A-17649CD1AC87.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="3311" data-original-width="3257" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi8BbnhQNk1kRkYSvarpbwNGn5G0sBYjTF-q129b-UJgB7xfm52_L-6LjfhEp8L40lZALjIDB66Qfd-QNMQuZIfc27sXKdOHls9sVSelhzF39Yp34C0QxsOidalk3Aa7whPd-IzVPdskMkt0PQirsVs3VP9TLgwFNMvZCr_MtOdlTR-Rm7wR6UK611hEg/s320/2AF481E5-6AAA-40FB-9F1A-17649CD1AC87.jpeg" width="315" /></a></div><br /> <p></p>Christopher Wiggintonhttp://www.blogger.com/profile/02433309097120061094noreply@blogger.com0tag:blogger.com,1999:blog-2973693700394445577.post-18470280938769784512023-02-15T05:13:00.001-08:002023-02-15T05:13:53.516-08:00Spy Balloon Path<p>source not confirmed but appears legit. </p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEigbr4ouL7hm-M3Pzxn4IRerHD08jXv01lXe5rYuqKWx4QU8TVouZgbKt0Kn_wJwU4_w2dLiueNqwQpOUJ6eQXGbOSXuUSsHq3nIKbOzedgbB1dKFFG-lG8w4_peYyob10u44y79LCyViq5ZHo4-rGBpLXO4iIoCBgbn5ROaI3Q-c1EjJLBiNs01ofHbA/s682/7AC90D8B-8760-4738-8C23-CD7112969B9A.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="682" data-original-width="651" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEigbr4ouL7hm-M3Pzxn4IRerHD08jXv01lXe5rYuqKWx4QU8TVouZgbKt0Kn_wJwU4_w2dLiueNqwQpOUJ6eQXGbOSXuUSsHq3nIKbOzedgbB1dKFFG-lG8w4_peYyob10u44y79LCyViq5ZHo4-rGBpLXO4iIoCBgbn5ROaI3Q-c1EjJLBiNs01ofHbA/s320/7AC90D8B-8760-4738-8C23-CD7112969B9A.jpeg" width="305" /></a></div><br /><p></p>Christopher Wiggintonhttp://www.blogger.com/profile/02433309097120061094noreply@blogger.com0tag:blogger.com,1999:blog-2973693700394445577.post-73120733661298204752022-08-24T16:00:00.001-07:002022-08-24T16:00:00.154-07:00ColdFusion: Scatology<p> Just stuff I keep around for memories </p><p><br /></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiOg7YMpAnARgRwR2wM0QQdi4vA97YF3DciF7Amb4mmddSdCjU2ArmgiAXLw7xuN3U4HLBti40XqyhDfLEFqutqxwu8NiltpKLy-WBhM-Zs7ZUhoomJPYFWfBxLSU1fCKVDd7ef6Iz2RKeoOibvrm9MT-ujviQ3yJrT7owpS015sO8K7h5bZ7kI0wQyug/s3730/33F8EC36-94B1-47D7-8020-FA4CA0E187C3.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="2261" data-original-width="3730" height="194" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiOg7YMpAnARgRwR2wM0QQdi4vA97YF3DciF7Amb4mmddSdCjU2ArmgiAXLw7xuN3U4HLBti40XqyhDfLEFqutqxwu8NiltpKLy-WBhM-Zs7ZUhoomJPYFWfBxLSU1fCKVDd7ef6Iz2RKeoOibvrm9MT-ujviQ3yJrT7owpS015sO8K7h5bZ7kI0wQyug/s320/33F8EC36-94B1-47D7-8020-FA4CA0E187C3.png" width="320" /></a></div><br /><p></p>Christopher Wiggintonhttp://www.blogger.com/profile/02433309097120061094noreply@blogger.com0tag:blogger.com,1999:blog-2973693700394445577.post-25610041012560847342022-08-10T17:00:00.011-07:002022-08-10T17:00:00.154-07:00Crystal Reports Custom Report Function: Superscript Text generator.<p> A simple custom report function for Crystal Reports that will take a numeric value and generate a string of UTF8 superscripts of the digits.</p><p><br /></p>
<!--HTML generated using hilite.me--><div style="background: rgb(255, 255, 255); border-color: gray; border-image: initial; border-style: solid; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;"><span style="color: #888888;">//font must be Arial Unicode MS or other font with Unicode support</span>
<span style="color: #888888;">//1 2 3 4 5 6 7 8 9 0</span>
<span style="color: #888888;">//Hex</span>
<span style="color: #888888;">// 2071 00B2 00B3 2074 2075 2076 2077 2078 2079 2070</span>
<span style="color: #888888;">//Dec</span>
<span style="color: #888888;">// 0185 0178 0179 8308 8309 8310 8311 8312 8313 8304</span>
<span style="color: #007020;">Function</span> (numberVar SuperScriptNumber)
<span style="color: #888888;">//If 1 thru 9 and then zero since we're not a zero based array</span>
Local NumberVar <span style="color: #007020;">Array</span> subs <span style="color: #333333;">:=</span> [<span style="color: #0000dd; font-weight: bold;">0185</span><span style="color: #333333;">,</span><span style="color: #0000dd; font-weight: bold;">0178</span><span style="color: #333333;">,</span><span style="color: #0000dd; font-weight: bold;">0179</span><span style="color: #333333;">,</span><span style="color: #0000dd; font-weight: bold;">8308</span><span style="color: #333333;">,</span><span style="color: #0000dd; font-weight: bold;">8309</span><span style="color: #333333;">,</span><span style="color: #0000dd; font-weight: bold;">8310</span><span style="color: #333333;">,</span><span style="color: #0000dd; font-weight: bold;">8311</span><span style="color: #333333;">,</span><span style="color: #0000dd; font-weight: bold;">8312</span><span style="color: #333333;">,</span><span style="color: #0000dd; font-weight: bold;">8313</span><span style="color: #333333;">,</span><span style="color: #0000dd; font-weight: bold;">8304</span>];
Local NumberVar x<span style="color: #333333;">;</span>
Local NumberVar DecValue<span style="color: #333333;">;</span>
Local StringVar NumString <span style="color: #333333;">:=</span> ToText(SuperScriptNumber<span style="color: #333333;">,</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">,</span><span style="background-color: #fff0f0;">""</span><span style="color: #333333;">,</span><span style="background-color: #fff0f0;">""</span>);
Local StringVar SuperString <span style="color: #333333;">:=</span> <span style="background-color: #fff0f0;">""</span><span style="color: #333333;">;</span>
For x<span style="color: #333333;">:=</span> <span style="color: #0000dd; font-weight: bold;">1</span> to Len(NumString) Do
(
DecValue<span style="color: #333333;">:=</span> ToNumber(Mid(NumString<span style="color: #333333;">,</span>x<span style="color: #333333;">,</span><span style="color: #0000dd;"><b>1)</b></span>);
<span style="color: #008800; font-weight: bold;">if</span> DecValue <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">0</span> then SuperString <span style="color: #333333;">:=</span> SuperString <span style="color: #333333;">+</span> chrw(subs[<span style="color: #0000dd; font-weight: bold;">10</span>])
<span style="color: #008800; font-weight: bold;">else</span>
SuperString <span style="color: #333333;">:=</span> SuperString <span style="color: #333333;">+</span> chrw(subs[decValue]);
);
SuperString
</pre></div>
Christopher Wiggintonhttp://www.blogger.com/profile/02433309097120061094noreply@blogger.com0tag:blogger.com,1999:blog-2973693700394445577.post-57031094064911811652022-05-24T13:34:00.008-07:002022-05-26T13:57:12.368-07:00Google Voice Chome Extension, React Development, and Incognito (Solved)<p> After trying to play around with the open package which is a dependency of <a href="https://www.npmjs.com/package/react-dev-utils">react-dev-utils</a>, I added the <a href="https://www.npmjs.com/package/bopen">bopen </a>package and changed the open call on line 131 in openBrowser.js to bopen and added incognito:true</p><p>This is currently hack status. but does solve the issue of using my chrome with all my extensions and launching the dev server in incognito mode.</p>
<pre class="hljs" style="background: rgb(255, 255, 255); color: #333333; display: block; overflow-x: auto; padding: 0.5em;"> <span class="hljs-keyword" style="color: #a71d5d;">try</span> {
<span class="hljs-keyword" style="color: #a71d5d;">var</span> options = { app: browser, wait: <span class="hljs-literal" style="color: #0086b3;">false</span>, url: <span class="hljs-literal" style="color: #0086b3;">true</span> , incognito: <span class="hljs-literal" style="color: #0086b3;">true</span>};
bopen(url, options).catch(() => {}); <span class="hljs-comment" style="color: #969896;">// Prevent `unhandledRejection` error.</span>
<span class="hljs-keyword" style="color: #a71d5d;">return</span> <span class="hljs-literal" style="color: #0086b3;">true</span>;
} <span class="hljs-keyword" style="color: #a71d5d;">catch</span> (err) {
<span class="hljs-keyword" style="color: #a71d5d;">return</span> <span class="hljs-literal" style="color: #0086b3;">false</span>;
}</pre>Christopher Wiggintonhttp://www.blogger.com/profile/02433309097120061094noreply@blogger.com0tag:blogger.com,1999:blog-2973693700394445577.post-47637575243166109712022-05-24T05:51:00.004-07:002022-05-24T06:43:23.389-07:00Google Voice Chome Extension and React DevelopmentGoogle Voice is a fantastic free service for VOIP via the browser, however the extension isn't compatible with local React development and returns an<i> "Uncaught (in promise) Error: Could not establish connection. Receiving end does not exist". </i> <div><br /></div><div><div class="separator" style="clear: both;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSnSnPfdLIkX9_b9zNpQviNbZXowBzzksCVcWj81-Q0OIJsqbs5Y-UPWJKJU7xcwAzo5wQbvjM2tyYuYJFmcymLp6rpspxEJOSHjzJ5muvbjAKl1TdeWDUP7zLOf2vdNBSknJ5JBRll9ooWkvHEfAKmB47a-yFcAC3JWBwD_8YA9ngzHgNxNahco3MMQ/s1600/google_voice_react.PNG" style="display: block; padding: 1em 0px; text-align: center;"><img alt="" border="0" data-original-height="69" data-original-width="448" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSnSnPfdLIkX9_b9zNpQviNbZXowBzzksCVcWj81-Q0OIJsqbs5Y-UPWJKJU7xcwAzo5wQbvjM2tyYuYJFmcymLp6rpspxEJOSHjzJ5muvbjAKl1TdeWDUP7zLOf2vdNBSknJ5JBRll9ooWkvHEfAKmB47a-yFcAC3JWBwD_8YA9ngzHgNxNahco3MMQ/s1600/google_voice_react.PNG" /></a></div>Solutions are to use incognito sessions, disable the extension during development, or a different browser. I set Chrome as my default over other browsers for the various google app integrations. So for now, it's a minor annoyance to have to perform the manual switching or configuration each time I want to launch a development session.</div><div><br /></div><div>There is one possibility of diving into the node packages such as react-dev-utils that's using html-webpack-plugin and trying to provide a method for launching the browser incognito when using the command npm start.</div>Christopher Wiggintonhttp://www.blogger.com/profile/02433309097120061094noreply@blogger.com0tag:blogger.com,1999:blog-2973693700394445577.post-5962014900337309222022-05-19T06:18:00.004-07:002022-05-19T06:23:38.959-07:00Greenscreens: Revisting ManyCamI used to use ManyCam a few years ago but wasn't happy with their chroma keying at the time and had switched to SparkoCam. I decided to try Manycam's newer version and they have significantly improved their chroma keying performance. I prefer chroma key background detection as you don't get as many artifacts in the output. Lighting still has to be adjusted for any product for best image. But this does fairly well with just ambient lighting.<div><br /><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgHLSQDAMmpYXJ2niyJ8bmiR0zyaULPIdveGnkg66SxJqxdJlGnVFqvyU8uIqR_sy0ffsbjgJKdYc3Lw7oTXe1qP6ciXw5tuMZhRBg3BLILmU-1M5Dqw3iRBthMUTDsRGdUdL6Z0RkoMRoHO83FIy5D-bSrLp_E3LJ0L6RMkyECvR6U9dA5K0GwjTZLxg/s964/manycam1.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="679" data-original-width="964" height="225" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgHLSQDAMmpYXJ2niyJ8bmiR0zyaULPIdveGnkg66SxJqxdJlGnVFqvyU8uIqR_sy0ffsbjgJKdYc3Lw7oTXe1qP6ciXw5tuMZhRBg3BLILmU-1M5Dqw3iRBthMUTDsRGdUdL6Z0RkoMRoHO83FIy5D-bSrLp_E3LJ0L6RMkyECvR6U9dA5K0GwjTZLxg/s320/manycam1.PNG" width="320" /></a></div><br /><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgrUT60gLKxenMHNrzDq25Rv_JeuCfrxAth_i1lOfVsQMmT72Vk0WCWgfbc2pTW5Loj-fHcY_q2W7PD5_i_l5R54eAU0G_p6YLzLTGUkvcPlcn8bttiTDwIftodfMCmwz7dpCnE-svFgl_fI_j0uf_Ft05DSRjnoiBOuxneMO0pFz90-StiQn1S8fVlaA/s962/manycam2.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="684" data-original-width="962" height="228" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgrUT60gLKxenMHNrzDq25Rv_JeuCfrxAth_i1lOfVsQMmT72Vk0WCWgfbc2pTW5Loj-fHcY_q2W7PD5_i_l5R54eAU0G_p6YLzLTGUkvcPlcn8bttiTDwIftodfMCmwz7dpCnE-svFgl_fI_j0uf_Ft05DSRjnoiBOuxneMO0pFz90-StiQn1S8fVlaA/s320/manycam2.PNG" width="320" /></a></div><br /><div><br /></div></div>Christopher Wiggintonhttp://www.blogger.com/profile/02433309097120061094noreply@blogger.com0tag:blogger.com,1999:blog-2973693700394445577.post-40257329790571316442022-05-18T05:00:00.001-07:002022-05-18T05:00:00.152-07:00VBA: Outlook Macro for saving selected emails as PDF's.<p> This VBA Macro for Outlook will take a selected emails and save it to c:\Temp folder as PDF's</p><p><br /></p>
<!--HTML generated using hilite.me--><div style="background: rgb(255, 255, 255); border-color: gray; border-image: initial; border-style: solid; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;"><span style="color: #888888;">'Outlook Macro for taking selected emails and exporting them to a folder as PDF's.</span>
<span style="color: #888888;">'Assumes you have Word installed and are an Exchange user.</span>
<span style="color: #008800; font-weight: bold;">Function</span> <span style="color: #0066bb; font-weight: bold;">CleanFileName</span>(strText <span style="color: black; font-weight: bold;">As</span> <span style="color: #333399; font-weight: bold;">String</span>) <span style="color: black; font-weight: bold;">As</span> <span style="color: #333399; font-weight: bold;">String</span>
<span style="color: #008800; font-weight: bold;">Dim</span> strStripChars <span style="color: black; font-weight: bold;">As</span> <span style="color: #333399; font-weight: bold;">String</span>
<span style="color: #008800; font-weight: bold;">Dim</span> intLen <span style="color: black; font-weight: bold;">As</span> <span style="color: #333399; font-weight: bold;">Integer</span>
<span style="color: #008800; font-weight: bold;">Dim</span> i <span style="color: black; font-weight: bold;">As</span> <span style="color: #333399; font-weight: bold;">Integer</span>
strStripChars <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">"/\[]:=,"</span> <span style="color: #333333;">&</span> Chr(<span style="color: #0000dd; font-weight: bold;">34</span>)
intLen <span style="color: #333333;">=</span> Len(strStripChars)
strText <span style="color: #333333;">=</span> Trim(strText)
<span style="color: #008800; font-weight: bold;">For</span> i <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">1</span> <span style="color: #008800; font-weight: bold;">To</span> intLen
strText <span style="color: #333333;">=</span> Replace(strText, Mid(strStripChars, i, <span style="color: #0000dd; font-weight: bold;">1</span>), <span style="background-color: #fff0f0;">""</span>)
<span style="color: #008800; font-weight: bold;">Next</span>
CleanFileName <span style="color: #333333;">=</span> strText
<span style="color: #008800; font-weight: bold;">End</span> <span style="color: #008800; font-weight: bold;">Function</span>
<span style="color: #008800; font-weight: bold;">Sub</span> <span style="color: #0066bb; font-weight: bold;">SaveSelectedMailAsPDFFile</span>()
<span style="color: #008800; font-weight: bold;">Const</span> OLTXT <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">0</span>
<span style="color: #008800; font-weight: bold;">Dim</span> currentExplorer <span style="color: black; font-weight: bold;">As</span> Explorer
<span style="color: #008800; font-weight: bold;">Dim</span> Selection <span style="color: black; font-weight: bold;">As</span> Selection
<span style="color: #008800; font-weight: bold;">Dim</span> oMail <span style="color: black; font-weight: bold;">As</span> Outlook.MailItem
<span style="color: #008800; font-weight: bold;">Dim</span> obj <span style="color: black; font-weight: bold;">As</span> <span style="color: #333399; font-weight: bold;">Object</span>
<span style="color: #008800; font-weight: bold;">Dim</span> sPath <span style="color: black; font-weight: bold;">As</span> <span style="color: #333399; font-weight: bold;">String</span>
<span style="color: #008800; font-weight: bold;">Dim</span> dtDate <span style="color: black; font-weight: bold;">As</span> <span style="color: #333399; font-weight: bold;">Date</span>
<span style="color: #008800; font-weight: bold;">Dim</span> sName <span style="color: black; font-weight: bold;">As</span> <span style="color: #333399; font-weight: bold;">String</span>
<span style="color: #008800; font-weight: bold;">Set</span> currentExplorer <span style="color: #333333;">=</span> Application.ActiveExplorer
<span style="color: #008800; font-weight: bold;">Set</span> Selection <span style="color: #333333;">=</span> currentExplorer.Selection
<span style="color: #008800; font-weight: bold;">For</span> <span style="color: #008800; font-weight: bold;">Each</span> obj <span style="color: black; font-weight: bold;">In</span> Selection
<span style="color: #008800; font-weight: bold;">Set</span> oMail <span style="color: #333333;">=</span> obj
SaveAsPDF oMail
<span style="color: #008800; font-weight: bold;">Next</span>
MsgBox <span style="background-color: #fff0f0;">"Selected Emails saved as PDF to C:\Temp folder"</span>
<span style="color: #008800; font-weight: bold;">End</span> <span style="color: #008800; font-weight: bold;">Sub</span>
<span style="color: #008800; font-weight: bold;">Function</span> <span style="color: #0066bb; font-weight: bold;">ResolveDisplayNameToSMTP</span>(sFromName)
<span style="color: #008800; font-weight: bold;">Dim</span> oRecip <span style="color: black; font-weight: bold;">As</span> Outlook.Recipient
<span style="color: #008800; font-weight: bold;">Dim</span> oEU <span style="color: black; font-weight: bold;">As</span> Outlook.ExchangeUser
<span style="color: #008800; font-weight: bold;">Dim</span> oEDL <span style="color: black; font-weight: bold;">As</span> Outlook.ExchangeDistributionList
<span style="color: #008800; font-weight: bold;">Set</span> oRecip <span style="color: #333333;">=</span> Application.Session.CreateRecipient(sFromName)
oRecip.Resolve
<span style="color: #008800; font-weight: bold;">If</span> oRecip.Resolved <span style="color: #008800; font-weight: bold;">Then</span>
<span style="color: #008800; font-weight: bold;">Select</span> <span style="color: #008800; font-weight: bold;">Case</span> oRecip.AddressEntry.AddressEntryUserType
<span style="color: #008800; font-weight: bold;">Case</span> OlAddressEntryUserType.olExchangeUserAddressEntry
<span style="color: #008800; font-weight: bold;">Set</span> oEU <span style="color: #333333;">=</span> oRecip.AddressEntry.GetExchangeUser
<span style="color: #008800; font-weight: bold;">If</span> <span style="color: #008800; font-weight: bold;">Not</span> (oEU <span style="color: black; font-weight: bold;">Is</span> <span style="color: #008800; font-weight: bold;">Nothing</span>) <span style="color: #008800; font-weight: bold;">Then</span>
ResolveDisplayNameToSMTP <span style="color: #333333;">=</span> oEU.PrimarySmtpAddress <span style="color: #333333;">+</span> vbCrLf <span style="color: #333333;">+</span> oEU.BusinessTelephoneNumber
<span style="color: #008800; font-weight: bold;">End</span> <span style="color: #008800; font-weight: bold;">If</span>
<span style="color: #008800; font-weight: bold;">Case</span> OlAddressEntryUserType.olOutlookContactAddressEntry
<span style="color: #008800; font-weight: bold;">Set</span> oEU <span style="color: #333333;">=</span> oRecip.AddressEntry.GetExchangeUser
<span style="color: #008800; font-weight: bold;">If</span> <span style="color: #008800; font-weight: bold;">Not</span> (oEU <span style="color: black; font-weight: bold;">Is</span> <span style="color: #008800; font-weight: bold;">Nothing</span>) <span style="color: #008800; font-weight: bold;">Then</span>
ResolveDisplayNameToSMTP <span style="color: #333333;">=</span> oEU.PrimarySmtpAddress <span style="color: #333333;">+</span> vbCrLf <span style="color: #333333;">+</span> oEU.BusinessTelephoneNumber
<span style="color: #008800; font-weight: bold;">End</span> <span style="color: #008800; font-weight: bold;">If</span>
<span style="color: #008800; font-weight: bold;">Case</span> OlAddressEntryUserType.olExchangeDistributionListAddressEntry
<span style="color: #008800; font-weight: bold;">Set</span> oEDL <span style="color: #333333;">=</span> oRecip.AddressEntry.GetExchangeDistributionList
<span style="color: #008800; font-weight: bold;">If</span> <span style="color: #008800; font-weight: bold;">Not</span> (oEDL <span style="color: black; font-weight: bold;">Is</span> <span style="color: #008800; font-weight: bold;">Nothing</span>) <span style="color: #008800; font-weight: bold;">Then</span>
ResolveDisplayNameToSMTP <span style="color: #333333;">=</span> oEU.PrimarySmtpAddress <span style="color: #333333;">+</span> vbCrLf <span style="color: #333333;">+</span> oEU.BusinessTelephoneNumber
<span style="color: #008800; font-weight: bold;">End</span> <span style="color: #008800; font-weight: bold;">If</span>
<span style="color: #008800; font-weight: bold;">End</span> <span style="color: #008800; font-weight: bold;">Select</span>
<span style="color: #008800; font-weight: bold;">End</span> <span style="color: #008800; font-weight: bold;">If</span>
<span style="color: #008800; font-weight: bold;">End</span> <span style="color: #008800; font-weight: bold;">Function</span> <span style="color: #888888;">' ResolveDisplayNameToSMTP</span>
<span style="color: #008800; font-weight: bold;">Sub</span> <span style="color: #0066bb; font-weight: bold;">SaveAsPDF</span>(MyMail <span style="color: black; font-weight: bold;">As</span> MailItem)
<span style="color: #888888;">' ### Requires reference to Microsoft Scripting Runtime ###</span>
<span style="color: #888888;">' ### Requires reference to Microsoft Word Object Library ###</span>
<span style="color: #888888;">' --- In VBE click TOOLS > REFERENCES and check the boxes for both of the above ---</span>
<span style="color: #008800; font-weight: bold;">Dim</span> fso <span style="color: black; font-weight: bold;">As</span> FileSystemObject
<span style="color: #008800; font-weight: bold;">Dim</span> strSubject <span style="color: black; font-weight: bold;">As</span> <span style="color: #333399; font-weight: bold;">String</span>
<span style="color: #008800; font-weight: bold;">Dim</span> sFromName <span style="color: black; font-weight: bold;">As</span> <span style="color: #333399; font-weight: bold;">String</span>
<span style="color: #008800; font-weight: bold;">Dim</span> strSaveName <span style="color: black; font-weight: bold;">As</span> <span style="color: #333399; font-weight: bold;">String</span>
<span style="color: #008800; font-weight: bold;">Dim</span> sSMTPAddress <span style="color: black; font-weight: bold;">As</span> <span style="color: #333399; font-weight: bold;">String</span>
<span style="color: #008800; font-weight: bold;">Dim</span> blnOverwrite <span style="color: black; font-weight: bold;">As</span> <span style="color: #333399; font-weight: bold;">Boolean</span>
<span style="color: #008800; font-weight: bold;">Dim</span> strFolderPath <span style="color: black; font-weight: bold;">As</span> <span style="color: #333399; font-weight: bold;">String</span>
<span style="color: #008800; font-weight: bold;">Dim</span> sendEmailAddr <span style="color: black; font-weight: bold;">As</span> <span style="color: #333399; font-weight: bold;">String</span>
<span style="color: #008800; font-weight: bold;">Dim</span> senderName <span style="color: black; font-weight: bold;">As</span> <span style="color: #333399; font-weight: bold;">String</span>
<span style="color: #008800; font-weight: bold;">Dim</span> looper <span style="color: black; font-weight: bold;">As</span> <span style="color: #333399; font-weight: bold;">Integer</span>
<span style="color: #008800; font-weight: bold;">Dim</span> plooper <span style="color: black; font-weight: bold;">As</span> <span style="color: #333399; font-weight: bold;">Integer</span>
<span style="color: #008800; font-weight: bold;">Dim</span> strID <span style="color: black; font-weight: bold;">As</span> <span style="color: #333399; font-weight: bold;">String</span>
<span style="color: #008800; font-weight: bold;">Dim</span> olNS <span style="color: black; font-weight: bold;">As</span> Outlook.NameSpace
<span style="color: #008800; font-weight: bold;">Dim</span> oMail <span style="color: black; font-weight: bold;">As</span> Outlook.MailItem
strID <span style="color: #333333;">=</span> MyMail.EntryID
<span style="color: #008800; font-weight: bold;">Set</span> olNS <span style="color: #333333;">=</span> Application.GetNamespace(<span style="background-color: #fff0f0;">"MAPI"</span>)
<span style="color: #008800; font-weight: bold;">Set</span> oMail <span style="color: #333333;">=</span> olNS.GetItemFromID(strID)
<span style="color: #888888;">' ### Get username portion of sender email address ###</span>
senderName <span style="color: #333333;">=</span> oMail.senderName
sendEmailAddr <span style="color: #333333;">=</span> ResolveDisplayNameToSMTP(senderName) <span style="color: #888888;">' use internal internal Exchange domain address if available</span>
<span style="color: #008800; font-weight: bold;">If</span> sendEmailAddr <span style="color: #333333;">=</span> Empty <span style="color: #008800; font-weight: bold;">Then</span> <span style="color: #888888;">' , otherwise use external smtp address</span>
sendEmailAddr <span style="color: #333333;">=</span> oMail.SenderEmailAddress
<span style="color: #008800; font-weight: bold;">End</span> <span style="color: #008800; font-weight: bold;">If</span>
<span style="color: #888888;">' ### USER OPTIONS ###</span>
blnOverwrite <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">False</span> <span style="color: #888888;">' False = don't overwrite, True = do overwrite</span>
<span style="color: #888888;">' ### Path to save directory ###</span>
bPath <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">"C:\Temp\"</span>
<span style="color: #888888;">' ### Create Directory if it doesnt exist ###</span>
<span style="color: #008800; font-weight: bold;">If</span> Dir(bPath, vbDirectory) <span style="color: #333333;">=</span> vbNullString <span style="color: #008800; font-weight: bold;">Then</span>
MkDir bPath
<span style="color: #008800; font-weight: bold;">End</span> <span style="color: #008800; font-weight: bold;">If</span>
<span style="color: #888888;">' ### Get Email subject & set name to be saved as ###</span>
emailSubject <span style="color: #333333;">=</span> CleanFileName(oMail.Subject)
saveName <span style="color: #333333;">=</span> Format(oMail.ReceivedTime, <span style="background-color: #fff0f0;">"yyyy-mm-dd-hhmm"</span>) <span style="color: #333333;">&</span> <span style="background-color: #fff0f0;">"_"</span> <span style="color: #333333;">&</span> emailSubject <span style="color: #333333;">&</span> <span style="background-color: #fff0f0;">".mht"</span>
<span style="color: #008800; font-weight: bold;">Set</span> fso <span style="color: #333333;">=</span> CreateObject(<span style="background-color: #fff0f0;">"Scripting.FileSystemObject"</span>)
<span style="color: #888888;">' ### Increment filename if it already exists ###</span>
<span style="color: #008800; font-weight: bold;">If</span> blnOverwrite <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">False</span> <span style="color: #008800; font-weight: bold;">Then</span>
looper <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">0</span>
<span style="color: #008800; font-weight: bold;">Do</span> <span style="color: #008800; font-weight: bold;">While</span> fso.FileExists(bPath <span style="color: #333333;">&</span> saveName)
looper <span style="color: #333333;">=</span> looper <span style="color: #333333;">+</span> <span style="color: #0000dd; font-weight: bold;">1</span>
saveName <span style="color: #333333;">=</span> Format(oMail.ReceivedTime, <span style="background-color: #fff0f0;">"yyyy-mm-dd-hhmm"</span>) <span style="color: #333333;">&</span> <span style="background-color: #fff0f0;">"_"</span> <span style="color: #333333;">&</span> senderName <span style="color: #333333;">&</span> <span style="background-color: #fff0f0;">"_"</span> <span style="color: #333333;">&</span> emailSubject <span style="color: #333333;">&</span> <span style="background-color: #fff0f0;">"_"</span> <span style="color: #333333;">&</span> looper <span style="color: #333333;">&</span> <span style="background-color: #fff0f0;">".mht"</span>
<span style="color: #008800; font-weight: bold;">Loop</span>
<span style="color: #008800; font-weight: bold;">Else</span>
<span style="color: #008800; font-weight: bold;">End</span> <span style="color: #008800; font-weight: bold;">If</span>
<span style="color: #888888;">' ### Save .mht file to create pdf from Word ###</span>
oMail.SaveAs bPath <span style="color: #333333;">&</span> saveName, olMHTML
pdfSave <span style="color: #333333;">=</span> bPath <span style="color: #333333;">&</span> Format(oMail.ReceivedTime, <span style="background-color: #fff0f0;">"yyyy-mm-dd-hhmm"</span>) <span style="color: #333333;">&</span> <span style="background-color: #fff0f0;">"_"</span> <span style="color: #333333;">&</span> senderName <span style="color: #333333;">&</span> <span style="background-color: #fff0f0;">"_"</span> <span style="color: #333333;">&</span> emailSubject <span style="color: #333333;">&</span> <span style="background-color: #fff0f0;">".pdf"</span>
<span style="color: #008800; font-weight: bold;">If</span> fso.FileExists(pdfSave) <span style="color: #008800; font-weight: bold;">Then</span>
plooper <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">0</span>
<span style="color: #008800; font-weight: bold;">Do</span> <span style="color: #008800; font-weight: bold;">While</span> fso.FileExists(pdfSave)
plooper <span style="color: #333333;">=</span> plooper <span style="color: #333333;">+</span> <span style="color: #0000dd; font-weight: bold;">1</span>
pdfSave <span style="color: #333333;">=</span> bPath <span style="color: #333333;">&</span> Format(oMail.ReceivedTime, <span style="background-color: #fff0f0;">"yyyy-mm-dd-hhmm"</span>) <span style="color: #333333;">&</span> <span style="background-color: #fff0f0;">"_"</span> <span style="color: #333333;">&</span> senderName <span style="color: #333333;">&</span> <span style="background-color: #fff0f0;">"_"</span> <span style="color: #333333;">&</span> emailSubject <span style="color: #333333;">&</span> <span style="background-color: #fff0f0;">"_"</span> <span style="color: #333333;">&</span> plooper <span style="color: #333333;">&</span> <span style="background-color: #fff0f0;">".pdf"</span>
<span style="color: #008800; font-weight: bold;">Loop</span>
<span style="color: #008800; font-weight: bold;">Else</span>
<span style="color: #008800; font-weight: bold;">End</span> <span style="color: #008800; font-weight: bold;">If</span>
<span style="color: #888888;">' ### Open Word to convert .mht file to PDF ###</span>
<span style="color: #008800; font-weight: bold;">Dim</span> wrdApp <span style="color: black; font-weight: bold;">As</span> Word.Application
<span style="color: #008800; font-weight: bold;">Dim</span> wrdDoc <span style="color: black; font-weight: bold;">As</span> Word.Document
<span style="color: #008800; font-weight: bold;">Set</span> wrdApp <span style="color: #333333;">=</span> CreateObject(<span style="background-color: #fff0f0;">"Word.Application"</span>)
<span style="color: #888888;">' ### Open .mht file we just saved and export as PDF ###</span>
<span style="color: #888888;">' ActiveDocument.PrintOut PrintZoomPaperWidth:= 72 * 8.5, PrintZoomPaperHeight:= 72 * 11</span>
<span style="color: #008800; font-weight: bold;">Set</span> wrdDoc <span style="color: #333333;">=</span> wrdApp.Documents.Open(FileName:<span style="color: #333333;">=</span>bPath <span style="color: #333333;">&</span> saveName, Visible:<span style="color: #333333;">=</span><span style="color: #008800; font-weight: bold;">True</span>)
PicturesFitPageWidth wrdApp.ActiveDocument
wrdApp.ActiveDocument.ExportAsFixedFormat OutputFileName:<span style="color: #333333;">=</span> _
pdfSave, ExportFormat:<span style="color: #333333;">=</span> _
wdExportFormatPDF, OpenAfterExport:<span style="color: #333333;">=</span><span style="color: #008800; font-weight: bold;">False</span>, OptimizeFor:<span style="color: #333333;">=</span> _
wdExportOptimizeForPrint, Range:<span style="color: #333333;">=</span>wdExportAllDocument, from:<span style="color: #333333;">=</span><span style="color: #0000dd; font-weight: bold;">0</span>, <span style="color: #008800; font-weight: bold;">To</span>:<span style="color: #333333;">=</span><span style="color: #0000dd; font-weight: bold;">0</span>, _
Item:<span style="color: #333333;">=</span>wdExportDocumentContent, IncludeDocProps:<span style="color: #333333;">=</span><span style="color: #008800; font-weight: bold;">True</span>, KeepIRM:<span style="color: #333333;">=</span><span style="color: #008800; font-weight: bold;">True</span>, _
CreateBookmarks:<span style="color: #333333;">=</span>wdExportCreateNoBookmarks, DocStructureTags:<span style="color: #333333;">=</span><span style="color: #008800; font-weight: bold;">True</span>, _
BitmapMissingFonts:<span style="color: #333333;">=</span><span style="color: #008800; font-weight: bold;">True</span>, UseISO19005_1:<span style="color: #333333;">=</span><span style="color: #008800; font-weight: bold;">False</span>
wrdDoc.Close
wrdApp.Quit
<span style="color: #888888;">' ### Delete .mht file ###</span>
<span style="color: #888888;">'mht file is good if tables are used, preserves the full file, so keep them both for now.</span>
<span style="color: #888888;">'Kill bPath & saveName</span>
<span style="color: #888888;">' ### Uncomment this section to save attachments ###</span>
<span style="color: #888888;">'If oMail.Attachments.Count > 0 Then</span>
<span style="color: #888888;">' For Each atmt In oMail.Attachments</span>
<span style="color: #888888;">' atmtName = CleanFileName(atmt.FileName)</span>
<span style="color: #888888;">' atmtSave = bPath & Format(oMail.ReceivedTime, "yyyy-mm-dd-hhmm") & "_" & atmtName</span>
<span style="color: #888888;">' atmt.SaveAsFile atmtSave</span>
<span style="color: #888888;">' Next</span>
<span style="color: #888888;">'End If</span>
<span style="color: #008800; font-weight: bold;">Set</span> oMail <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">Nothing</span>
<span style="color: #008800; font-weight: bold;">Set</span> olNS <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">Nothing</span>
<span style="color: #008800; font-weight: bold;">Set</span> fso <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">Nothing</span>
<span style="color: #008800; font-weight: bold;">End</span> <span style="color: #008800; font-weight: bold;">Sub</span>
<span style="color: #008800; font-weight: bold;">Sub</span> <span style="color: #0066bb; font-weight: bold;">PicturesFitPageWidth</span>(ActiveDocument <span style="color: black; font-weight: bold;">As</span> <span style="color: #333399; font-weight: bold;">Variant</span>)
<span style="color: #888888;">' ResizePic Macro</span>
<span style="color: #888888;">' Resizes an image</span>
Shapes <span style="color: #333333;">=</span> ActiveDocument.Shapes.count
InLines <span style="color: #333333;">=</span> ActiveDocument.InlineShapes.count
oTables <span style="color: #333333;">=</span> ActiveDocument.Tables.count
<span style="color: #888888;">'Sets the variables to loop through all shapes in the document, one for shapes and one for inline shapes.</span>
<span style="color: #888888;">'Calculate usable width of page</span>
<span style="color: #008800; font-weight: bold;">With</span> ActiveDocument.PageSetup
WidthAvail <span style="color: #333333;">=</span> .PageWidth <span style="color: #333333;">-</span> .LeftMargin <span style="color: #333333;">-</span> .RightMargin
<span style="color: #008800; font-weight: bold;">End</span> <span style="color: #008800; font-weight: bold;">With</span>
<span style="color: #888888;">'Loop through all shapes and lines in the document. Checks to see if they're too wide, and if they are, resizes them.</span>
<span style="color: #008800; font-weight: bold;">For</span> ShapeLoop <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">1</span> <span style="color: #008800; font-weight: bold;">To</span> Shapes
<span style="color: #888888;">'MsgBox Prompt:="Shape " & ShapeLoop & " width: " & ActiveDocument.Shapes(ShapeLoop).Width</span>
<span style="color: #008800; font-weight: bold;">If</span> ActiveDocument.Shapes(ShapeLoop).Width <span style="color: #333333;">></span> WidthAvail <span style="color: #008800; font-weight: bold;">Then</span>
ActiveDocument.Shapes(ShapeLoop).Width <span style="color: #333333;">=</span> WidthAvail
<span style="color: #008800; font-weight: bold;">End</span> <span style="color: #008800; font-weight: bold;">If</span>
<span style="color: #008800; font-weight: bold;">Next</span> ShapeLoop
<span style="color: #008800; font-weight: bold;">For</span> InLineLoop <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">1</span> <span style="color: #008800; font-weight: bold;">To</span> InLines
<span style="color: #888888;">'MsgBox Prompt:="Inline " & InLineLoop & " width: " & ActiveDocument.InlineShapes(InLineLoop).Width</span>
<span style="color: #008800; font-weight: bold;">If</span> ActiveDocument.InlineShapes(InLineLoop).Width <span style="color: #333333;">></span> WidthAvail <span style="color: #008800; font-weight: bold;">Then</span>
ActiveDocument.InlineShapes(InLineLoop).Width <span style="color: #333333;">=</span> WidthAvail
<span style="color: #008800; font-weight: bold;">End</span> <span style="color: #008800; font-weight: bold;">If</span>
<span style="color: #008800; font-weight: bold;">Next</span> InLineLoop
<span style="color: #008800; font-weight: bold;">End</span> <span style="color: #008800; font-weight: bold;">Sub</span>
</pre></div>
Christopher Wiggintonhttp://www.blogger.com/profile/02433309097120061094noreply@blogger.com0tag:blogger.com,1999:blog-2973693700394445577.post-53191080030257265712022-05-17T07:48:00.005-07:002022-05-18T04:59:51.281-07:00JavaScript Grids: Handsontable<p> </p><p>I've always been a fan of the original jQuery <a href="https://editor.datatables.net/purchase/index">DataTables </a>which has been a very tight grid. A worthy competitor that has a very appealing look and more support for the more recent JavaScript frameworks is <a href="https://handsontable.com/demo">Handsontable</a>. It's a little pricey on the commercial license as opposed to DataTables, but there is a free version you can use to check out the functionality. </p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiUfxp1PSWkItsv1DYqs_NxiANvdE2h5gzfih26jI9alcagHnya0bLINU9P7LWtkcFKC77SFdlUyNzrjrmK38Ec-Za_WBrfsVWF3zgy0yvjtYZ1KALrrJLI7uv4f7uRFmZS6tajxBiUQYbGZnvn6vS1aM5MfRyZU4A62jsX7sROdF-jta7nMs4qNq2_Kw/s1169/handsontable.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="546" data-original-width="1169" height="149" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiUfxp1PSWkItsv1DYqs_NxiANvdE2h5gzfih26jI9alcagHnya0bLINU9P7LWtkcFKC77SFdlUyNzrjrmK38Ec-Za_WBrfsVWF3zgy0yvjtYZ1KALrrJLI7uv4f7uRFmZS6tajxBiUQYbGZnvn6vS1aM5MfRyZU4A62jsX7sROdF-jta7nMs4qNq2_Kw/s320/handsontable.PNG" width="320" /></a></div><br /><p></p><p></p><div class="separator" style="clear: both; text-align: center;"><br /></div><br /><br /><p></p>Christopher Wiggintonhttp://www.blogger.com/profile/02433309097120061094noreply@blogger.com0tag:blogger.com,1999:blog-2973693700394445577.post-68921339935507542102022-05-11T13:43:00.006-07:002022-05-17T08:52:49.734-07:00openCSV in ColdFusion and Lucee<p> The opencsv project at http://opencsv.sourceforge.net/ is a nice overall java based csv parser library that can automatically support qualified strings that contain comma's. The below code works in ColdFusion 2021 as is with the opencsv.jar file but needs an additional jar with Lucee 5.3.9.</p><p><b>ColdFusion and Lucee: </b></p><p>Grab the source from opencsv.sourceforge.net and run mvn to produce the jar. I used version 5.6.</p><p><b>Lucee:</b></p><p>Download the apache commons lang3 source from https://commons.apache.org/proper/commons-lang/download_lang.cgi and compile with maven.</p>
<p></p><table>
<tbody><tr><td>opencsv-5.6.1-SNAPSHOT.jar</td></tr>
<tr><td>commons-lang3-3.12.0.jar</td></tr>
</tbody></table><p></p>
<p>Put the jar(s) in the lib folder of the server or use a jar loader. start up the server and run the following test (adjust the path to your sample csv data file). which should produce the data below (excluding the other dumps)</p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEhIoj8hyovHtR4fGA4zLlTx0ojj4SMDIhJPgkAbCnC7RVXi0vgCVY8YESJqQuCeJT2IxjrhzPipYHc9jHKIlarg-YgXMHEtKpmNqBoD5Z-77pGAJGOJjVoL6pOCjepgJDNGRIDRWqffdXRqpUMWSlZvT-vo54qIDwNCo02rDJFdU0U8qxT87Tozv_6IyA" style="margin-left: 1em; margin-right: 1em;"><img alt="" data-original-height="316" data-original-width="363" height="240" src="https://blogger.googleusercontent.com/img/a/AVvXsEhIoj8hyovHtR4fGA4zLlTx0ojj4SMDIhJPgkAbCnC7RVXi0vgCVY8YESJqQuCeJT2IxjrhzPipYHc9jHKIlarg-YgXMHEtKpmNqBoD5Z-77pGAJGOJjVoL6pOCjepgJDNGRIDRWqffdXRqpUMWSlZvT-vo54qIDwNCo02rDJFdU0U8qxT87Tozv_6IyA" width="276" /></a></div><br /><br /><p></p>
<!--HTML generated using hilite.me--><div style="background: rgb(255, 255, 255); border-color: gray; border-image: initial; border-style: solid; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;"><span style="color: #007020;"><cfscript></span>
<span style="color: #996633;">csvFile</span> <span style="color: #333333;">=</span><span style="background-color: #fff0f0;">"#expandPath('.')#/csv_data/addresses.csv"</span>;
<span style="color: #996633;">csvData</span> <span style="color: #333333;">=</span> [];
<span style="color: #996633;">fileReader</span> <span style="color: #333333;">=</span> <span style="color: #0066bb; font-weight: bold;">createobject</span>(<span style="background-color: #fff0f0;">"java"</span>,<span style="background-color: #fff0f0;">"java.io.FileReader"</span>).<span style="color: #0066bb; font-weight: bold;">init</span>(<span style="color: #996633;">csvFile</span>);
<span style="color: #0066bb; font-weight: bold;">writeDump</span>(<span style="color: #996633;">fileReader</span>);
<span style="color: #996633;">csvReader</span> <span style="color: #333333;">=</span> <span style="color: #0066bb; font-weight: bold;">createObject</span>(<span style="background-color: #fff0f0;">"java"</span>,<span style="background-color: #fff0f0;">"com.opencsv.CSVReader"</span>).<span style="color: #0066bb; font-weight: bold;">init</span>(<span style="color: #996633;">fileReader</span>);
<span style="color: #0066bb; font-weight: bold;">writeDump</span>(<span style="color: #996633;">csvReader</span>);</pre><pre style="line-height: 125%; margin: 0px;"> <span style="color: #996633;">csvData</span> <span style="color: #333333;">=</span> <span style="color: #0066bb; font-weight: bold;">csvReader.readAll</span>();
<span style="color: #0066bb; font-weight: bold;">writeDump</span>(<span style="color: #996633;">csvData</span>);
<span style="color: #0066bb; font-weight: bold;">csvReader.close</span>();
<span style="color: #007020;"></cfscript></span></pre></div>
Christopher Wiggintonhttp://www.blogger.com/profile/02433309097120061094noreply@blogger.com0tag:blogger.com,1999:blog-2973693700394445577.post-16495838007278902732021-06-28T07:01:00.004-07:002021-06-28T07:22:04.896-07:00CMUD: Experiment in creating a visible color map
The createColorMap alias in CMUD will generate a pattern of rooms showing you each room color used in mapping.<div><br />
<!--HTML generated using hilite.me--><div style="background: rgb(255, 255, 255); border-color: gray; border-image: initial; border-style: solid; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;"><span style="color: #007700;"><br /></span></pre><pre style="line-height: 125%; margin: 0px;"><span style="color: #007700;"><alias</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"createColorMap"</span> <span style="color: #0000cc;">language=</span><span style="background-color: #fff0f0;">"Lua"</span> <span style="color: #0000cc;">id=</span><span style="background-color: #fff0f0;">"179"</span><span style="color: #007700;">></span>
<span style="color: #007700;"><value></span>local mapcolors ={"aliceblue", "antiquewhite", "aqua", "aquamarine", "azure", "beige", "bisque", "black",
"blanchedalmond", "blue", "blueviolet", "brown", "burlywood", "cadetblue", "chartreuse",
"chocolate", "coral", "cornflowerblue", "cornsilk", "crimson", "cyan", "darkblue", "darkcyan",
"darkgoldenrod", "darkgray", "darkgreen", "darkkhaki", "darkmagenta", "darkolivegreen", "darkorange",
"darkorchid", "darkred", "darksalmon", "darkseagreen", "darkslateblue", "darkslategray",
"darkturquoise", "darkviolet", "deeppink", "deepskyblue", "dimgray", "dodgerblue", "firebrick",
"floralwhite", "forestgreen", "fuchsia", "gainsboro", "ghostwhite", "gold", "goldenrod", "gray",
"green", "greenyellow", "honeydew", "hotpink", "indianred", "indigo", "ivory", "khaki",
"lavender", "lavenderblush", "lawngreen", "lemonchiffon", "lightblue", "lightcoral",
"lightcyan", "lightgoldenrodyellow", "lightgreen", "lightgrey", "lightpink", "lightsalmon",
"lightseagreen", "lightskyblue", "lightslategray", "lightsteelblue", "lightyellow", "lime",
"limegreen", "linen", "magenta", "maroon", "mediumaquamarine", "mediumblue", "mediumorchid",
"mediumpurple", "mediumseagreen", "mediumslateblue", "mediumspringgreen", "mediumturquoise",
"mediumvioletred", "midnightblue", "mintcream", "mistyrose", "moccasin", "navajowhite", "navy",
"oldlace", "olive", "olivedrab", "orange", "orangered", "orchid", "palegoldenrod", "palegreen",
"paleturquoise", "palevioletred", "papayawhip", "peachpuff", "peru", "pink", "plum", "powderblue",
"purple", "red", "rosybrown", "royalblue", "saddlebrown", "salmon", "sandybrown", "seagreen",
"seashell", "sienna", "silver", "skyblue", "slateblue", "slategray", "snow", "springgreen",
"steelblue", "tan", "teal", "thistle", "tomato", "turquoise", "violet", "wheat", "white"
, "whitesmoke", "yellow", "yellowgreen"}
function tablelength(T)
local count = 0
for _ in pairs(T) do count = count + 1 end
return count
end
local maxcolumns = 10
local colorcount = tablelength(mapcolors)
local mapdir
local c
local targetcolor = 0
local r = 0
local numrows = colorcount/maxcolumns + 1
for r = 1, numrows do
if r % 2 == 0 then
mapdir = "e"
else
mapdir = "w"
end
-- always drop down for each row
targetcolor = targetcolor + 1
if targetcolor <span style="color: #880000; font-weight: bold;">&gt;</span> colorcount then
break;
end
zs.make("s",mapcolors[targetcolor])
zs.func.roomcol(null,mapcolors[targetcolor])
for c = 1,maxcolumns - 1 do
targetcolor = targetcolor + 1
if targetcolor <span style="color: #880000; font-weight: bold;">&gt;</span> colorcount then
break;
end
zs.make(mapdir,mapcolors[targetcolor])
zs.func.roomcol(null,mapcolors[targetcolor])
end
end
<span style="color: #007700;"></value></span>
<span style="color: #007700;"></alias></span>
</pre></div>
</div>Christopher Wiggintonhttp://www.blogger.com/profile/02433309097120061094noreply@blogger.com0tag:blogger.com,1999:blog-2973693700394445577.post-54285923470672148092021-01-09T09:04:00.004-08:002022-08-23T14:26:02.850-07:00Mud and cmud mapping<p> </p><p>If you use cmud client, the following will capture room descriptions to the map. It's not elegant code wise in that it requires a special color combination for room descriptions to enable the scripts to only see the room lines, build up the description and then update on the description termination Terrain.</p><p><b>Variables</b><br /><br /><span style="color: #2b00fe;">flag to turn description capture on/off</span><br />#var roomdesc 1<br /><br /><span style="color: #2b00fe;">holds the captured text of a description</span><br />#var description_store ""</p><p><span style="color: #2b00fe;">a placeholder to capture result of function so as not to display on mud</span><br />#var result</p><p><b>Aliases</b></p><p><alias name="roomson" id="136"><br /> <value>#var roomdesc 1;#show you have turned on update room desc.</value><br /></alias></p><p><alias name="roomsoff" id="137"><br /> <value>#var roomdesc 0;#show you have turned off update room desc.</value><br /></alias></p><p><b>Triggers</b></p><p><span style="color: #2b00fe;">Creates a trigger that matches any text that matches a foreground/background color. The description color has to be a unique combo. each line is captured and adds it to the description_store variable and then when the 2nd trigger "Terrain:" hits, it updates the map room description</span></p><p><trigger priority="1310" regex="true" linecolor="112" id="131"><br /> <pattern>(.*)</pattern><br /><value>#var description_store %concat(@description_store,%1)</value><br /></trigger></p><p><trigger priority="1330" id="133"><br /><pattern>Terrain:</pattern><br /> <value><br />#if (@roomdesc == 1) {<br />#var foo %roomdesc(%roomvnum,@description_store);<br />}<br />#var description_store "";<br /></value><br /></trigger></p>Christopher Wiggintonhttp://www.blogger.com/profile/02433309097120061094noreply@blogger.com0tag:blogger.com,1999:blog-2973693700394445577.post-83901739797857038182020-12-07T05:18:00.003-08:002020-12-07T05:18:43.491-08:00Bash: Script to archive files into YYYY/MM based on creation date<p> I had over 10 years of photos that I wanted to organize by YYYY/MM. Created this Bash script to do it.</p><div style="background: rgb(238, 238, 221); border-color: gray; border-image: initial; border-style: solid; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;"><span style="color: forestgreen;">#!/bin/sh</span>
<span style="color: forestgreen;">#script: archiver.sh</span>
<span style="color: forestgreen;">#</span>
<span style="color: forestgreen;">#</span>
<span style="color: #00688b;">sourceDir</span>=<span style="color: #cd5555;">"/f/from_kims_ext/"</span>
<span style="color: forestgreen;">#sourceDir="/f/test/"</span>
<span style="color: #00688b;">archiveDir</span>=<span style="color: #cd5555;">"/f/image_archive/"</span>
<span style="color: #00688b;">ARCHIVEFILE</span>=<span style="color: #cd5555;">"/f/move_archive.txt"</span>
<span style="color: darkmagenta; font-weight: bold;">function </span>getfilelist {
<span style="color: #cd5555;">`</span>ls -Rp <span style="color: #00688b;">$sourceDir</span> | awk <span style="color: #cd5555;">'</span>
<span style="color: #cd5555;">/:$/&&f{s=$0;f=0}</span>
<span style="color: #cd5555;">/:$/&&!f{sub(/:$/,"");s=$0;f=1;next}</span>
<span style="color: #cd5555;">NF&&f{ print s"/"$0 }'</span> | sed <span style="color: #cd5555;">"/\/$/d"</span> > <span style="color: #00688b;">$ARCHIVEFILE</span><span style="color: #cd5555;">`</span>
}
<span style="color: darkmagenta; font-weight: bold;">function </span>parsefilename {
<span style="color: #00688b;">sourcefilename</span>=<span style="color: #cd5555;">`</span>basename <span style="color: #00688b;">$1</span><span style="color: #cd5555;">`</span>
<span style="color: #00688b;">extension</span>=<span style="color: #cd5555;">"${sourcefilename##*.}"</span>
<span style="color: #00688b;">filename</span>=<span style="color: #cd5555;">"${sourcefilename%.*}"</span>
}
<span style="color: darkmagenta; font-weight: bold;">function </span>updatefilename {
<span style="color: #658b00;">typeset </span>counter
<span style="color: #00688b;">counter</span>=0
<span style="color: forestgreen;">#check if ok to use original filename</span>
<span style="color: #00688b;">updatecheck</span>=<span style="color: #cd5555;">"$archiveDir$datepath/$filename.$extension"</span>
<span style="color: #658b00;">echo</span> <span style="color: #cd5555;">"checking if target $updatecheck exists"</span>
<span style="color: forestgreen;"># if [[ -f $updatecheck ]]; then</span>
<span style="color: darkmagenta; font-weight: bold;">if</span> [ ! -f <span style="color: darkmagenta; font-weight: bold;">${</span><span style="color: #00688b;">updatecheck</span><span style="color: darkmagenta; font-weight: bold;">}</span> ]; <span style="color: darkmagenta; font-weight: bold;">then</span>
<span style="color: darkmagenta; font-weight: bold;"> </span><span style="color: #658b00;">echo</span> <span style="color: #cd5555;">"$updatecheck does not exist"</span>
<span style="color: darkmagenta; font-weight: bold;">return</span>
<span style="color: darkmagenta; font-weight: bold;"> else</span>
<span style="color: darkmagenta; font-weight: bold;"> </span><span style="color: #658b00;">echo</span> <span style="color: #cd5555;">"$updatecheck exists"</span>
<span style="color: darkmagenta; font-weight: bold;">fi</span>
<span style="color: darkmagenta; font-weight: bold;"> while</span> [[ <span style="color: #00688b;">$counter</span> -lt 200 ]]
<span style="color: darkmagenta; font-weight: bold;">do</span>
<span style="color: darkmagenta; font-weight: bold;"> </span><span style="color: #00688b;">counter</span>=<span style="color: darkmagenta; font-weight: bold;">$((</span>counter+1<span style="color: darkmagenta; font-weight: bold;">))</span>
<span style="color: #00688b;">updatecheckinc</span>=<span style="color: #cd5555;">"$archiveDir$datepath/$filename"</span>
updatecheckinc+=<span style="color: #cd5555;">"_"</span>
updatecheckinc+=<span style="color: #cd5555;">"$counter.$extension"</span>
<span style="color: #658b00;">echo</span> <span style="color: #cd5555;">"checking for new $updatecheckinc"</span>
<span style="color: darkmagenta; font-weight: bold;">if</span> [[ ! -f <span style="color: #cd5555;">"${updatecheckinc}"</span> ]]; <span style="color: darkmagenta; font-weight: bold;">then</span>
<span style="color: darkmagenta; font-weight: bold;"> </span><span style="color: #658b00;">break</span>
<span style="color: #658b00;"> </span><span style="color: darkmagenta; font-weight: bold;">fi</span>
<span style="color: darkmagenta; font-weight: bold;"> done</span>
<span style="color: forestgreen;"># changing name because it already exists, so increment to new file name</span>
filename+=<span style="color: #cd5555;">"_"</span>
filename+=<span style="color: #cd5555;">"$counter"</span>
<span style="color: #658b00;">echo</span> <span style="color: #cd5555;">"updating filename to $filename"</span>
<span style="color: darkmagenta; font-weight: bold;">return</span>
}
<span style="color: #658b00;">set</span> -u
<span style="color: forestgreen;">#LOG_TIME=`date |cut -c12-13,15-16,21-23| sed s/" "//g`</span>
<span style="color: #00688b;">LOG_TIME</span>=<span style="color: #cd5555;">`</span>date<span style="color: #cd5555;">`</span>
<span style="color: #00688b;">thisyear</span>=<span style="color: #cd5555;">`</span>date +<span style="color: #cd5555;">"%Y"`</span>
<span style="color: #00688b;">thismonth</span>=<span style="color: #cd5555;">`</span>date +<span style="color: #cd5555;">"%m"`</span>
<span style="color: #658b00;">echo</span> <span style="color: #cd5555;">"archive starting..."</span>
<span style="color: #658b00;">echo</span> <span style="color: #cd5555;">"Starting archive at $LOG_TIME"</span>
getfilelist
<span style="color: forestgreen;"># Setting delimiter to an empty string since we want to read the entire line of the file</span>
<span style="color: forestgreen;"># and be able to handle files with spaces since the default is a space delimiter</span>
<span style="color: #00688b;">SAVEIFS</span>=<span style="color: #00688b;">$IFS</span>
<span style="color: #00688b;">IFS</span>=<span style="color: #cd5555;">$''</span>
((<span style="color: #00688b;">archived_moved</span>=0))
<span style="color: darkmagenta; font-weight: bold;">while </span><span style="color: #658b00;">read </span>file
<span style="color: darkmagenta; font-weight: bold;">do</span>
<span style="color: darkmagenta; font-weight: bold;"> </span>parsefilename <span style="color: #00688b;">$file</span>
<span style="color: #658b00;">echo</span> <span style="color: #cd5555;">"processing $filename with extension $extension"</span>
<span style="color: #00688b;">fDate</span>=<span style="color: #cd5555;">`</span>stat -c %y <span style="color: #cd5555;">"${file}"`</span>
<span style="color: #00688b;">fDate</span>=<span style="color: darkmagenta; font-weight: bold;">$(</span><span style="color: #658b00;">echo</span> <span style="color: #cd5555;">"$fDate"</span> | cut -d<span style="color: #cd5555;">' '</span> -f1<span style="color: darkmagenta; font-weight: bold;">)</span>
<span style="color: forestgreen;">#example 2018-01-12</span>
<span style="color: #00688b;">year</span>=<span style="color: darkmagenta; font-weight: bold;">$(</span><span style="color: #658b00;">echo</span> <span style="color: darkmagenta; font-weight: bold;">${</span><span style="color: #00688b;">fDate</span><span style="color: darkmagenta; font-weight: bold;">}</span> | cut -d<span style="color: #cd5555;">'-'</span> -f1 <span style="color: darkmagenta; font-weight: bold;">)</span>
<span style="color: #00688b;">month</span>=<span style="color: darkmagenta; font-weight: bold;">$(</span><span style="color: #658b00;">echo</span> <span style="color: darkmagenta; font-weight: bold;">${</span><span style="color: #00688b;">fDate</span><span style="color: darkmagenta; font-weight: bold;">}</span> | cut -d<span style="color: #cd5555;">'-'</span> -f2<span style="color: darkmagenta; font-weight: bold;">)</span>
<span style="color: #00688b;">day</span>=<span style="color: darkmagenta; font-weight: bold;">$(</span><span style="color: #658b00;">echo</span> <span style="color: darkmagenta; font-weight: bold;">${</span><span style="color: #00688b;">fDate</span><span style="color: darkmagenta; font-weight: bold;">}</span> | cut -d<span style="color: #cd5555;">'-'</span> -f3<span style="color: darkmagenta; font-weight: bold;">)</span>
<span style="color: #00688b;">filedate</span>=<span style="color: darkmagenta; font-weight: bold;">${</span><span style="color: #00688b;">year</span><span style="color: darkmagenta; font-weight: bold;">}${</span><span style="color: #00688b;">month</span><span style="color: darkmagenta; font-weight: bold;">}</span>
<span style="color: darkmagenta; font-weight: bold;">if</span> [ <span style="color: darkmagenta; font-weight: bold;">$(</span><span style="color: #658b00;">echo</span> <span style="color: #cd5555;">"$filedate"</span> | grep -c <span style="color: #cd5555;">'^[0-9]\{6\}$'</span><span style="color: darkmagenta; font-weight: bold;">)</span> -eq 1 ]
<span style="color: darkmagenta; font-weight: bold;">then</span>
<span style="color: darkmagenta; font-weight: bold;"> if</span> [ ! -d <span style="color: darkmagenta; font-weight: bold;">${</span><span style="color: #00688b;">archiveDir</span><span style="color: darkmagenta; font-weight: bold;">}${</span><span style="color: #00688b;">year</span><span style="color: darkmagenta; font-weight: bold;">}</span>/<span style="color: darkmagenta; font-weight: bold;">${</span><span style="color: #00688b;">month</span><span style="color: darkmagenta; font-weight: bold;">}</span> ]
<span style="color: darkmagenta; font-weight: bold;">then</span>
<span style="color: darkmagenta; font-weight: bold;"> </span><span style="color: #658b00;">echo</span> <span style="color: #cd5555;">"echo making directory $archiveDir$year/$month"</span>
mkdir -p <span style="color: darkmagenta; font-weight: bold;">${</span><span style="color: #00688b;">archiveDir</span><span style="color: darkmagenta; font-weight: bold;">}${</span><span style="color: #00688b;">year</span><span style="color: darkmagenta; font-weight: bold;">}</span>/<span style="color: darkmagenta; font-weight: bold;">${</span><span style="color: #00688b;">month</span><span style="color: darkmagenta; font-weight: bold;">}</span>
<span style="color: darkmagenta; font-weight: bold;">fi</span>
<span style="color: darkmagenta; font-weight: bold;"> </span><span style="color: #00688b;">datepath</span>=<span style="color: #cd5555;">"${year}/${month}"</span>
updatefilename
<span style="color: #658b00;">echo</span> <span style="color: #cd5555;">"Archiving ${file} to ${archiveDir}${datepath}/$filename.$extension"</span>
mv <span style="color: #cd5555;">"${file}"</span> <span style="color: #cd5555;">"${archiveDir}${datepath}/${filename}.${extension}"</span>
((<span style="color: #00688b;">archived_moved</span>=archived_moved+1))
<span style="color: darkmagenta; font-weight: bold;">else</span>
<span style="color: darkmagenta; font-weight: bold;"> </span><span style="color: #658b00;">echo</span> <span style="color: #cd5555;">"Couldn't get stat on ${reportBakDir}${file}"</span>
<span style="color: darkmagenta; font-weight: bold;">fi</span>
<span style="color: darkmagenta; font-weight: bold;">done</span> <<span style="color: #cd5555;">"$ARCHIVEFILE"</span>
<span style="color: #00688b;">IFS</span>=<span style="color: #00688b;">$SAVEIFS</span>
<span style="color: forestgreen;">#END_TIME=`date |cut -c12-13,15-16,21-23| /usr/bin/sed s/" "//g`</span>
<span style="color: #00688b;">END_TIME</span>=<span style="color: #cd5555;">`</span>date<span style="color: #cd5555;">`</span>
<span style="color: #658b00;">echo</span> <span style="color: #cd5555;">"Completed archive at $END_TIME"</span>
<span style="color: #658b00;">exit </span>0
</pre></div>
Christopher Wiggintonhttp://www.blogger.com/profile/02433309097120061094noreply@blogger.com0tag:blogger.com,1999:blog-2973693700394445577.post-77797720016539366232020-08-25T05:25:00.002-07:002020-08-25T05:25:49.522-07:00Python 3: RegEx Back ReferencesRegual Expressions is one of those things that isn't completely regular when switching between languages.
This is how you use a back reference in Python.<div><br />
<!--HTML generated using hilite.me--><div style="background: rgb(39, 40, 34); border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;"><span style="color: #f92672;">import</span> <span style="color: #f8f8f2;">re</span>
<span style="color: #f8f8f2;">print(</span> <span style="color: #f8f8f2;">re</span><span style="color: #f92672;">.</span><span style="color: #f8f8f2;">sub(</span><span style="color: #e6db74;">r'(foo)(bar)'</span><span style="color: #f8f8f2;">,</span><span style="color: #e6db74;">r'\g<2>\g<1>'</span><span style="color: #f8f8f2;">,</span><span style="color: #e6db74;">'foobar'</span><span style="color: #f8f8f2;">))</span>
</pre></div>
<br /><br />
More info here <a href="https://www.regular-expressions.info/replacebackref.html">https://www.regular-expressions.info/replacebackref.html</a>
</div>Christopher Wiggintonhttp://www.blogger.com/profile/02433309097120061094noreply@blogger.com0tag:blogger.com,1999:blog-2973693700394445577.post-37832321593384215042020-08-24T05:26:00.000-07:002020-08-24T05:26:07.953-07:00Python 3: solving 'utf-8' codec can't decode byte 0x92In Python 3, UTF-8 is the default encoding. In windows you may run into issues where characters will not decode such as 'utf-8' codec can't decode byte 0x92. Use a header with either cp1252 or windows-1252
<p> </p>
<!--HTML generated using hilite.me--><div style="background: rgb(32, 32, 32); border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;"><span style="color: #999999; font-style: italic;"># coding=CP1252</span>
<span style="color: #6ab825; font-weight: bold;">import</span> <span style="color: #447fcf; text-decoration: underline;">re</span>
<span style="color: #d0d0d0;">text</span> <span style="color: #d0d0d0;">=</span> <span style="color: #ed9d13;">"""</span>
<span style="color: #ed9d13;">LADY CAPULET</span>
<span style="color: #ed9d13;"> Alack the day. She’s dead, she’s dead, she’s dead!</span>
<span style="color: #ed9d13;">CAPULET</span>
<span style="color: #ed9d13;"> Ha! Let me see her. Out, alas! She’s cold.</span>
<span style="color: #ed9d13;"> Her blood is settled, and her joints are stiff.</span>
<span style="color: #ed9d13;"> Life and these lips have long been separated.</span>
<span style="color: #ed9d13;"> Death lies on her like an untimely frost</span>
<span style="color: #ed9d13;"> Upon the sweetest flower of all the field.</span>
<span style="color: #ed9d13;">Nurse</span>
<span style="color: #ed9d13;"> O lamentable day!</span>
<span style="color: #ed9d13;">"""</span>
</pre></div>
Christopher Wiggintonhttp://www.blogger.com/profile/02433309097120061094noreply@blogger.com0tag:blogger.com,1999:blog-2973693700394445577.post-77131679168959455132020-08-06T11:32:00.001-07:002020-08-06T11:33:27.752-07:00Autosys: Changing output of autosys -j JOB_NAME into MarkdownWhen generating output using autosys -j command line, it produces an output using space delimited typical console output. The following command will output the result into a markdown table.<div><br /></div><div><br /></div>
<table><tbody><tr><td>
autorep -j YOUR_JOB_OR_BOX_NAME | sed -e 's/ \{2,\}/|/g'| sed -e 's/_\{2,\}/ /g' | sed 's/\(.*\)/|\1/g' | sed -e 's/\(Job Name\)/|\1/g' | sed -e 's/\(Last Start\)/|\1/g' | sed -e 's/\(Last End\)/|\1|/g'| sed -e 's/ST Run/ST||Run/g' | sed -e 's/Ntry Pri\/Xit/Ntry||Pri\/Xit||/g'| sed -e 's/\(.*\)\([0-9]\{8\}\/[0-9]*\)/\1|\2|/g'
</td></tr></tbody></table>
Christopher Wiggintonhttp://www.blogger.com/profile/02433309097120061094noreply@blogger.com0tag:blogger.com,1999:blog-2973693700394445577.post-57580040156744676292020-07-29T09:57:00.000-07:002020-07-29T16:18:12.309-07:00Python: Performing XSLT recursively on a directory of XML filesI've been using <a href="https://github.com/ajryan/RptToXml">https://github.com/ajryan/RptToXml</a> to extract out xml information from Crystal Reports. I then rip through the created xml files with xlst to provide detail information on how the reports are created. This little python 3.5+ script uses <a href="https://www.saxonica.com/download/download_page.xml">https://www.saxonica.com/download/download_page.xml</a> and will create html files from a directory tree containing xml files. <!-- HTML generated using hilite.me --><br />
<br />
TODO: Write an xxl file to convert Crystal Reports to Jasper Reports.<br />
<br />
<br />
<div style="background: #272822; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;">
<pre style="line-height: 125%; margin: 0;"><span style="color: #f92672;">import</span> <span style="color: #f8f8f2;">os</span>
<span style="color: #f92672;">import</span> <span style="color: #f8f8f2;">subprocess</span>
<span style="color: #f92672;">import</span> <span style="color: #f8f8f2;">glob</span>
<span style="color: #f92672;">from</span> <span style="color: #f8f8f2;">pathlib</span> <span style="color: #f92672;">import</span> <span style="color: #f8f8f2;">Path</span>
<span style="color: #f8f8f2;">root_dir</span> <span style="color: #f92672;">=</span> <span style="color: #e6db74;">r"C:\crystalxml"</span>
<span style="color: #f8f8f2;">xslFile</span> <span style="color: #f92672;">=</span> <span style="color: #e6db74;">r"C:\Saxon\pretty.xsl"</span>
<span style="color: #66d9ef;">for</span> <span style="color: #f8f8f2;">filename</span> <span style="color: #f92672;">in</span> <span style="color: #f8f8f2;">glob</span><span style="color: #f92672;">.</span><span style="color: #f8f8f2;">iglob(root_dir</span> <span style="color: #f92672;">+</span> <span style="color: #e6db74;">'/**/*.xml'</span><span style="color: #f8f8f2;">,</span> <span style="color: #f8f8f2;">recursive</span><span style="color: #f92672;">=</span><span style="color: #f8f8f2;">True):</span>
<span style="color: #f8f8f2;">my_parts</span> <span style="color: #f92672;">=</span> <span style="color: #f8f8f2;">filename</span><span style="color: #f92672;">.</span><span style="color: #f8f8f2;">split(</span><span style="color: #e6db74;">"</span><span style="color: #ae81ff;">\\</span><span style="color: #e6db74;">"</span><span style="color: #f8f8f2;">)</span>
<span style="color: #f8f8f2;">justname</span> <span style="color: #f92672;">=</span> <span style="color: #f8f8f2;">my_parts[</span><span style="color: #f92672;">-</span><span style="color: #ae81ff;">1</span><span style="color: #f8f8f2;">]</span><span style="color: #f92672;">.</span><span style="color: #f8f8f2;">split(</span><span style="color: #e6db74;">'.'</span><span style="color: #f8f8f2;">)[</span><span style="color: #ae81ff;">0</span><span style="color: #f8f8f2;">]</span>
<span style="color: #f8f8f2;">my_dir</span> <span style="color: #f92672;">=</span> <span style="color: #f8f8f2;">os</span><span style="color: #f92672;">.</span><span style="color: #f8f8f2;">path</span><span style="color: #f92672;">.</span><span style="color: #f8f8f2;">dirname(filename)</span>
<span style="color: #f8f8f2;">newname</span> <span style="color: #f92672;">=</span> <span style="color: #f8f8f2;">fr</span><span style="color: #e6db74;">'{my_dir}\{justname}.html'</span>
<span style="color: #f8f8f2;">cmd</span> <span style="color: #f92672;">=</span> <span style="color: #f8f8f2;">fr</span><span style="color: #e6db74;">'java -cp C:\Saxon\saxon-he-10.1.jar net.sf.saxon.Transform -t -s:"{filename}" -xsl:{xslFile} -o:"{newname}"'</span>
<span style="color: #f8f8f2;">subprocess</span><span style="color: #f92672;">.</span><span style="color: #f8f8f2;">call(cmd)</span>
</pre>
</div>
Christopher Wiggintonhttp://www.blogger.com/profile/02433309097120061094noreply@blogger.com0tag:blogger.com,1999:blog-2973693700394445577.post-14303702235488564472020-05-12T20:35:00.000-07:002020-05-13T05:42:31.391-07:00Python: Learning by starting with the basics.Just a simple mind exercise in learning a language. Created a console Hangman game that uses a word api with a hint command that fills in the first available blank.<br />
<br />
<a href="https://github.com/wiggick/misc_python/blob/master/fun_n_games/hangman.py" target="_blank">hangman.py</a><br />
<br />
<pre>Guess a Letter:hint
------
| |
| 0
| /|\
| /
t y p h u _ e _
Wrong Guesses:lmaio
Guess a Letter:s
------
| |
| 0
| /|\
| /
t y p h u s e s
Wrong Guesses:lmaio
stay of execution
</pre>
Christopher Wiggintonhttp://www.blogger.com/profile/02433309097120061094noreply@blogger.com0tag:blogger.com,1999:blog-2973693700394445577.post-77293774304683690172020-05-08T16:00:00.000-07:002020-05-08T16:04:44.161-07:00Oracle: Capitalizing and removing underscores from a column nameOracle table names are all caps with underscores. So if you're consuming them from something like all_tab_columns, this quick little function makes them a little prettier.
<!-- HTML generated using hilite.me --><br />
<br />
<div style="background: #ffffff; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;">
<pre style="line-height: 125%; margin: 0;"><span style="color: #008800; font-weight: bold;">select</span> initcap(<span style="color: #008800; font-weight: bold;">replace</span>(<span style="color: #008800; font-weight: bold;">lower</span>(<span style="background-color: #fff0f0;">'SOME_COLUMN_NAME'</span>),<span style="background-color: #fff0f0;">'_'</span>,<span style="background-color: #fff0f0;">' '</span>)) <span style="color: #008800; font-weight: bold;">from</span> dual;
</pre>
</div>
Christopher Wiggintonhttp://www.blogger.com/profile/02433309097120061094noreply@blogger.com0tag:blogger.com,1999:blog-2973693700394445577.post-36441086619799203062020-05-06T16:10:00.000-07:002020-05-08T16:11:21.436-07:00VBA: A little function to Capitalize and Split a StringHere's a subroutine for converting a range of strings into a space separated Capitalization (i.e.) "FOO_BAR" becomes "Foo Bar"<br />
<br />
<!-- HTML generated using hilite.me --><br />
<div style="background: #ffffff; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;">
<pre style="line-height: 125%; margin: 0;"><span style="color: #008800; font-weight: bold;">Sub</span> <span style="color: #0066bb; font-weight: bold;">Capitalization_Split</span>()
<span style="color: #888888;">'Declaring variables</span>
<span style="color: #008800; font-weight: bold;">Dim</span> Cell <span style="color: black; font-weight: bold;">As</span> Range
<span style="color: #008800; font-weight: bold;">Dim</span> Source <span style="color: black; font-weight: bold;">As</span> Range
<span style="color: #008800; font-weight: bold;">Dim</span> Capitalized <span style="color: black; font-weight: bold;">As</span> <span style="color: #333399; font-weight: bold;">String</span>
<span style="color: #008800; font-weight: bold;">Dim</span> Humps <span style="color: black; font-weight: bold;">As</span> <span style="color: #333399; font-weight: bold;">Variant</span>
<span style="color: #008800; font-weight: bold;">Dim</span> Hump <span style="color: black; font-weight: bold;">As</span> <span style="color: #333399; font-weight: bold;">String</span>
<span style="color: #008800; font-weight: bold;">Dim</span> i <span style="color: black; font-weight: bold;">As</span> <span style="color: #333399; font-weight: bold;">Long</span>
<span style="color: #888888;">'Initializing source range</span>
<span style="color: #008800; font-weight: bold;">Set</span> Source <span style="color: #333333;">=</span> Application.Selection
<span style="color: #888888;">'Looping through each cell in the source range</span>
<span style="color: #008800; font-weight: bold;">For</span> <span style="color: #008800; font-weight: bold;">Each</span> Cell <span style="color: black; font-weight: bold;">In</span> Source
Capitalized <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">""</span>
Hump <span style="color: #333333;">=</span> Cell.Value
Humps <span style="color: #333333;">=</span> Split(Hump, <span style="background-color: #fff0f0;">"_"</span>)
<span style="color: #008800; font-weight: bold;">For</span> i <span style="color: #333333;">=</span> LBound(Humps, <span style="color: #0000dd; font-weight: bold;">1</span>) <span style="color: #008800; font-weight: bold;">To</span> UBound(Humps, <span style="color: #0000dd; font-weight: bold;">1</span>)
Hump <span style="color: #333333;">=</span> UCase(Left(Humps(i), <span style="color: #0000dd; font-weight: bold;">1</span>)) <span style="color: #333333;">&</span> LCase(Right(Humps(i), Len(Humps(i)) <span style="color: #333333;">-</span> <span style="color: #0000dd; font-weight: bold;">1</span>))
Capitalized <span style="color: #333333;">=</span> Capitalized <span style="color: #333333;">&</span> Hump <span style="color: #333333;">&</span> <span style="background-color: #fff0f0;">" "</span>
<span style="color: #008800; font-weight: bold;">Next</span>
Cell.Value <span style="color: #333333;">=</span> Capitalized
<span style="color: #008800; font-weight: bold;">Next</span>
<span style="color: #008800; font-weight: bold;">End</span> <span style="color: #008800; font-weight: bold;">Sub</span>
</pre>
</div>
Christopher Wiggintonhttp://www.blogger.com/profile/02433309097120061094noreply@blogger.com0tag:blogger.com,1999:blog-2973693700394445577.post-2068350486324094642020-05-05T19:06:00.000-07:002020-05-05T19:16:25.791-07:00GoLang: Issues Installing Delv Analysis ToolI've recently just started setting up my development environment to play around with GO. My editor of choice is Eclipse as it 1) suits my development efforts, 2) It's pretty much free, though I did opt to pay for <a href="https://www.genuitec.com/products/codemix/" target="_blank">CodeMix </a>which has a very reasonable price of $29 per year as opposed to the competition.<br />
<br />
I mostly use windows and the initial setup went fairly well except I was getting an error that all the analysis tools were not there. I was able to "Go Get" some of the ones that were missing, but dlv just wouldn't install in that manner. So I ended up checking out the <a href="https://github.com/go-delve/">https://github.com/go-delve/</a> repo, performing a go build and then manually copying over repo to my $GOPATH/pkg/mod/github.com/ folder, put the compiled dlv.exe into the $GOPATH/bin folder and then launched Eclipse. No more warnings of analytic tools being missing.<br />
<br />
No off to do something other than the obligatory "Hello World".Christopher Wiggintonhttp://www.blogger.com/profile/02433309097120061094noreply@blogger.com0tag:blogger.com,1999:blog-2973693700394445577.post-79546801142862872482020-03-05T07:40:00.000-08:002020-03-05T07:42:20.227-08:00Why Lucee is Better Than ColdFusion #1Lucee's Query of Queries is better than Adobe. Try this little snippet on Lucee 5 and then CF2018 or earlier<br />
<br />
<!-- HTML generated using hilite.me --><br />
<div style="background: #ffffff; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;">
<pre style="line-height: 125%; margin: 0;"><span style="color: #007020;"><cfscript></span>
<span style="color: #996633;">myQuery</span><span style="color: #333333;">=</span><span style="color: #0066bb; font-weight: bold;">QueryNew</span>(<span style="background-color: #fff0f0;">"Country,Capital City,Amount##"</span>,<span style="background-color: #fff0f0;">"varchar,varchar,numeric"</span>);
<span style="color: #333333;">/*</span><span style="color: #996633;">Add</span> <span style="color: #996633;">array</span> <span style="color: #996633;">values</span> <span style="color: #996633;">in</span> <span style="color: #996633;">column</span><span style="color: #333333;">*/</span>
<span style="color: #996633;">myAreaValues</span><span style="color: #333333;">=</span><span style="color: #0066bb; font-weight: bold;">ArrayNew</span>(<span style="color: #6600ee; font-weight: bold;">1</span>);
<span style="color: #996633;">myAreaValues</span>[<span style="color: #6600ee; font-weight: bold;">1</span>]<span style="color: #333333;">=</span><span style="color: #6600ee; font-weight: bold;">100000</span>;
<span style="color: #996633;">myAreaValues</span>[<span style="color: #6600ee; font-weight: bold;">2</span>]<span style="color: #333333;">=</span><span style="color: #6600ee; font-weight: bold;">50000</span>;
<span style="color: #0066bb; font-weight: bold;">myQuery.addColumn</span>(<span style="background-color: #fff0f0;">"Area"</span>,<span style="background-color: #fff0f0;">"integer"</span>,<span style="color: #996633;">myAreaValues</span>);
<span style="color: #0066bb; font-weight: bold;">WriteDump</span>(<span style="color: #996633;">myQuery</span>);
<span style="color: #007020;"></cfscript><div class="separator" style="clear: both; text-align: center;">
</div>
</span>
</pre>
</div>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhhXyhW561xzxX13rrM7zlM8bqwDPc7WSozjcy7t4usc9x5_bDcFvhwmX42W9Gf7lkhJpNdAtCjKcBV5gXjOwXkTm-3SOWWXB2igHfUVjHlnVXag5WCR2H6uxDgVGxDSXp9xFcJ-h5oZ2j9/s1600/lucee1.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="144" data-original-width="260" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhhXyhW561xzxX13rrM7zlM8bqwDPc7WSozjcy7t4usc9x5_bDcFvhwmX42W9Gf7lkhJpNdAtCjKcBV5gXjOwXkTm-3SOWWXB2igHfUVjHlnVXag5WCR2H6uxDgVGxDSXp9xFcJ-h5oZ2j9/s1600/lucee1.PNG" /></a>
Christopher Wiggintonhttp://www.blogger.com/profile/02433309097120061094noreply@blogger.com0tag:blogger.com,1999:blog-2973693700394445577.post-51960777104217594872020-02-09T14:29:00.000-08:002020-02-09T14:29:50.207-08:00XSLT with carriage returns and line breaksI needed to translate carriage returns and line feeds to <BR/> elements in an XSLT process. Sometimes you get hung up how you normally use functions and then hit a language wall that you think should work,<br />
<br />
In this case, the solution was to iterate over the selection and output the elements with an appended tag.<br />
<br />
<div style="background: #ffffff; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;">
<pre style="line-height: 125%; margin: 0;"><span style="color: #007700;"><tr><td></span><span style="color: #008800; font-weight: bold;"><xsl:for-each</span> <span style="color: #0000cc;">select=</span><span style="background-color: #fff0f0;">"tokenize(customerinfo/@comments, '&#xD;&#xA;')"</span><span style="color: #007700;">></span>
<span style="color: #008800; font-weight: bold;"><xsl:value-of</span> <span style="color: #0000cc;">select=</span><span style="background-color: #fff0f0;">"."</span> <span style="color: #007700;">/><br/></span>
<span style="color: #008800; font-weight: bold;"></xsl:for-each></span><span style="color: #007700;"></td></tr></span>
</pre>
</div>
Christopher Wiggintonhttp://www.blogger.com/profile/02433309097120061094noreply@blogger.com0tag:blogger.com,1999:blog-2973693700394445577.post-74375949788648428712019-08-15T17:44:00.000-07:002019-08-15T17:44:17.465-07:00ColdFusion: Pretty Printing JSON with Google's gsonHere's a simple example on how to pretty print JSON with ColdFusion.<br />
<br />
Install or load Google's gson.jar file by building it from the git repo <a href="https://github.com/google/gson">https://github.com/google/gson</a> or download the latest <a href="https://maven-badges.herokuapp.com/maven-central/com.google.code.gson/gson" target="_blank">jar </a><!-- HTML generated using hilite.me --><br />
<br />
<!-- HTML generated using hilite.me --><br />
<!-- HTML generated using hilite.me --><br />
<div style="background: #272822; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;">
<pre style="line-height: 125%; margin: 0;"><span style="color: #f8f8f2;"><cfscript></span>
<span style="color: #f8f8f2;">variables.myJSON</span> <span style="color: #f92672;">=</span> <span style="color: #f8f8f2;">{</span><span style="color: #e6db74;">"ugly"</span><span style="color: #f8f8f2;">:</span><span style="color: #e6db74;">"put in some ugly/compressed json here"</span><span style="color: #f8f8f2;">};</span>
<span style="color: #f8f8f2;">variables.objJSON</span> <span style="color: #f92672;">=</span> <span style="color: #a6e22e;">CreateObject</span><span style="color: #f8f8f2;">(</span><span style="color: #e6db74;">"java"</span><span style="color: #f8f8f2;">,</span><span style="color: #e6db74;">"com.google.gson.GsonBuilder"</span><span style="color: #f8f8f2;">).</span><span style="color: #a6e22e;">setPrettyPrinting</span><span style="color: #f8f8f2;">().</span><span style="color: #a6e22e;">create</span><span style="color: #f8f8f2;">();</span>
<span style="color: #f8f8f2;">variables.objParser</span><span style="color: #f92672;">=</span> <span style="color: #a6e22e;">CreateObject</span><span style="color: #f8f8f2;">(</span><span style="color: #e6db74;">"java"</span><span style="color: #f8f8f2;">,</span><span style="color: #e6db74;">"com.google.gson.JsonParser"</span><span style="color: #f8f8f2;">);</span>
<span style="color: #f8f8f2;">variables.jsonElement</span> <span style="color: #f92672;">=</span> <span style="color: #a6e22e;">variables.objParser.parse</span><span style="color: #f8f8f2;">(variables.myJSON);</span>
<span style="color: #f8f8f2;">variables.result</span> <span style="color: #f92672;">=</span> <span style="color: #a6e22e;">variables.objJSON.toJson</span><span style="color: #f8f8f2;">(variables.jsonElement);</span>
<span style="color: #a6e22e;">WriteOutput</span><span style="color: #f8f8f2;">(</span><span style="color: #e6db74;">"<textarea cols='80' rows='20'>#variables.result#</textarea>"</span><span style="color: #f8f8f2;">);</span>
<span style="color: #f8f8f2;"></cfscript></span>
</pre>
</div>
Christopher Wiggintonhttp://www.blogger.com/profile/02433309097120061094noreply@blogger.com0