Skip to content

Instantly share code, notes, and snippets.

Andy Conlisk AndyConlisk

  • Conlisk Consulting
  • Louisville, KY
View GitHub Profile
@AndyConlisk
AndyConlisk / generateUUID.js
Created Jun 14, 2017
generate a UUID / GUID in javascript
View generateUUID.js
function generateUUID() {
var d = new Date().getTime();
if (window.performance && typeof window.performance.now === "function") {
d += performance.now();; //use high-precision timer if available
}
var uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
var r = (d + Math.random() * 16) % 16 | 0;
d = Math.floor(d / 16);
return (c == 'x' ? r : (r & 0x3 | 0x8)).toString(16);
});
@AndyConlisk
AndyConlisk / Model1.cs
Created May 13, 2017
Example Entity Framework One to Many and Many to Many
View Model1.cs
namespace ComplexEntityFramework
{
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Data.Entity;
public class Model1 : DbContext
{
public Model1()
: base("name=Model1")
@AndyConlisk
AndyConlisk / FindRemoveDuplicates.sql
Created Mar 8, 2017
Finding and removing duplicate rows from database
View FindRemoveDuplicates.sql
-- SQL databate table dbo.Test with columns Id, FirstName, LastName, TransactionNumber, LastUpdatedDate
-- Select rows that are duplicates without using LastUpdatedDate
-- If needed can insert into a backup/archive table
SELECT t.Id, t.FirstName, t.LastName, t.TransactionNumber, t.LastUpdatedDate
FROM dbo.Test t
LEFT OUTER JOIN (
SELECT MIN(Id) as Id,
FirstName, LastName, TransactionNumber
FROM dbo.Test
@AndyConlisk
AndyConlisk / projectsetupdescription.txt
Created Mar 2, 2017
Description on setting up MVC web projects
View projectsetupdescription.txt
Application.Core
This namespace should contain all functionality that is not expansive enough to be in its own project but are required by multiple consumers/projects
- Logging and other cross access functions
- Generic helper classes for logging.
- Non-domain specific, independent functionality, and Profiling. Such as .NET Extension methods.
Application.Domain
This namespace contains the domain objects.
- Domain Objects (POCO), Shared data transfer objects, Models, ViewModels, etc
- Business logic for Validators, Filters, Factories, Regular expressions
Application.Data
View gist:dd539a1ebff2d6b3bd0bb32f3007d0a6
### Keybase proof
I hereby claim:
* I am andyconlisk on github.
* I am kingpancake (https://keybase.io/kingpancake) on keybase.
* I have a public key ASALMMqf4SM6CNyfc95F_w2_aYcKnvvdEA9bENXjbTLrlAo
To claim this, I am signing this object:
@AndyConlisk
AndyConlisk / combinemultiplerowintoone.sql
Created Sep 20, 2016
SQL select statement to combine multiple row vales into one field
View combinemultiplerowintoone.sql
SELECT p.Name, substring
((SELECT ', ' + k.Number FROM dbo.Keys k
JOIN dbo.Keys_Assignments ka ON ka.KeyID = k.KeyID
WHERE ka.PersonID = p.PersonID
FOR XML PATH('')), 2, 1000) [Keys]
FROM dbo.People p
SELECT k.Number, SUBSTRING
((SELECT '; ' + p.Name FROM dbo.People p
@AndyConlisk
AndyConlisk / sql_findTableUsageInStoredProc
Last active Aug 29, 2015
SQL statment to find all instances of utility in stored procs
View sql_findTableUsageInStoredProc
SELECT DISTINCT so.name FROM syscomments sc INNER JOIN sysobjects so on sc.id=so.id WHERE sc.text LIKE '%utility%'
@AndyConlisk
AndyConlisk / ProductRandomImage.sql
Created Jan 5, 2015
SQL to get a random image from a product of the product category
View ProductRandomImage.sql
SELECT b.Id AS BusinessId, COALESCE(subCategoryImage.Id, parentCategoryImage.Id) AS ImageAssetId, COALESCE(subCategoryImage.CategoryId, parentCategoryImage.CategoryId) AS CategoryId, b.Name, COALESCE(subCategoryImage.FileName, parentCategoryImage.FileName) AS FileName
FROM Businesses b
OUTER APPLY (
SELECT TOP 1 *
FROM ImageAssets
WHERE CategoryId = b.CategoryId
AND Deleted = 0
ORDER BY CHECKSUM(NEWID(), b.id) & 2147483647
) subCategoryImage
OUTER APPLY (
@AndyConlisk
AndyConlisk / Background.cs
Created Jan 3, 2015
Simple Background Tasks for ASP.NET
View Background.cs
//Easy Background tasks in ASP.NET projects
//Inspiration from http://blog.stackoverflow.com/2008/07/easy-background-tasks-in-aspnet/
//This code is added into the Global.asax file. In the Application_Start() method
private static CacheItemRemovedCallback OnCacheRemove = null;
protected void Application_start()
{
//The register code that is put in here
//Here is where you add all the tasks you want to start on application start
You can’t perform that action at this time.