tag:blogger.com,1999:blog-13640054381576978082024-03-11T01:36:37.291-07:00Less is MoreJess's Software Development BlogJesshttp://www.blogger.com/profile/05332870856354994724noreply@blogger.comBlogger127125tag:blogger.com,1999:blog-1364005438157697808.post-47858175918989213022019-11-27T11:12:00.001-08:002019-12-02T09:13:46.600-08:00Live 360 TakeawaysI attended the Live 360 conference last week. Here are my <span style="background-color: #fff2cc;">main takeaways</span>.<br />
<br />
<h2>
A Tour of Visual Studio</h2>
<div>
Some of this I knew already. Many of the less important keyboard shortcuts are omitted.</div>
<div>
<ol>
<li><span style="background-color: #fff2cc;">ReSharper</span>. There is a ton of stuff that Visual Studio does now for refactoring. Long story short however, R# still does more. I'm really productive with it. No reason to throw it out just yet.</li>
<ol>
<li>I use Resharper key bindings, so some of the shortcut keys he used are different for me!</li>
<li>You can assign key bindings.</li>
</ol>
<li>Press <b>Esc</b> to get rid of the Splash Screen.</li>
<li><span style="background-color: #fff2cc;"><b>CTRL-Q</b>. </span></li>
<ol>
<li>Search for features. (Try "bookmark")</li>
<li>Better yet, it shows the keyboard shortcuts.</li>
<li>No more hunting for windows.</li>
</ol>
<li>Workflow tip. Try unpinning docked windows to see more code!</li>
<li>There are a myriad of ways to customize VS:</li>
<ol>
<li>Settings roam with you via a login.</li>
<li>Can export settings.</li>
</ol>
<li>You can have multiple start up projects: <b>Solution > Properties</b></li>
<li><b>SHIT-F10 </b>is context click.</li>
<li><b>Live Share</b> exists. So does Teams.</li>
<li><b>CTRL-SHIFT-V</b> = Clipboard ring.</li>
<li><b>Intellicode </b>uses machine learning to put a star next to things you may want to do in IntelliSense.</li>
<li>I have Many, Many other shortcuts written down if you want a list.</li>
<li>You can create your own Refactorings. (A lot of work. Easy to get slightly wrong)</li>
<li>Testing - run tests in parallel, sort by duration. <a href="https://github.com/tonerdo/coverlet">Coverlet</a>?</li>
<li>Other stuff. Some of it is Enterprise only:</li>
<ol>
<li>Performance Analyzer</li>
<li>Debug -> profiler</li>
<li>Analyzers</li>
<li>Extensions</li>
</ol>
</ol>
<h2>
Programming Smart Contracts in C#</h2>
</div>
<div>
This was about block-chain. It was complicated and it blew my mind. This seemed like a product marketing for Neo. I don't see a space for using block-chain storage. </div>
<div>
(thought: <a href="https://insights.stackoverflow.com/survey/2019#technology-_-most-popular-development-environments">Visual Studio Code</a> usage is soaring, Visual Studio is lagging)</div>
<div>
<h2>
What's New in .NET Core 3.0</h2>
</div>
<div>
<ol>
<li>Winforms and WPF runs on it! (Only on Windows. The design tools are not ported yet)</li>
<li><span style="background-color: #fff2cc;">New <a href="https://docs.microsoft.com/en-us/dotnet/core/whats-new/dotnet-core-3-0#single-file-executables">single file EXE deployment</a></span>. LARGE file. Takes a while to run first time, but is snappy after that.</li>
<li>gRPC project template.</li>
<li><span style="background-color: #fff2cc;">C# 8.0 has </span><b><span style="background-color: #fff2cc;"><a href="https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/proposals/csharp-8.0/async-streams#foreach">await foreach</a>!</span> </b>This is actually helpful. I have been doing Select and then await Task.WhenAll(tasks).</li>
<li>Has Blazor Server Side and Blazor WebAssembly. They are 2 different things!</li>
<ol>
<li>The latter is the real deal and is releasing May 2020.</li>
<li>Requires javascript interops right now (wrappers).</li>
<li>Everything is a component.</li>
</ol>
<li>.NET Core 3.1 is getting LTS Long Term Support.</li>
<li>Soon they will drop the name "Core" which I think will be super confusing. Oh well!</li>
<li>There are very few reasons to use .NET Framework anymore.</li>
</ol>
<div>
<h2>
Dev Ops</h2>
<div>
They were pushing Azure pretty hard.</div>
<div>
Azure DevOp Services DOES IT ALL. vs. Atlassian?</div>
<h2>
Blazing the Web</h2>
<div>
<ul>
<li>Blazor WebAssembly (Client side)</li>
<li>Requires .NET Core 3.1 Preview</li>
<li>Type limitations: int, int64, float, float64.</li>
<li><span style="background-color: #fff2cc;">No DOM, no threads, requires JS interop (wrapper), No native JS operations - Geo Location as an example.</span></li>
</ul>
</div>
<h2>
Graph API</h2>
<div>
I keep hearing about this, but have had no interaction with it yet.<br />
One API to rule them all. </div>
<div>
Can use Microsoft.Identity.Client package to get a token (MSAL). You can also do it manually if you want.<br />
Uses bearer token.<br />
Make request for permission via scopes.<br />
There are many authentication flows.<br />
Use <a href="https://developer.microsoft.com/en-us/graph/graph-explorer">Graph Explorer</a>. Like Postman. You can get C# snippets if you <span style="background-color: #fff2cc;">use <a href="https://developer.microsoft.com/en-us/graph/graph-explorer/preview">the preview version</a></span>!<br />
Use Microsoft.graph package to get Fluid API.<br />
<h2>
Power Automate</h2>
<div>
Formerly "Flow". Formerly Logic Apps?<br />
Drag and drop programming.<br />
A lot of canned actions.<br />
Can also call APIs.<br />
<span style="background-color: #fff2cc;"><a href="https://docs.microsoft.com/en-us/power-automate/modern-approvals">Example</a>.</span><br />
<h2>
Typescript - Advanced</h2>
<div>
<ol>
<li>Transpiled to JS</li>
<li>All JS is valid TS, but that does not mean you should!</li>
<li>You can do a lot of crazy things with classes and interfaces: Unions, Merges, etc.</li>
<li>Language concepts are rapidly being added: For ... of, for ... in, Map, Set, Generators</li>
<li>Most of this stuff was "too" advanced.</li>
</ol>
<h2>
Identity Server</h2>
<div>
<ol>
<li>Poor guy struggled with the projector for a while - I aborted.</li>
<ol>
<li>Simple [Authorize]</li>
<li>Role [Authorize(Role="Role")]</li>
<li>Claims</li>
<li>Policy - complex logic</li>
</ol>
<li>There are tons of <a href="https://www.talkingdotnet.com/how-to-scaffold-identity-ui-in-asp-net-core-2-1/" style="background-color: #fff2cc;">Scaffolding options</a>. Scaffold, then customize. </li>
</ol>
<div>
<h2>
Dev && UX</h2>
<div>
<ol>
<li>Happy, Ease, Intuitive, Accessibility</li>
<li>Frustration, confusion, disappointment, distraction = UX Debt</li>
<li>UX != Style, Graphic design</li>
<li>Function > Style</li>
<li>Tree test. This was a cool tool she used to have us find a topic in the navigation and analyze the results. I can't find the link to it.</li>
<li>A lot of companies say customer satisfaction is their top priority, but they do not measure it!</li>
</ol>
<h2>
Web Performance</h2>
</div>
</div>
</div>
</div>
<div>
Amazon and Walmart did an experiment with performance. They purposely slowed their pages by 100ms. There was a loss of 1% in sales. If you need to improve performance in an app, <span style="background-color: #fff2cc;">translate the ROI into dollars</span>. Make sure your marketing department understands the benefits and work with them.<br />
<ol>
<li>Http</li>
<ol>
<li>For HTTP 1.1, make fewer requests. (4 connections max)</li>
<li>For <a href="https://en.wikipedia.org/wiki/HTTP/2">HTTP 2.0</a>, this is an anti-pattern. (Multiplexing 1 TCP connection)</li>
</ol>
<li>Send as little as possible</li>
<li>Use Fiddler</li>
<li>Metrics: </li>
<ol>
<li>First Byte (server response time)</li>
<li>Speed Index</li>
<li>Time to Interactive</li>
<li>Onload</li>
<li>Fully loaded</li>
</ol>
<li>Real User Monitoring (RUM) - capturing all user interactions. W3C Navigation Timing. W3C Resource Timing.</li>
<li>Steps:</li>
<ol>
<li>Header Compression = 50% less bandwidth.</li>
<li>IIS Compression - CS, JS, HTML, not images</li>
<li>Content Expiration (cache). Rename, hash or build custom code to bust cache.</li>
<li>CDN. Bandwidth vs. Latency (distance). Latency is king. Use your own CDN and give fallbacks.</li>
<li>Bundling and Minification. In HTTP 2.0 we don't need to bundle anymore and don't minify your html.</li>
<li>Images. Avoid them! USe CSS3 if you can. Use SVG if you can.</li>
<ol>
<li>Use JPEG for photos</li>
<li>Use PNG for all else</li>
<li>Use srcset, <picture> not <img></li>
<li>Use Client Hints (new)</li>
</ol>
<li>Use Progressive JPEG - lower res renders first.</li>
<li>Lazy load images below the fold.</li>
<li>Deffered loading. (Like for ads)</li>
<li>Async JS. Use Async keyword. Use deffered if order matters.</li>
<li>Resource hints. </li>
<ol>
<li>"Preconnect" gets the HTTP request read ahead of time.</li>
<li>Prerender</li>
</ol>
<li>Image names are case sensitive. Use consistent naming make sure you are using the cache.</li>
<li>JS at the top now.</li>
</ol>
<li><a href="https://webpagetest.org/result/191202_CC_1d0fbbf64e74f33440b5b1729ac45486/" style="background-color: #fff2cc;">Webpagetest.org</a> => Speed index. Visible page above the fold.</li>
<li>Google Test My Site. (See PDF in my email)</li>
</ol>
</div>
<h2>
Next Breakthrough Dev Platform</h2>
<div>
Low-code development. App development is expensive!</div>
<div>
Targeting multiple execution environments.</div>
<div>
<ol>
<li>Flutter, Uno, Kony, Power Apps, Zoho, Blazor </li>
</ol>
<div>
<h2>
UX in a Day</h2>
<div>
<a href="http://billyhollis.com/Downloads/AppUXInADayPart1.pdf">Slide deck</a></div>
</div>
</div>
</div>
</div>
</div>
</div>
<div>
<h2>
<span style="font-size: 24px; font-weight: 700;">Random Thoughts</span></h2>
</div>
<div>
Stuff that came up in conversations</div>
<div>
<ol>
<li>CSLA</li>
<li>gRPC</li>
<li>T4</li>
<li>Flow is now Power Automate</li>
<li>I talked to a dude who may a web form, mobile app, etc. in a month with Power Automate. Very powerful for less complicated workflows/apps.</li>
<li>I want to learn more about Jasmine and Selenium for client side testing.</li>
</ol>
</div>
<div>
<br /></div>
Jesshttp://www.blogger.com/profile/05332870856354994724noreply@blogger.com0tag:blogger.com,1999:blog-1364005438157697808.post-21696119578197901392018-12-04T04:59:00.003-08:002018-12-04T05:01:47.546-08:00Solve a Rubik’s Cube in Text Format<br />
<span style="mso-fareast-font-family: "Times New Roman";">This is mostly a cheat sheet for myself, but if it helps you out too then great!</span><br />
<h2>
<span style="mso-fareast-font-family: "Times New Roman";">White cross </span></h2>
<div class="MsoNormal">
<span style="mso-fareast-font-family: "Times New Roman";">Easy,
but Make sure green, blue, red, and orange middles line up. <o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<h2>
<span style="mso-fareast-font-family: "Times New Roman";">White corners</span></h2>
<div class="MsoNormal">
<span style="mso-fareast-font-family: "Times New Roman";">Should
be easy to do with some RDR’D’ action. <o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<h2>
<span style="mso-fareast-font-family: "Times New Roman";">Colored edges</span></h2>
<div class="MsoNormal">
<span style="mso-fareast-font-family: "Times New Roman";">Drop
top edge down and right (or left)<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="color: purple; mso-fareast-font-family: "Times New Roman";"><b>U R
Ui Ri Ui Fi U Fi<o:p></o:p></b></span></div>
<div class="MsoNormal">
<span style="mso-fareast-font-family: "Times New Roman";"><span style="color: purple;"><b>Ui
Li U L U F Ui Fi</b></span><o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<h2>
<span style="mso-fareast-font-family: "Times New Roman";">Top yellow cross </span></h2>
<div class="MsoNormal">
<span style="mso-fareast-font-family: "Times New Roman";">with
top orientation <o:p></o:p></span></div>
<div class="MsoNormal">
<span style="mso-fareast-font-family: "Times New Roman";"><span style="font-family: "courier new" , "courier" , monospace;">XYX XXX<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span style="mso-fareast-font-family: "Times New Roman";"><span style="font-family: "courier new" , "courier" , monospace;">YYX
OR YYY<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span style="mso-fareast-font-family: "Times New Roman";"><span style="font-family: "courier new" , "courier" , monospace;">XXX XXX</span><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="mso-fareast-font-family: "Times New Roman";"><span style="color: purple;"><b>F R
U R' U' F'</b></span><o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<h2>
<span style="mso-fareast-font-family: "Times New Roman";">Top yellow edges (middles)</span></h2>
</div>
<div class="MsoNormal">
<span style="mso-fareast-font-family: "Times New Roman";">Rotate
top 3 edges: </span>Front, left, and back.</div>
<div class="MsoNormal">
<span style="mso-fareast-font-family: "Times New Roman";"><span style="color: purple;"><b>R U
R' U R U U R’ U</b></span><o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<h2>
<span style="mso-fareast-font-family: "Times New Roman";"><o:p>Top yellow corners</o:p></span></h2>
<div class="MsoNormal">
<span style="mso-fareast-font-family: "Times New Roman";">Rotate
top 3 corners (FL, BL, BR?)<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="mso-fareast-font-family: "Times New Roman";"><span style="color: purple;"><b>U R
U’ L’ U R’ U’ L</b></span><o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<h2>
<span style="mso-fareast-font-family: "Times New Roman";">Final
corner (FR)</span></h2>
<div>
with top orientation:</div>
<div>
<div class="MsoNormal">
<span style="font-family: "courier new" , "courier" , monospace;">?Y?<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "courier new" , "courier" , monospace;">YYY<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "courier new" , "courier" , monospace;">YYX</span><o:p></o:p></div>
</div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span></div>
<div class="MsoNormal">
<span style="mso-fareast-font-family: "Times New Roman";"><span style="color: purple;"><b>R '
D' R D</b></span><o:p></o:p></span></div>
once the corner you are working on (FR) is correct, do a U turn until you have this orientation:<br />
<div>
<div>
<div class="MsoNormal">
<span style="font-family: "courier new" , "courier" , monospace;">?Y?<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "courier new" , "courier" , monospace;">YYY<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "courier new" , "courier" , monospace;">YYX</span><o:p></o:p></div>
</div>
</div>
<div>
<br /></div>
<div>
<span style="font-family: inherit;">Now repeat R'D'RD</span></div>
Jesshttp://www.blogger.com/profile/05332870856354994724noreply@blogger.com0tag:blogger.com,1999:blog-1364005438157697808.post-35269560817492007862018-09-25T18:40:00.001-07:002018-09-25T18:40:19.071-07:00Unity Android BuildHi!<br />
<br />
So after like 3 hours of having fun with this, I’m documenting what I did - so I don’t forget.<br />
<br />
First, DONT use the Unity documentation for this.<br />
<br />
<a href="https://unity3d.com/learn/tutorials/topics/mobile-touch/building-your-unity-game-android-device-testing">https://unity3d.com/learn/tutorials/topics/mobile-touch/building-your-unity-game-android-device-testing</a><br />
<br />
It is for Unity 5.3, is super old and out of date.<br />
<br />
Open the build settings<br />
Set the build output to Android<br />
Open Project Settings. If you have the inspector locked nothing will happen...<br />
Dig thru to find the package name.<br />
Change it from com.CompanyName.Project to something meaningful<br />
You may want to set up other things while you are in here like app icon<br />
Run a build<br />
Unity will ask you to save the apk file in a location.<br />
Then it will ask you for JDK 1.8.<br />
If you don’t have it, Unity will download it for you.<br />
Sometimes it looks like Unity is doing nothing at this point. There is no progress bar. Be patient.<br />
Next Unity will ask for Android SDK. Again, Unity will just download it for you.<br />
Cool! Now you should have an apk file!<br />
<br />
Get the APK file on a phone.<br />
There is actually a pretty good SO Answer on how to do this. I edited the answer to make it easier.<br />
<br />
<a href="https://stackoverflow.com/questions/9718104/how-to-install-apk-from-pc">https://stackoverflow.com/questions/9718104/how-to-install-apk-from-pc</a><br />
<br />
So that should do it.<br />
<br />
<br />Jesshttp://www.blogger.com/profile/05332870856354994724noreply@blogger.com0tag:blogger.com,1999:blog-1364005438157697808.post-9864912785455289512017-12-24T05:54:00.000-08:002017-12-24T05:56:23.824-08:00TEEJ Christmas<span style="font-family: "courier new" , "courier" , monospace;">Hi Teej!</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">I made a Christmas video game for you! It's <b><i>insane</i></b>.</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">Some things you should know before you play.</span><br />
<br />
<ol>
<li><span style="font-family: "courier new" , "courier" , monospace;">You might get a message that says, <b style="font-weight: bold;">"Please note that Unity WebGL is not currently supported on mobiles. Press OK if you wish to continue anyway."</b><span style="font-weight: 400;"> Just click </span><b style="font-weight: bold;">OK!</b></span></li>
<li><span style="font-family: "courier new" , "courier" , monospace;">The file size is big. It may take a little while to download.</span></li>
<li><span style="font-family: "courier new" , "courier" , monospace;">To play the game, click or touch a location and you will move there.</span></li>
<li><span style="font-family: "courier new" , "courier" , monospace;">Push the bad guys off the screen!</span></li>
<li><span style="font-family: "courier new" , "courier" , monospace;">Don't go off the screen yourself or you will die!</span></li>
<li><span style="font-family: "courier new" , "courier" , monospace;">There is no score! Sorry. For some reason I could not get that to work,</span></li>
</ol>
<div>
<span style="font-family: "courier new" , "courier" , monospace;">I think that's it! Enjoy the game.</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-large;"><a href="http://www.sparkyland.com/teejchristmas/index.html">Click here to play TEEJ Christmas</a></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">Ho ho ho</span></div>
Jesshttp://www.blogger.com/profile/05332870856354994724noreply@blogger.com0tag:blogger.com,1999:blog-1364005438157697808.post-71074424882697403032017-10-17T05:46:00.003-07:002017-11-06T06:35:19.187-08:00Enviro Empress IgniterOur Enviro Empress is a great stove, but it has stopped lighting! I looked at the manual and found some tips online for how to troubleshoot it. You can give it 120V power (somehow?) and also test to see if fuses are burned out or if the igniter is getting enough power using a voltage detector.<br />
<br />
What I did is just remove the igniter. It was not easy to get in there, but I used a socket wrench with a T20 "star" drill bit to remove the screws. I also created a home-made tool to finish backing out the screws because the socket wrench barely fit.<br />
<br />
I placed the igniter on the hearth in <b>very fireproof place</b>, plugged the stove back in and turned it on. In 2 minutes I had a red hot igniter, but it was not hot all the way to the end, as you can see in the pictures.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgkhOv1pGUZgspVtGF7mXTnj8qKWgcbpMXRhdRcFrkrOQchJkLAPUg1nMVqtiEozjQRjqhr9gbK6j8kGyFhyphenhyphenAIO292gTMyGuxV3wGjpRQLhYMqa2f0WJJpKizZya7b1hevJtnIUmZvLYns/s1600/IMG_7023.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="640" data-original-width="480" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgkhOv1pGUZgspVtGF7mXTnj8qKWgcbpMXRhdRcFrkrOQchJkLAPUg1nMVqtiEozjQRjqhr9gbK6j8kGyFhyphenhyphenAIO292gTMyGuxV3wGjpRQLhYMqa2f0WJJpKizZya7b1hevJtnIUmZvLYns/s320/IMG_7023.JPG" width="240" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjT6T_TtmScEoBIDTY7m_tL4et2jnG553Vn9jSNETPwU5R7DV5o-QTy3Z39VErAgVSh7peNdsbN83nHq1OUsGd-NUE5VslX9FzpMLSKHmx4xaO36GK4IGMkP0Aiv1AGZHLRz2gmF1zGb_c/s1600/IMG_7024.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="640" data-original-width="480" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjT6T_TtmScEoBIDTY7m_tL4et2jnG553Vn9jSNETPwU5R7DV5o-QTy3Z39VErAgVSh7peNdsbN83nHq1OUsGd-NUE5VslX9FzpMLSKHmx4xaO36GK4IGMkP0Aiv1AGZHLRz2gmF1zGb_c/s320/IMG_7024.JPG" width="240" /></a></div>
<br />
<br />
So I ordered a new one from Amazon. Hopefully that will do the trick!<br />
<br />
I have received the new igniter! It is so much cleaner than the old one (which was actually slightly bent). the crazy thing about the new igniter is that the holes in the mounting plate are smaller than the provided screws and the screws I already had from the old igniter. What the heck!? Anyway, I was able to use a metal screw bit to enlarge the holes and install the igniter.<br />
<br />
The new igniter is working great! The stove fires right up.Jesshttp://www.blogger.com/profile/05332870856354994724noreply@blogger.com0tag:blogger.com,1999:blog-1364005438157697808.post-77539131832471982112017-09-13T18:59:00.002-07:002017-10-20T08:48:17.752-07:00Colonization Rampage 2OK. This old game is still wicked fun.<br />
<br />
I downloaded the new Colonization game on the iPhone. It was playable, but the controls were really bad and it was not very fun.<br />
<br />
I downloaded the game again from GOG. I decided to try another game with a challenge. <br />
<br />
<a href="http://jesslilly.com/other/vids/colonize.html">Here are my old challenges</a>. Never going back to Europe was my favorite.<br />
<br />
<h2>
Save the Natives</h2>
<br />
Anyway, I wanted to play a game where I tried to prevent <b>all</b> native villages from being destroyed.<br />
<br />
I started one game as the Spanish near the Tupi tribe. My rationale was to be the Spanish to prevent their Indian village attack bonus from being used. That did not work so well and the Tupi were not very good to trade with (being nomadic).<br />
<br />
I started this other game as the French and went to war with the Spanish (and other Europeans) early and often. Some things that have happened that were fun and/or helped:<br />
<br />
<br />
<ol>
<li>I got Hernando de Soto first! That was lucky. All my exploration is always positive. But I never dug any burial mounds.</li>
<li>I got Hernan Cortez second. I was able to do a lot of exploration and have the king's galleons transport my treasure for free.</li>
<li>I have created a TON of missionaries, but I have gotten very few converts so far.</li>
<li>I also NEVER took any Indian land, only land that was unoccupied. (1 square away from all villages)</li>
<li>I have armed every single tribe I am in contact with with many horses and guns. I always just give 2 horses at a time and it counts as an entire horse herd.</li>
</ol>
<br />
<br />
Some pictures from midway through:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhBQ5TPu1V-laj20dKBYRdNYGE7sRZ3K1FFLVblpreGoLVS7FENaqpSpAH19eY9eHlnBxDCXVUs3TtPcncFtHm6fILG5cJ8ri25olt_dCDMZYaE-TTUjRxGSD7sFIgqVOt68hSVbnhs_gY/s1600/colo1.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="638" data-original-width="1023" height="199" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhBQ5TPu1V-laj20dKBYRdNYGE7sRZ3K1FFLVblpreGoLVS7FENaqpSpAH19eY9eHlnBxDCXVUs3TtPcncFtHm6fILG5cJ8ri25olt_dCDMZYaE-TTUjRxGSD7sFIgqVOt68hSVbnhs_gY/s320/colo1.PNG" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjT8EhDxzqN8UlgOPp7hSUb_dSCUkgMx40WI0C3WLFOgCGtruXMRVfPLN7kbCePNMWdg8idSFvvJE0rtawRoUXAAXz5KoJJNBwuhyphenhyphenDf4YU1MpJLxp77mQYjAjhmmDcFSujntoqYUSGEE1U/s1600/colo2.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="636" data-original-width="1024" height="198" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjT8EhDxzqN8UlgOPp7hSUb_dSCUkgMx40WI0C3WLFOgCGtruXMRVfPLN7kbCePNMWdg8idSFvvJE0rtawRoUXAAXz5KoJJNBwuhyphenhyphenDf4YU1MpJLxp77mQYjAjhmmDcFSujntoqYUSGEE1U/s320/colo2.PNG" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
And here is the final pic. Only one native village was destroyed by the Spanish. I finally beat down the Spanish so much that they retired from the New World.</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/AVvXsEiS0Q0T3Ja0QMtl4jN0K6EsZ9D6pkrm79zn-dPgTFw6Da9idmG97uuQpjP5_5xEYFgs74tGUZygBmRp_6eCvgg2tXS0BvhYvsKZyml9UqFCe-93GVPbfGQySz9a45tO3Y6IIahjkjWIxJI/s1600/colo3.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="639" data-original-width="1025" height="199" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiS0Q0T3Ja0QMtl4jN0K6EsZ9D6pkrm79zn-dPgTFw6Da9idmG97uuQpjP5_5xEYFgs74tGUZygBmRp_6eCvgg2tXS0BvhYvsKZyml9UqFCe-93GVPbfGQySz9a45tO3Y6IIahjkjWIxJI/s320/colo3.PNG" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<h2>
Caddyshack </h2>
<h3>
"There shall be no money, but you shall have complete enlightenment, which is nice."</h3>
Never have any money. Ever.<br />
<br />
So that means there are certain things you just can't do like:<br />
<br />
<ul>
<li>Visit native villages - they sometimes give you gifts</li>
<li>Explore - ruins give you money</li>
<li>Trade - this one is obvious</li>
<li>Take over European settlements - this comes with spoils!</li>
</ul>
<br />
This was a fun one. It was really hard in the beginning. My military was super weak at first. I basically had one soldier to guard 2 settlements until I got my first cannon. Even then I was super weak. I finally got horses from the Apache - they gifted them to me. I could have also gotten them from immigrant scouts, but I didn't get that until very late in the game.<br />
<br />
Anyway, I decided to play as the English because of their immigration bonus. I created lots of churches and preachers to get more immigrants.<br />
<br />
My war of independence was pretty rocky until I got Dutch intervention. After that it was smooth sailing.<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj7x6Wkbm2EiRB82Ta9eadklwYI6S2oxKrWStZdlE1kFpmD7Wy7IKNIAVsUC0rtEw9G3NZ01oFjxadumAqkng42Yp5rJlnZseiCGi1SfP3ZjB59OwSSfiqVfdwRKWqgB6wb4MAv2Q19-rY/s1600/colo5.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="800" data-original-width="1026" height="249" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj7x6Wkbm2EiRB82Ta9eadklwYI6S2oxKrWStZdlE1kFpmD7Wy7IKNIAVsUC0rtEw9G3NZ01oFjxadumAqkng42Yp5rJlnZseiCGi1SfP3ZjB59OwSSfiqVfdwRKWqgB6wb4MAv2Q19-rY/s320/colo5.png" width="320" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYrt-rsSlC-Ev5B2NookhG7DUbvXcBUWDW_4rPF1pcc3cOwjwXoLD0cCDWYp-zZvz4Shj169gGw-i-prLjcbjhT53-tyT2ykq68o0rwZQpEfvT789MEMhclEExmYadTbmcUz-y0EtSAYA/s1600/colo4.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="800" data-original-width="1026" height="249" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYrt-rsSlC-Ev5B2NookhG7DUbvXcBUWDW_4rPF1pcc3cOwjwXoLD0cCDWYp-zZvz4Shj169gGw-i-prLjcbjhT53-tyT2ykq68o0rwZQpEfvT789MEMhclEExmYadTbmcUz-y0EtSAYA/s320/colo4.png" width="320" /></a></div>
<br />
<h2>
Late Comer!</h2>
<div>
I've been reading a bit about the actual history of some colonies like Jamestown, Santo Domingo, Plymouth, New Amsterdam, etc. It is very interesting how the English and Dutch colonization really didn't ramp up until the 1600s.</div>
<div>
<br /></div>
<div>
So I decided to play the game as Late Comer Jr. I didn't take any screen shots, but it was fun. I basically held down the space bar until it became 1595 at which point I landed my settlers and founded a colony. Actually I should have explored a bit by ship first which did historically happen.</div>
<div>
<br /></div>
<div>
I used the English. I was amazed at how the game mimicked reality. One of the reasons the English were successful colonizers is because of their lateness. The local native populations were already reduced by smallpox and other diseases to such a degree that certain areas that were good for settlements were abandoned by the native Americans. This is a very tragic part of American history. </div>
<div>
<br /></div>
<div>
In the game, there is no disease, but the Spanish and Dutch had already come through and fought off many of the local tribes, so I did have plenty of space for settlements. I was able to build a church very quickly and get a swarm of immigrants. I needed that to catch up to the other European players.</div>
<div>
<br /></div>
<div>
I founded 4 colonies, but decided not to finish the game. I had already caught up to the other players in terms of population and military.</div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
Jesshttp://www.blogger.com/profile/05332870856354994724noreply@blogger.com6tag:blogger.com,1999:blog-1364005438157697808.post-27052156617976454202017-08-24T12:37:00.001-07:002017-08-24T12:37:39.716-07:00How to create a Bootstrap 3 ThemeWow, it was really easy once I figured out how to do it.<br />
<br />
I all relies on a config.json file. You don't have one? Download the base bootstrap from this link.<br />
<br />
<a href="https://getbootstrap.com/docs/3.3/">https://getbootstrap.com/docs/3.3/</a><br />
<br />
The download link is at the very bottom.<br />
<br />
Once you have the file, tweak the LESS variables to your heart's content! I put in my brand colors, tweaked a lot of the padding, and some fonts.<br />
<br />
Then using the same URL above, upload the config.json and see that all of the variables you changed are reflected in the page. Then simply download it again! Voila!<br />
<br />
Note. I tried to add inline comments to the JSON in // and /**/ form, but the parser did not like that at all.Jesshttp://www.blogger.com/profile/05332870856354994724noreply@blogger.com0tag:blogger.com,1999:blog-1364005438157697808.post-66267750823547629192016-12-15T13:10:00.002-08:002016-12-15T13:14:42.540-08:00How to Import Excel or CSV data into SQL Server using SSDTI have recently rebuilt my computer and decided to give SSDT a try. This is SQL Server Data Tools. I would use it instead of SQL Server Management Studio (SSMS).<br />
<br />
It has been going really well so far. I'm able to do all the normal things I'm used to. Until now. I wanted to import an Excel file into a table. I've done it a million times in SSMS, but how do I do it in SSDT?<br />
<br />
After some googling, I came up empty. I should note that I am a C# developer. I'm not using database projects.<br />
<br />
Anyway, I figured out a really easy and almost ridiculous way to import the data.<br />
<br />
Before you do this, make sure your database is backed up. Only do this with small data sets.<br />
<br />
<ol>
<li>Open Visual Studio with SSDT. To see if you have SSDT, look in your <b>Help > About</b> dialog and look in the list of <b>Installed products</b>.</li>
<li>Open the <b>SQL Server Object Explorer</b> view. (It's in the <b>View</b> menu).</li>
<li>Connect to your DB and drill down to the table you want to import to.</li>
<li>Right click the table and select <b>View Data</b>.</li>
<li>Now go into Excel and select the data you want to import and hit our good old friend, <b>CTRL-C</b> or <u>Copy</u>.</li>
<li>Switch back to Visual Studio, click on the row with all of the NULL values. This row is intended for adding a single new row. However, with the row selected, you can hit <b>CTRL-V</b> and paste all of the data into the new table. Make sure the data fields line up.</li>
<li>This will even work with IDENTITY columns. Just make sure to have a column in Excel filled with zeros.</li>
<li>That's it! You might have to wait a while!</li>
</ol>
<div>
I should note that this is not the best plan if you have many rows of data. If you have 1000 or less, this seems like a decent approach. It may take a little while to import the data via copy/paste though.</div>
Jesshttp://www.blogger.com/profile/05332870856354994724noreply@blogger.com0tag:blogger.com,1999:blog-1364005438157697808.post-77776001680063026152016-05-27T05:10:00.000-07:002017-09-12T08:16:24.773-07:00Comparison and Review of .NET Fuzzy Matching Nuget PackagesI am simply using Jaro-Winkler to get a similarity factor of 2 strings. I'm using this for name and address comparisons and doing my own score aggregation and weighting.<br />
<br />
I first tried <a href="https://www.nuget.org/packages/FuzzyString"><b>Fuzzy String</b></a>. Unfortunately, it has <a href="https://fuzzystring.codeplex.com/workitem/list/basic">several issues</a> preventing it from working properly. Even among these issues, I found other examples that caused the Jaro-Winkler algorithm to go into an infinite loop. It's funny that this package has a 5 star rating, because for my use case, only using Jaro-Winkler, it failed miserably.<br />
<br />
Then I tried <a href="https://www.nuget.org/packages/BlueSimilarity/" style="font-weight: bold;">BlueSimilarity</a>. This package also had issues loading a BlueSimilarity.Interop.dll. At this point I was tired of troubleshooting and just wanted a solution that worked. Besides, on nuget the project site is a broken link. Man.<br />
<br />
Finally I tried <a href="https://www.nuget.org/packages/SimMetrics-TextFunctions/" style="font-weight: bold;">SimMetrics-TextFunctions</a>. This worked really well! I had a few small unit tests to simply verify that the bugs in FuzzyString are not in this implementation. Awesome!<br />
EDIT: Wow. I found out 7 months later that this package does indeed have a bug. It is easy to work around, but I consider it a bug non-the-less. This code, with a space prefix on one of the strings returns with a zero similarity. EDIT 2: Over a year later, I have found a bug. With strings "Canyon Rd" and "Canyon Est Dr" I am getting a similarity score of .4. It should be much higher than that. So... I'm changing my implementation... again.<br />
<br />
Now I am using some <a href="https://stackoverflow.com/a/19165108/1804678">code from <b>Stack Overflow</b></a>. I'm really surprised that all the NuGet packages have some kind of issue and that this bit of code passes where all the others fail. Thank goodness for unit tests. I have a ton of them.<br />
<br />
<script src="https://gist.github.com/jesslilly/07b1b2cf8f9ab2308ebf3b1f3f0266b2.js"></script>Jesshttp://www.blogger.com/profile/05332870856354994724noreply@blogger.com1tag:blogger.com,1999:blog-1364005438157697808.post-89837817269563488482016-05-09T11:22:00.001-07:002018-11-29T13:11:49.463-08:00My Entity Framework Cheat SheetThis is a list of tools I use to get generated code and get work done quickly with Entity Framework.<br />
<div>
<ol>
</ol>
</div>
<div>
<h2>
Generate SQL/Database from a DbContext</h2>
</div>
<div>
Tip: If you are doing this a second time to rebuild your database (after requirements changes), you can...<br />
<br />
<ul>
<li>... unload your Web or Api, Services, and Tests projects and just have your DbModels and DbContext projects open. That way you can rebuild the solution easily targetting just your Entity Framework related code. (Assuming you may have code referencing your DbModels which are changing). </li>
<li>... or if you are rebuilding only a subset of new tables, run a "Reset" migration first using <a href="https://stackoverflow.com/a/49876164/1804678">this trick</a> to omit the tables you are working on. Then remove the Ignore methods and run a second migration for those tables in question.</li>
</ul>
</div>
<div>
<ol>
<li>For the entities, create a models directory and create classes in it.</li>
<ol>
<li>If your primary key does not follow convention name, use the [<i>Key</i>] attribute.</li>
<li>Create navigation properties for many to one relationships; create a property for the ID and the object.</li>
<li>If your nav prop ID does not follow convention, use the [<i>ForeignKey</i>] attribute on the object.</li>
<li>Other attributes to use: <i>Required, MaxLength, Index, InverseProperty, Column</i> (if you want your db column to have a different name), [<i>Table</i>("TableName", Schema = "SchemaName")]</li>
<li>Don't forget to make some fields nullable if necessary.</li>
</ol>
<li>VIEW > Other > <b>Package Manager Console</b>.</li>
<li>Make sure the console is showing the correct project. You also may need to set that project as the startup project in VS so it can find the correct config file with the DB connection string.</li>
<li>If you are trying to recreate your database, make sure to <a href="https://gist.github.com/jesslilly/c95793ca0cb113818c56aa4058733f09">drop the DB</a> or change the connection string. Also remove the Migrations folder.</li>
<li>Make sure you have a DbContext file with:</li>
<ol>
<li>A good database connection string.</li>
<li>Sub-classing DbContext</li>
<li>public DbSet<Entity> Entities {get;set;}</li>
<li>If you are using .NET Core, you will need a <a href="https://gist.github.com/jesslilly/5fad464839a41daa5e79aa5e027fb15d">IDesignTimeDbContextFactory</a> or a <a href="https://stackoverflow.com/questions/46202845/idesigntimedbcontextfactory-not-always-needed">default constructor</a>.</li>
</ol>
<ol>
</ol>
<li>Type: <b>Enable-Migrations</b>. Skip this for .NET Core</li>
<li><b>Add-Migration MigrationName</b></li>
<li><b>Update-Database -Script</b> or for .NET Core: <b>Script-Migration</b>. Save off the SQL if you want it.</li>
<li><b>Update-Database</b>. Now your database tables are created.</li>
</ol>
<div>
<h2>
Generate Classes for Entity Framework Code-First from an Existing Database</h2>
<div>
For EF Core, the process has changed. See the <a href="https://stackoverflow.com/a/46203681/1804678">Scaffold-DbContext</a> command.</div>
<div>
<br /></div>
<div>
For EF 6, the below process works well.</div>
<div>
<ol>
<li>Prerequisite: An existing database</li>
<li>Do one time: <a href="https://www.microsoft.com/en-us/download/details.aspx?id=40762">Download Entity Framework 6 Tools for Visual Studio 2012 & 2013</a>.</li>
<li>Right click a project</li>
<li><b>Add new item...</b></li>
<li>Search for ADO, select <b>ADO.NET Entity DataModel</b>.</li>
<li>Name it.</li>
<li>Select <b>Code First from database</b>.</li>
<li>Select / Create Database connection.</li>
<li>Select tables you want to include.</li>
<li>Finish</li>
<li>Now you have models and a DbContext to work with.</li>
</ol>
</div>
</div>
</div>
Jesshttp://www.blogger.com/profile/05332870856354994724noreply@blogger.com0tag:blogger.com,1999:blog-1364005438157697808.post-78349224843275172562016-03-30T13:34:00.003-07:002017-01-20T11:35:44.674-08:00Generate .NET MVC Views for a ViewModel<span style="font-family: "trebuchet ms" , sans-serif;">So I have a ViewModel that I created. Now I want to generate a controller and views for it with the typical CRUD actions. I'm not going to use all the actions, but I did want a few of them. This is very easy to do with normal Entity Framework entities, but what about a view model?</span><br />
<span style="font-family: "trebuchet ms" , sans-serif;"><br /></span>
<span style="font-family: "trebuchet ms" , sans-serif;">I decided to see if I could fake out the scaffolding tool and I was able to!</span><br />
<span style="font-family: "trebuchet ms" , sans-serif;"><br /></span>
<span style="font-family: "trebuchet ms" , sans-serif;">Here's what you do:</span><br />
<span style="font-family: "trebuchet ms" , sans-serif;"><br /></span>
<br />
<ol>
<li><span style="font-family: "trebuchet ms" , sans-serif;">Make your POCO MyThingViewModel class.</span></li>
<li><span style="font-family: "trebuchet ms" , sans-serif;">Make sure to have one property in the class annotated with <b>[Key]</b>.</span></li>
<li><span style="font-family: "trebuchet ms" , sans-serif;">Take some time to annotate your view model with attributes like:</span></li>
<ol>
<li><span style="font-family: "trebuchet ms" , sans-serif;">[StringLength(10)]</span></li>
<li><span style="font-family: "trebuchet ms" , sans-serif;">[Required]</span></li>
<li><span style="font-family: "trebuchet ms" , sans-serif;">[DataType(DataType.Date)]</span></li>
<li><span style="font-family: "trebuchet ms" , sans-serif;">[Display(Name = @"Unit Type")]</span></li>
<li><span style="font-family: "trebuchet ms" , sans-serif;">[DisplayFormat(DataFormatString = "{0:MM/dd/yyyy}", ApplyFormatInEditMode = true)]</span></li>
<li><span style="font-family: "trebuchet ms" , sans-serif;">[Range(1,100)]</span></li>
</ol>
<li><span style="font-family: "trebuchet ms" , sans-serif;">Find your DbContext class and add a <b>DbSet<MyThingViewModel></b></span></li>
<li><span style="font-family: "trebuchet ms" , sans-serif;">BUILD your solution.</span></li>
<li><span style="font-family: "trebuchet ms" , sans-serif;">Now on the controllers folder, right click and <b>"Add Scaffolded Item..."</b></span></li>
<li><span style="font-family: "trebuchet ms" , sans-serif;">Choose <b>MVC 5 Controller with views, using Entity Framework</b>.</span></li>
<li><span style="font-family: "trebuchet ms" , sans-serif;">Choose your DbContext, MyThingViewModel Class, and desired controller name like, MyThingsController.</span></li>
<li><span style="font-family: "trebuchet ms" , sans-serif;">Click Finish</span></li>
</ol>
<div>
<span style="font-family: "trebuchet ms" , sans-serif;">The scaffolding tool will do its work and create the views for you! Obviously now you have code that will not run since there is no MyThingViewModel in the database. (Don't try to run this code with automatic migrations!)</span><br />
<span style="font-family: "trebuchet ms" , sans-serif;"><br /></span>
<span style="font-family: "trebuchet ms" , sans-serif;">Now that you have your views:</span><br />
<br />
<ol>
<li><span style="font-family: "trebuchet ms" , sans-serif;">Remove the DbSet and Key attribute.</span></li>
<li><span style="font-family: "trebuchet ms" , sans-serif;">Edit the controller to populate the View Model however you need to.</span></li>
</ol>
<span style="font-family: "trebuchet ms" , sans-serif;">Enjoy the "free" views.</span><br />
<span style="font-family: "trebuchet ms" , sans-serif;"><br /></span>
<br />
<h2>
<span style="font-family: "trebuchet ms" , sans-serif;">Alternate Option</span></h2>
</div>
<div>
<span style="font-family: "trebuchet ms" , sans-serif;">There is another option. You can simply use a DB Model in the Add Scaffolded Item Wizard and manually change the code to use a view model. This is pretty easy to do for CRUD implementations where the DB Model and the view model are almost identical.</span></div>
Jesshttp://www.blogger.com/profile/05332870856354994724noreply@blogger.com0tag:blogger.com,1999:blog-1364005438157697808.post-31191723836197875272016-02-12T05:45:00.002-08:002016-12-08T05:19:20.009-08:00Windows 8.1 Disk Usage / IO at 99 or 100%<h2>
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;">tl;dr</span></h2>
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;">We ended up getting solid state drives on our team and our laptops are running super fast now!</span><br />
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><br /></span>
<h2>
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;">The Long Story</span></h2>
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;">So I just resumed my laptop from hibernation. Things are running pretty slowly. It can last for up to 15 minutes.</span><br />
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;">It is a fresh install of Windows 8.1 from about 3 months ago. I have a DELL PRECISION M4800. The laptop is pretty good but it does suffer from slowness. I have finally pinpointed the slowness to the Disk. If I open Task Manager, I can see whenever my laptop is slow, the Disk column is at 99%. There is usually no single process hogging the disk. Usually it is several. I have never seen Memory maxed out, and CPU will spike occasionally, but not often.</span><br />
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;">Most of the time the slowness is during the first 10 minutes of boot up and starting any program. I mean any normal GUI program like chrome, paint.net, IE, Outlook, etc. It takes at least 30 seconds (usually more) to start any program.</span><br />
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;">Back to the disk. I've also seen slowness when I am emptying the trash or doing large file operations.</span><br />
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;">On to the fix. This is the first thing I tried, changing the virtual memory settings:</span><br />
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><br /></span>
<a href="http://answers.microsoft.com/en-us/windows/forum/windows_8-performance/windows-8-keeps-slows-down-to-100-disk-usage-and/cd787f8d-e7b4-4872-aecb-6f0cd15ad942?auth=1"><span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;">http://answers.microsoft.com/en-us/windows/forum/windows_8-performance/windows-8-keeps-slows-down-to-100-disk-usage-and/cd787f8d-e7b4-4872-aecb-6f0cd15ad942?auth=1</span></a><br />
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;">Of course you have to reboot to make this take effect and I have work to do! So stay tuned!</span><br />
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;">This did not help at all. I should have known.</span><br />
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;">I just now went to <b>Control Panel > System > Advanced System Settings > Advanced tab > Performance > Settings > "Adjust for best performance".</b> </span><br />
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;">This helped a lot actually. I still see my laptop maxing out the disk at 99% periodically, but the performance is noticeably faster, especially after boot up when I open several applications. I don't think this solved the root of the problem.</span><br />
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;">I also tried to disable search indexing on my C drive. Let's see if that helps. (WARNING: Disabling search indexing on the full drive can take a long time.)</span><br />
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;">Turning off indexing did not seem to help that much.</span><br />
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;">I also tried this solution, but it did not seem to do much: <a href="http://superuser.com/a/926390/199528">http://superuser.com/a/926390/199528</a>. </span><br />
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;">Ug. I think it's fair to say that nothing so far has really helped. See screenshot below.</span><br />
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgoSnQvOA7bkv66-8nNiFcwkp5UbRPA7aVOFSP1n6k-tAIRMnyQHF9EtGOKI98Qyd6smj9jTwvZVM1a9_sDHulooMFNOZcmeg777SiyalamwYxOSXitHXayNLLlqXbd0YlupyJNcxzRFmY/s1600/disk_max_100.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="170" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgoSnQvOA7bkv66-8nNiFcwkp5UbRPA7aVOFSP1n6k-tAIRMnyQHF9EtGOKI98Qyd6smj9jTwvZVM1a9_sDHulooMFNOZcmeg777SiyalamwYxOSXitHXayNLLlqXbd0YlupyJNcxzRFmY/s320/disk_max_100.png" width="320" /></a></div>
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;">I'm starting to believe that my virus scanner is the problem. Not sure what to do next though. I don't see any way to temporarily disable it.</span><br />
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;">My buddy Tim has the same computer and suggested <a href="http://www.williambharding.com/blog/technology/fixed-my-i7-intel-dell-laptop-is-ridiculously-slow/">disabling SpeedStep</a>, but unfortunately there is no noticeable change for me.</span><br />
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;">I have disabled SpeedStep again and it is not helping. Now I have done this google search:</span><br />
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><a href="https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=windows%208.1%20task%20manager%20disk%20100">https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=windows%208.1%20task%20manager%20disk%20100</a></span><br />
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;">And found that my virtual memory is quite low. I don't have my physical memory maxed out, but it is worth a try. I have set it to min 8000MB (same as my physical memory) and max 16000MB (double physical memory). I need to reboot (later) and find out if this helps!</span><br />
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;">It didn't help.</span><br />
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;">I tried stopping some services using Start > Search > msconfig to disable and services.msc to see what the service is. I disabled a lot of bluetooth services since I don't use them and superfetch. This did not help either.</span><br />
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;">I restarted my computer in safe mode and safe mode with networking. Both were working much better - I could start programs in only a few seconds, but I still do not know what services I need to stop.</span><br />
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;">Wow! Now I am getting somewhere. I have a balanced Power Settings profile in effect. I changed from balanced to High Performance temporarily. Then in a balanced profile, I found that setting my Hard Drive sleep minutes to zero (when plugged in) to disable Hard Drive sleep is helping. Programs are now starting up in only a few seconds!</span><br />
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;">Ug. That was a fluke. It's still very slow to start up. No root cause identified yet. It is something software related since it was starting up applications very quickly in safe mode. Now I am trying a fully High Performance Power profile.</span><br />
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;">A friend from work recommended <b>Start > Run > </b></span><span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><b>control.exe srchadmin.dll</b>. Then disable indexing for mapped drives. I tried turning indexing off for everything. We'll see if that helps.</span><br />
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"></span><br />
<div class="MsoNormal">
<br /></div>
Jesshttp://www.blogger.com/profile/05332870856354994724noreply@blogger.com0tag:blogger.com,1999:blog-1364005438157697808.post-82263189256762551222015-06-22T10:06:00.004-07:002015-06-22T10:06:52.705-07:00How to add a password to Web.config and encrypt itI recently had the need to store a password in the web.config file in an ASP.NET web app and I wanted to encrypt it. I did not want to encrypt the entire appSettings section of the Web.config, so here's a solution I came up with, answering my own question on Stack Overflow, community wiki style!<br />
<br />
<a href="http://stackoverflow.com/questions/30983920/how-to-add-a-password-to-web-config-and-encrypt-it">http://stackoverflow.com/questions/30983920/how-to-add-a-password-to-web-config-and-encrypt-it</a>Jesshttp://www.blogger.com/profile/05332870856354994724noreply@blogger.com0tag:blogger.com,1999:blog-1364005438157697808.post-35238575595763040692015-06-22T10:03:00.001-07:002015-06-22T10:03:58.231-07:00Need to Mock a DbSet for testing Entity Framework?I wanted to create fast unit tests that did not rely on the database, nor data in the DB. I used the Moq framework to create mock objects, but the Entity Framework DbSet was not easy to mock, so I created my own class. The gist is on github. View the readme in the gist for more details. (One of the hardest things is to workaround the DbFunctions which only work for LINQ to Entities).<br />
<br />
<script src="https://gist.github.com/jesslilly/d3ce6d776b0a3b0f35d8.js"></script>
Jesshttp://www.blogger.com/profile/05332870856354994724noreply@blogger.com0tag:blogger.com,1999:blog-1364005438157697808.post-30594517017042528062015-05-21T13:53:00.001-07:002015-05-22T06:16:36.057-07:00Implementing a Base Class with Entity FrameworkI want to add a bunch of audit fields to all of my tables. Here's how I did it with a base class. Note that the base class must have a key column. The subclass does not have an ID explicitly; it inherits the ID column from the base class.
<br>
<br>
The call to MapInheritedProperties will put the inherited properties directly on the subclass table. <br>
<br>
<br>
<br>
<script src="https://gist.github.com/jesslilly/aec5f154f85e6bda9309.js"></script>Jesshttp://www.blogger.com/profile/05332870856354994724noreply@blogger.com0tag:blogger.com,1999:blog-1364005438157697808.post-12974939257246707132015-05-21T13:34:00.002-07:002015-05-21T13:35:51.917-07:00Nhibernate performance improvementsI recently took a process that was running for hours and would never finish and made it run in less than an hour. It was also using one big transaction which was locking other people out of the database. So here are the big 3 performance improvements I used.<br />
<br />
<h3>
Batching</h3>
<div>
I basically used some code from the <a href="http://nhibernate.info/doc/nhibernate-reference/batch.html#batch-inserts">NH documentation</a> to implement SQL execution batching. I also batched the transactions which was very easy to do. You just do:</div>
<div>
<br /></div>
<div>
<div class="line number21 index20 alt2" style="background: none rgb(255, 255, 255) !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; color: #333333; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-size: 14px; height: auto !important; left: auto !important; line-height: 20px; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: nowrap !important; width: auto !important;">
<code class="java plain" style="background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; color: rgb(0, 0, 0) !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; height: auto !important; left: auto !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">session.Transaction.Commit();</code></div>
<div class="line number22 index21 alt1" style="background: none rgb(255, 255, 255) !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; color: #333333; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-size: 14px; height: auto !important; left: auto !important; line-height: 20px; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: nowrap !important; width: auto !important;">
<code class="java plain" style="background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; color: rgb(0, 0, 0) !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; height: auto !important; left: auto !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">session.BeginTransaction();</code></div>
</div>
<div class="line number22 index21 alt1" style="background: none rgb(255, 255, 255) !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; color: #333333; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-size: 14px; height: auto !important; left: auto !important; line-height: 20px; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: nowrap !important; width: auto !important;">
<code class="java plain" style="background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; color: rgb(0, 0, 0) !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; height: auto !important; left: auto !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><br /></code></div>
<div class="line number22 index21 alt1" style="background: none rgb(255, 255, 255) !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; color: #333333; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-size: 14px; height: auto !important; left: auto !important; line-height: 20px; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: nowrap !important; width: auto !important;">
<span style="color: black; font-family: 'Times New Roman'; font-size: small; line-height: normal; white-space: normal;">This was a huge performance boost.</span><br />
<span style="color: black; font-family: 'Times New Roman'; font-size: small; line-height: normal; white-space: normal;"><br /></span></div>
<h3 style="background: none rgb(255, 255, 255) !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<span style="font-size: small;">Native SQL</span></h3>
<div>
<span style="font-size: small;">There was some code that read a list of entities from the DB into a session and then updated the same field to the same value in a loop. Instead I used "session.CreateQuery" to run a single update. Then the code did not have to do the select, nor load all the entities into memory.</span><br />
<span style="font-size: small;"><br /></span></div>
<h3>
<span style="font-size: small;">Pre-Fetching</span></h3>
<div>
<span style="font-size: small;">Running selects in a loop can be disastrous to performance. So where possible I pre-fetched data that I needed before the loop and put it into a Dictionary. (Or Map, Hash Table, whatever you want to call it!)</span></div>
Jesshttp://www.blogger.com/profile/05332870856354994724noreply@blogger.com0tag:blogger.com,1999:blog-1364005438157697808.post-23672313025687800442015-03-02T12:53:00.001-08:002015-03-31T05:35:33.482-07:00A Little Research on Ionic and AngularJs 2.0First, AngularJS 2.0 is not coming out for a while. There is currently no release date. You can look at their status/progress on Google drive:<br />
<div>
<br /></div>
<div>
<a href="https://drive.google.com/folderview?id=0B7Ovm8bUYiUDR29iSkEyMk5pVUk">https://drive.google.com/folderview?id=0B7Ovm8bUYiUDR29iSkEyMk5pVUk</a></div>
<div>
<br /></div>
<div>
Right now it seems about half way done? It's a crude estimate. There is some talk that it will be done "end of 2015". </div>
<div>
<br /></div>
<div>
Also, Ionic Framework. Wow it looks great, but it does not solve ALL your problems. You can use it to create beautiful HYBRID apps, but not really for mobile web: </div>
<div>
<br /></div>
<div>
<a href="http://ionicframework.com/docs/overview/#browser-support">http://ionicframework.com/docs/overview/#browser-support</a></div>
<div>
<br /></div>
<div>
So if you use it, you still may need to support mobile web depending on your project requirements. </div>
<div>
<br /></div>
<div>
Now what about Ionic with AngularJS 2.0? It may take even longer for that. I read that Ionic uses some Angular APIs pretty heavily, and they are all changing. </div>
<div>
<br /></div>
Jesshttp://www.blogger.com/profile/05332870856354994724noreply@blogger.com0tag:blogger.com,1999:blog-1364005438157697808.post-77445394632172186452015-01-05T12:15:00.001-08:002015-01-05T12:18:40.942-08:00jQuery POST to ASP.NET MVC ControllerI recently created some code to us jQuery to post to a MVC Controller.<br />
<br />
Here's the code.<br />
<br />
<br />
<script src="https://gist.github.com/jesslilly/d48058dd13f54218eac4.js"></script>
<br />
I was a little surprised at the different return values from the C#.<br />
<br />
In the case of a success, I am returning a JSON object to the client, which is being processed in the done callback of the jquery promise.<br />
<br />
When there is an error, there is a response code with a message sent back to the client which is handled by the fail callback.<br />
<br />
From my reading and searches on Stack Overflow, these appear to be the best practices as of this writing for return values from a HttpPost Action.<br />
<br />
Note that I am not posting a form directly. If you do that, your HttpPost service should also include a redirect like this:<br />
<br />
<span style="font-family: Courier New, Courier, monospace;"><b> // http://stackoverflow.com/a/9435432/1804678</b></span><br />
<span style="font-family: Courier New, Courier, monospace;"><b> return RedirectToAction("Index", "Work");</b></span>Jesshttp://www.blogger.com/profile/05332870856354994724noreply@blogger.com0tag:blogger.com,1999:blog-1364005438157697808.post-3133586047741456492014-12-15T12:13:00.001-08:002014-12-15T12:13:30.468-08:00SSDT get your DB back in sync with your projectSo I've been using SQL Server Data Tools (SSDT) in visual studio to manage database changes. I'm the only one really using it on my team right now. I had been working on a branch project in isolation for a while and the trunk database schema kept changing.<br />
<br />
Today I am working in trunk (HEAD/master) again. So I need to switch to the trunk branch of my SSDT solution and get it back in sync with everyone else. I was amazed at how easy this was.<br />
<br />
Simply do a database schema compare using a database with the most recent schema as the source and the SSDT project as the target. Run the update to make changes to all the SQL files in the target (the project). Then you can commit all those changes to your source control and VOILA! - Your SSDT project is back in sync.<br />
<br />
Now I can develop my own schema changes and generate the change scripts easily. Sweet!Jesshttp://www.blogger.com/profile/05332870856354994724noreply@blogger.com2tag:blogger.com,1999:blog-1364005438157697808.post-21226453394862076322014-12-06T06:56:00.001-08:002014-12-06T07:07:34.073-08:00Print from an iPhone to an HP Photosmart plus all in oneJI used to be able to print from my iPhone 4S. But I don't print much and I have since upgraded my router and upgraded to an iPhone 6. <div><br></div><div>I couldn't remember how I set it up a few years ago. Anyway, it's really easy. This printer does support a way of emailing documents to the printer which is one way to do it. </div><div><br></div><div>The other way is to go to the App Store on your iPhone. Search for HP ePrint. Download and install the app (it's free). If your printer is not detected right away, restart it by simply powering it off powering it back on. You may also have to restart your wireless router. These resetting steps are a pain, but they really work. Next add your wireless printer. Now you can print from any app on your iPhone.</div><div><br></div>Jesshttp://www.blogger.com/profile/05332870856354994724noreply@blogger.com0tag:blogger.com,1999:blog-1364005438157697808.post-44470379659689532582014-12-03T08:28:00.000-08:002014-12-03T08:28:16.350-08:00HTML CSS Form Layout<br />
I just created an awesome plunker showing a form with different layout markup and styling. I have one for percent widths, 2 using floats and one using a table.<br />
<br />
<a href="http://plnkr.co/edit/50Pq71?p=preview">http://plnkr.co/edit/50Pq71?p=preview</a><br />
<br />
<br />
<br />Jesshttp://www.blogger.com/profile/05332870856354994724noreply@blogger.com0tag:blogger.com,1999:blog-1364005438157697808.post-73016497071362131672014-12-02T17:06:00.002-08:002014-12-02T17:06:45.339-08:00touchend javasccript event not workingSo I came to find out today that I think the touchend event has a pageX and pageY populated in Safari, but not in the Android browser.<br />
<br />
Here's the code.<br />
<br />
<br />
<span style="font-family: Courier New, Courier, monospace;">if (canvas.addEventListener) {</span><br />
<span style="font-family: Courier New, Courier, monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>canvas.addEventListener("mousedown", function(e) {</span><br />
<span style="font-family: Courier New, Courier, monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span> click(e.pageX, e.pageY);</span><br />
<span style="font-family: Courier New, Courier, monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}, false);</span><br />
<span style="font-family: Courier New, Courier, monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>canvas.addEventListener("touchstart", function(e) {</span><br />
<span class="Apple-tab-span" style="font-family: 'Courier New', Courier, monospace; white-space: pre;"> </span><span style="font-family: 'Courier New', Courier, monospace;"> e.preventDefault();</span><br />
<span style="font-family: Courier New, Courier, monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span> click(e.touches[0].pageX, e.touches[0].pageY);</span><br />
<span style="font-family: Courier New, Courier, monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}, false);</span><br />
<span style="font-family: Courier New, Courier, monospace;">}</span><br />
<br />
Originally, I was using e.pageX and e.pageY and it worked on chrome (desktop) and mobile safari, but it was failing on a Samsung device. So, reading about the touchend event on Mozilla, I found that there is a touches array with the list of touches. That was populated on a mobile.Jesshttp://www.blogger.com/profile/05332870856354994724noreply@blogger.com0tag:blogger.com,1999:blog-1364005438157697808.post-15778185956927185952014-11-15T13:15:00.001-08:002014-11-15T17:08:03.935-08:00Saturday UTF8 ReadingReading about UTF8 on a Saturday afternoon? Yeah I didn't expect that either. But I was having trouble yesterday at work sending html email. I was getting some mojibake. That's when characters are encoded one way and interpreted in another way. It looks like some of the characters turn into garbage. For example in Microsoft outlook you get a black diamond with a question mark for some special characters.<br />
<div>
<br /></div>
<div>
I'm learning that UTF8 is really a dominant standard mostly because it can be used to encode all Unicode characters as well as support good old ASCII. ASCII is UTF8. UTF8 can do these tricks because it can encode characters with a variable number of bytes. For common and ASCII characters it uses just one. For special characters it might use two or more bytes. </div>
<div>
<br /></div>
<div>
Also UTF-8 is being used more and more for all Internet related documents and email clients all support HTML encoded in UTF-8. Read more about it at <a href="http://en.m.wikipedia.org/wiki/UTF-8">Wikipedia</a>. </div>
<div>
<br /></div>
<div>
This is a good read too from <a href="http://www.emailonacid.com/blog/details/C13/the_importance_of_content-type_character_encoding_in_html_emails">email on acid</a>.</div>
<div>
<br /></div>
<div>
I learned that most email clients IGNORE the content type in the HTML but instead use the content type from the email header. That was certainly tricking me up yesterday. </div>
<div>
<br /></div>
<div>
The problem was with File.ReadAllText. The solution was to use the correct encoding.<br />
<br />
<span style="color: #cc0000; font-family: Courier New, Courier, monospace;"><b>File.ReadAllText(tempFilePath, System.Text.Encoding.GetEncoding(1252))</b></span><br />
<span style="color: #cc0000; font-family: Courier New, Courier, monospace;"><b><br /></b></span>
See also this <a href="http://stackoverflow.com/questions/15480970/invalid-characters-in-file-readalltext">Stack Overflow question</a>.</div>
Jesshttp://www.blogger.com/profile/05332870856354994724noreply@blogger.com0tag:blogger.com,1999:blog-1364005438157697808.post-31722729619640379092014-11-07T11:15:00.001-08:002014-11-07T12:21:28.814-08:00Nhibernate LINQ query with null Where conditionSo today I was trying to profile a query and for the life of me I could not see the query in the profiler. Simple queries where working fine:<br />
<br />
<span style="color: blue; font-family: Courier New, Courier, monospace;"><b>Session.Get<User>(123); // I could see the SQL in the profiler.</b></span><br />
<span style="color: blue; font-family: Courier New, Courier, monospace;"><b><br /></b></span>
<span style="color: blue; font-family: Courier New, Courier, monospace;"><b>Session.Query<User>().Where(u => u.thing == someVar) // I was not seeing this in the profiler.</b></span><br />
<br />
Come to find out, "someVar" was null. OMG. Wow. It's kind of like trying to run this SQL<br />
<br />
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b>select u.*</b></span><br />
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b>from user</b></span><br />
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b>where 1=0</b></span><br />
<br />
There's pretty much no point in running that query and I guess LINQ to NHibernate thought the same thing!<br />
<br />
This happened because someVar was coming from config. The config file for my unit test was missing the variable, so it was null. Fun times.<br />
<br />
OK, so I fixed that problem and it turned out not to be it. My queries from the unit test kept returning empty IEnumerables. So I come to find out that the Fluent Nhibernate Models I am using are special models that are not in the same namespace as the majority of our models. I had to add the models to the NHibernate Config code and NOW the LINQ queries are working.<br />
<br />
<br />Jesshttp://www.blogger.com/profile/05332870856354994724noreply@blogger.com0tag:blogger.com,1999:blog-1364005438157697808.post-31291937865488555592014-10-20T13:11:00.001-07:002014-10-21T11:42:51.571-07:00AngularJs vs KnockoutJsI've used AngularJs before. It's pretty cool. I just watched a presentation on KnockoutJs. Knockout is also pretty cool in that it has 2 way data binding, so when the view model changes, the view changes and vice version - the view and view model are always in sync.<br />
<br />
I have not used either of these frameworks extensively, but I will say that with Knockout, you have to explicitly make all of your data into observables. What's worse is that in a very common example of an array of objects, you have to make the array observable as well as all of the properties of the objects in the array. Likewise when you want to POST the data, you have to convert it from a Knockout observable object/array to a plain old javascript object/array using ko.toJSON(koObject).<br />
<br />
With angular, all you have to do is put data into your $scope and it is immediately observable. There is no encapsulating it with observables, nor converting it back to a plain old javascript object when you need to POST to a web service.<br />
<br />
Another thing I don't quite like about Knockout is that is has no way to "commit or undo" a change to the view model. For example, if I change a text field in the view and then I hit cancel to "undo" the change, I can't - the view model has already been changed. You have to manage that yourself. AngularJS has this same issue too.<br />
<br />
Some more interesting tidbits... Incrementing is not as fun as in angular. Since obserables are functions you have to increment like this:<br />
<br />
<span style="font-family: Courier New, Courier, monospace;">this.count(this.count() + 1);</span><br />
<br />
In angular you can simply do:<br />
<br />
<span style="font-family: Courier New, Courier, monospace;">$scope.count++;</span><br />
<br />
Also I found out that using the ko array utilities, you lose access to the "this" pointer. I found out the hard way that it is actuallly a good thing. Why? You should not be editing your view model in a loop! You will be updating the view N times, which is not very performant!<br />
<br />
<br />Jesshttp://www.blogger.com/profile/05332870856354994724noreply@blogger.com0