Skip to content

Instantly share code, notes, and snippets.

View billgeek's full-sized avatar

William Mitchell billgeek

View GitHub Profile
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.56/pdfmake.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.56/vfs_fonts.js"></script>
</head>
<body>
<script type="text/javascript">
function downloadPdf() {
var docDefinition = {
@billgeek
billgeek / CopySongsToClipboard.js
Last active March 4, 2019 12:12
Get Songs from a Google Play Music playlist
var copyToClipboard = function(strToCopy) {
var el = document.createElement('textarea');
el.value = strToCopy;
document.body.appendChild(el);
el.select();
document.execCommand('copy');
document.body.removeChild(el);
}
var getCurrentPl = function() {
@billgeek
billgeek / -EF6 Fluent API and Reflection in VBNet.md
Last active February 22, 2018 16:51
Creating Entity Framework 6 Fluent API Models using Reflection (VB.NET)

Using Reflection and Fluent API to create EF6 Models (VB.NET)

Below is an example of how to use reflection and Fluent API to define the models for your DbContext. (This is a VB.NET version of my previous GIST)

Objective

To contain the definition and initialization of a model in a single file and to seperate initialization out of the main context file.

IEntityBuilder.cs

The interface "IEntityBuilder" is primarily used to identify the models that are to be built

User.cs

@billgeek
billgeek / -Generic Repository Pattern in VBNet.md
Last active December 1, 2023 11:13
Generic Repository Pattern in VB.NET

Creating a Generic Repository Pattern (VB.NET)

The below example shows how to implement a Repository of objects in a generic fashion. (This is the VB.NET version of my previous GIST) This was adapted and simplified from this article: https://code.msdn.microsoft.com/generic-repository-pattern-ddea2262

Overview

The point of this code is to allow the generic access to any object type in the datastore without the need to define a repository for each object. It is important to note that, although the below examples should work as is, it is recommended to make use of a dependency injection framework as database connection limits are not considered.

Overview

The below sample will demonstrate how to implement an HTTP interceptor in Angular 5 as well as append authorization tokens where neccessary. (This was built in Angular 4 originally and was not modified when upgrading, so it should still work with Angular 4)

To make a call including an auth token, simply pass "true" as the last argument.

Note that the "app-loader-indicator" needs to be the last element on the app component markup to ensure it's always visible and always "on top". The loader service and loader indicator component can be enhanced to make use of Observables, though for my project it was not required.

Lastly the loader indicator is simply the font awesome "fa-spin" class as per the example on the Font Awesome homepage.

@billgeek
billgeek / -Generic Repository Pattern in CSharp.md
Last active February 17, 2018 19:22
Generic Repository pattern

Creating a Generic Repository Pattern

The below example shows how to implement a Repository of objects in a generic fashion. This was adapted and simplified from this article: https://code.msdn.microsoft.com/generic-repository-pattern-ddea2262

Overview

The point of this code is to allow the generic access to any object type in the datastore without the need to define a repository for each object. It is important to note that, although the below examples should work as is, it is recommended to make use of a dependency injection framework as database connection limits are not considered.

@billgeek
billgeek / EF6 Fluent API and Reflection.md
Last active February 17, 2018 19:17
Creating Entity Framework 6 Fluent API Models using Reflection

Using Reflection and Fluent API to create EF6 Models

Below is an example of how to use reflection and Fluent API to define the models for your DbContext.

Objective

To contain the definition and initialization of a model in a single file and to seperate initialization out of the main context file.

IEntityBuilder.cs

The interface "IEntityBuilder" is primarily used to identify the models that are to be built

User.cs