Tuesday, October 17, 2017

Enviro Empress Igniter

Our 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.

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.

I placed the igniter on the hearth in very fireproof place, 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. 




So I ordered a new one from Amazon.  Hopefully that will do the trick!

Wednesday, September 13, 2017

Colonization Rampage 2

OK.  This old game is still wicked fun.

I downloaded the new Colonization game on the iPhone.  It was playable, but the controls were really bad and it was not very fun.

I downloaded the game again from GOG.  I decided to try another game with a challenge.

Here are my old challenges.  Never going back to Europe was my favorite.

Save the Natives


Anyway, I wanted to play a game where I tried to prevent all native villages from being destroyed.

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).

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:


  1. I got Hernando de Soto first!  That was lucky.  All my exploration is always positive.  But I never dug any burial mounds.
  2. 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.
  3. I have created a TON of missionaries, but I have gotten very few converts so far.
  4. I also NEVER took any Indian land, only land that was unoccupied.  (1 square away from all villages)
  5. 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.


Some pictures from midway through:



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.



Caddyshack 

"There shall be no money, but you shall have complete enlightenment, which is nice."

Never have any money.  Ever.

So that means there are certain things you just can't do like:

  • Visit native villages - they sometimes give you gifts
  • Explore - ruins give you money
  • Trade - this one is obvious
  • Take over European settlements - this comes with spoils!

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.

Anyway, I decided to play as the English because of their immigration bonus.  I created lots of churches and preachers to get more immigrants.

My war of independence was pretty rocky until I got Dutch intervention.  After that it was smooth sailing.





Thursday, August 24, 2017

How to create a Bootstrap 3 Theme

Wow, it was really easy once I figured out how to do it.

I all relies on a config.json file.  You don't have one?  Download the base bootstrap from this link.

https://getbootstrap.com/docs/3.3/

The download link is at the very bottom.

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.

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!

Note.  I tried to add inline comments to the JSON in // and /**/ form, but the parser did not like that at all.

Thursday, December 15, 2016

How to Import Excel or CSV data into SQL Server using SSDT

I 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).

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?

After some googling, I came up empty.  I should note that I am a C# developer.  I'm not using database projects.

Anyway, I figured out a really easy and almost ridiculous way to import the data.

Before you do this, make sure your database is backed up.  Only do this with small data sets.

  1. Open Visual Studio with SSDT.  To see if you have SSDT, look in your Help > About dialog and look in the list of Installed products.
  2. Open the SQL Server Object Explorer view.  (It's in the View menu).
  3. Connect to your DB and drill down to the table you want to import to.
  4. Right click the table and select View Data.
  5. Now go into Excel and select the data you want to import and hit our good old friend, CTRL-C or Copy.
  6. 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 CTRL-V and paste all of the data into the new table.  Make sure the data fields line up.
  7. This will even work with IDENTITY columns.  Just make sure to have a column in Excel filled with zeros.
  8. That's it!  You might have to wait a while!
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.

Friday, May 27, 2016

Comparison and Review of .NET Fuzzy Matching Nuget Packages

I 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.

I first tried Fuzzy String.  Unfortunately, it has several issues 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.

Then I tried BlueSimilarity.  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.

Finally I tried SimMetrics-TextFunctions.  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!
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.

Now I am using some code from Stack Overflow.  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.

Monday, May 9, 2016

My Entity Framework Cheat Sheet

This is a list of tools I use to get generated code and get work done quickly with Entity Framework.

Generate Classes for Entity Framework Code-First from Database

  1. Prerequisite: An existing database
  2. Do one time:  Download Entity Framework 6 Tools for Visual Studio 2012 & 2013.
  3. Right click a project
  4. Add new item...
  5. Search for ADO, select ADO.NET Entity DataModel.
  6. Name it.
  7. Select Code First from database.
  8. Select / Create Database connection.
  9. Select tables you want to include.
  10. Finish
  11. Now you have models and a DbContext to work with.

Generate SQL/Database from a DbContext

  1. For the entities, create a models directory and create classes in it.
    1. If your primary key does not follow convention name, use the [Key] attribute.
    2. Create navigation properties for many to one relationships; create a property for the ID and the object.
    3. If your nav prop ID does not follow convention, use the [ForeignKey] attribute on the object.
    4. Other attributes to use: Required, MaxLength, Index, InverseProperty, Column (if you want your db column to have a different name), [Table("TableName", Schema = "SchemaName")]
  2. VIEW > Other > Package Manager Console.
  3. 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.
  4. If you are trying to recreate your database, make sure to drop the DB or change the connection string.  Also remove the Migrations folder.
  5. Make sure you have a DbContext file with:
    1. A good database connection string.
    2. Sub-classing DbContext
    3. public DbSet<Entity> Entities {get;set;}
  6. Type: Enable-Migrations
  7. Add-Migration MigrationName
  8. Update-Database -Script.  Save off the SQL if you want it.
  9. Update-Database.  Now your database tables are created.

Wednesday, March 30, 2016

Generate .NET MVC Views for a ViewModel

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?

I decided to see if I could fake out the scaffolding tool and I was able to!

Here's what you do:


  1. Make your POCO MyThingViewModel class.
  2. Make sure to have one property in the class annotated with [Key].
  3. Take some time to annotate your view model with attributes like:
    1. [StringLength(10)]
    2. [Required]
    3. [DataType(DataType.Date)]
    4. [Display(Name = @"Unit Type")]
    5. [DisplayFormat(DataFormatString = "{0:MM/dd/yyyy}", ApplyFormatInEditMode = true)]
    6. [Range(1,100)]
  4. Find your DbContext class and add a DbSet<MyThingViewModel>
  5. BUILD your solution.
  6. Now on the controllers folder, right click and "Add Scaffolded Item..."
  7. Choose MVC 5 Controller with views, using Entity Framework.
  8. Choose your DbContext, MyThingViewModel Class, and desired controller name like, MyThingsController.
  9. Click Finish
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!)

Now that you have your views:

  1. Remove the DbSet and Key attribute.
  2. Edit the controller to populate the View Model however you need to.
Enjoy the "free" views.


Alternate Option

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.