Posts

Showing posts from 2018

Complete Project Gutenberg Catalog in JSON

Image
Project Gutenberg is an amazing site containing over 57,000 free ebooks at the time of this writing.



Recently I've been working on a project to create a database of book bibliographies. A database of book references from within other books. You'd be able to answer the query: Show me all the books that reference "Thinking Fast and Slow". I plan to use Project Gutenberg as the repository that I use to create the first version of this database.

Project Gutenberg currently makes their complete project catalog available as a collection of RDF files found here: http://www.gutenberg.org/wiki/Gutenberg:Feeds

RDF is not something I've worked with in the past, so I converted them to JSON files. You can download that set of files from here:

https://sfp.blob.core.windows.net/public/gutenberg_catalog.zip


Hope this helps,
Aaron





ASP.NET Core 2.1 Identity

Image
I thought I'd compile some resources on ASP.NET Core 2.1 Identity. Hope you find these useful:

Database schema of tables that are generated after the first EF Migration:

https://gist.github.com/aaronhoffman/74f4c072afaa0459dcd6595b6380f67d


You can override password rules in the Startup.cs class:

            services.AddDefaultIdentity()
                .AddEntityFrameworkStores();

            services.Configure(options =>
            {
                options.Password.RequireDigit = false;
                options.Password.RequireLowercase = false;
                options.Password.RequireUppercase = false;
                options.Password.RequireNonAlphanumeric = false;
            });


If you are wondering where the AccountController or login pages are (because they do not appear in the solution explorer by default) more info can be found here: https://docs.microsoft.com/en-us/aspnet/core/security/authentication/scaffold-identity?view=aspnetcore-2.1&tabs=visual-studio



That's it fo…

Programmatically add Other Search Engines to Google Chrome for VSTS Shortcuts

Image
When I'm working with a new repo/project in VSTS, I like to set up shortcuts in Google Chrome to be able to quickly jump to a specific Work Item, PR, Build, or Release based on the ID.

To do this, I take advantage of Chrome's "other search engines" settings.

You can manually add these by specifying a Short Name, a Keyword, and the URL to navigate to when that keyword is typed into the browser's address bar.

Until now, I would manually add these URLs one at a time, but being a lazy developer, I wanted a way to automate this process. I discovered that Chrome uses a SQLite database to store these values, and you can side-load new entries by simply performing a SQL Insert into the `keywords` table of that SQLite database!



You can use the following SQL Script to insert the default set of shortcuts I usually add for each new VSTS project/repo:

https://gist.github.com/aaronhoffman/60660365310b7ff462b547fea9eb605b



Steps to Add:

 1. Ensure all instances of Google Chrome are…

Location of SqlPackage.exe on VSTS and Azure

Image
If you're looking to deploy a Visual StudioDatabase Project via VSTS to Azure, you can use the Azure SQL Database Deployment Release Task to include the deployment in your CI/CD process.

When a .dbproj builds, it creates a .dacpac file that contains the database definition/schema. The DB Deployment Release Task uses the SqlPackage.exe executable to deploy/sync the target database with the definitions in the dacpac file.

SqlPackage.exe can do more than just `publish`. However, at this time, the publish action is the only action supported by that release task.

If you'd like to perform other actions (e.g. `DeployReport` or `Script`), you can call the SqlPackage.exe directly using a PowerShell Script Release Task. However, to do that, you'll need to know the location of the SqlPackage.exe on the VSTS host, because it is not available in the PATH by default.

To find the location of SqlPackage.exe, the Azure SQL DB Deploy task uses this utility script: https://github.com/Microso…

Sync Github Gists with Git Repo

Image
I needed an easy way to sync github gists to my local machines and I couldn't find anything provided by gist, or any other open source projects out there so I put this little node app together quick.

Simply clone this repo and update the `users.json` file to sync all the associated public gists to your local machine.

https://github.com/aaronhoffman/gists


The node app uses the gists api and `git clone`s each gist into a folder with the same name as it's id:




Hope this helps!
Aaron

Use Azure Functions to Execute a SQL Azure Stored Procedure on a Timer

Image
It was hard to find this information all in one place, so I thought I'd throw a post together quick.

If you have the need to execute a stored procedure on a timer, that can be fairly easily accomplished with Azure Functions.

Create a new Timer Trigger Azure Function, set the cron timer as desired, and add code similar to the code below:

using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using Dapper;

public static void Run(TimerInfo myTimer, TraceWriter log)
{
    var conString = ConfigurationManager.ConnectionStrings["ConString"]?.ConnectionString;

    using(var con = new SqlConnection(conString))
    {
        con.Execute("dbo.MyProc", commandType: CommandType.StoredProcedure);
    }
}


This code will not compile at this time. Note the name of the connection string, we'll need that in the app settings page.

Go to the Connection Strings section of the Application Settings for the function app (this will look very similar to the Con…

Create Google Contact via API and Add To My Contacts System Group

Image
When you create a new Contact via the Google Contacts API, by default it will not appear in the list of contacts on the Google Contacts webpage, however, if you search for the contact there, it will appear. If you then click the "Add to contacts" button, it will appear in that contacts list, and increase your contact count in the top left of the page.




There is a way to add new contacts via the API and have them show up in this list, it is just not well documented within the API documentation. The code below demonstrates how to do this is C#.

What appears to be a list of all contacts on the Google Contacts page is actually just a subset of all your contacts, it is actually the "My Contacts" System Group. When you create a new contact via the API, you must specify that this new contact is part of that system group for it to appear on the contacts page without searching.

Steps:
 1. Create a ContactsRequest
 2. Get a list of all groups and search for the "My Conta…