Skip to content

Instantly share code, notes, and snippets.

View lukencode's full-sized avatar
🙃

Luke Lowrey lukencode

🙃
View GitHub Profile
@lukencode
lukencode / DbUp.cs
Created April 8, 2013 23:27
DbUp program with dodgy hack to create db if it doesnt exist - good for developing.
public class Program
{
/// <summary>
/// Entry point.
/// </summary>
/// <param name="args">The args.</param>
/// <returns></returns>
static int Main(string[] args)
{
var rawConnectionString = ConfigurationManager.ConnectionStrings["db"].ConnectionString;
@lukencode
lukencode / sql.json
Created August 18, 2020 06:08
Azure Data Studio - User snippets
{
// Place your snippets for sql here. Each snippet is defined under a snippet name and has a prefix, body and
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the
// same ids are connected.
// Example:
// "Print to console": {
// "prefix": "log",
// "body": [
// "console.log('$1');",
@lukencode
lukencode / widget.js
Last active December 7, 2021 19:16
Starter template for creating jsonp embeddable widgets.
(function () {
var scriptName = "embed.js"; //name of this script, used to get reference to own tag
var jQuery; //noconflict reference to jquery
var jqueryPath = "http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js";
var jqueryVersion = "1.8.3";
var scriptTag; //reference to the html script tag
/******** Get reference to self (scriptTag) *********/
var allScripts = document.getElementsByTagName('script');
@lukencode
lukencode / Startup.cs
Created July 2, 2018 10:25
FluentEmail dependency injection
public void ConfigureServices(IServiceCollection services)
{
services
.AddFluentEmail("defaultsender@test.test")
.AddRazorRenderer()
.AddSmtpSender("localhost", 25);
}
@lukencode
lukencode / HomPageService.cs
Last active May 20, 2018 23:45
LazyCache Example
public class HomePageService
{
public static string HomeModelCacheKey = "HomeModel";
private static TimeSpan cacheExpiry = new TimeSpan(12, 0, 0); //12 hours
private readonly PositionsGroupedByTagQuery positionsGroupedByTagQuery;
private readonly IAppCache cache;
public HomePageService(PositionsGroupedByTagQuery positionsGroupedByTagQuery, IAppCache cache)
{
const path = require('path')
const webpack = require('webpack')
const ExtractTextPlugin = require('extract-text-webpack-plugin')
const outputDir = './wwwroot/dist'
const entry = './wwwroot/js/app.js'
const cssOutput = 'site.css'
module.exports = (env) => {
return [{
{
"name": "austechjobs",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"dev": "cross-env ASPNETCORE_ENVIRONMENT=Development NODE_ENV=development dotnet run",
"watch": "webpack --watch --mode=development",
"build": "webpack --mode=production --optimize-minimize",
@lukencode
lukencode / StringExtensions.cs
Created August 18, 2010 12:34
C# String extension methods
public static class StringExtensions
{
/// Like linq take - takes the first x characters
public static string Take(this string theString, int count, bool ellipsis = false)
{
int lengthToTake = Math.Min(count, theString.Length);
var cutDownString = theString.Substring(0, lengthToTake);
if (ellipsis && lengthToTake < theString.Length)
cutDownString += "...";
public class DataMockHelpers
{
public Mock<IQeraUnit> GetMockUnit()
{
var unit = new Mock<IQeraUnit>();
return unit;
}
public Mock<TRepo> MockRepo<TRepo, TEntity>(List<TEntity> seedData = null, bool callBase = false, MockBehavior behavior = MockBehavior.Default)
where TRepo : class, IRepo<TEntity>
@lukencode
lukencode / embeddedtemplate.cs
Created May 21, 2013 06:27
Embedded tempate
/// <summary>
/// Adds template to email from embedded resource
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="path">Path the the embedded resource eg [YourAssembly].[YourResourceFolder].[YourFilename.txt]</param>
/// <param name="model">Model for the template</param>
/// <param name="isHtml">True if Body is HTML, false for plain text (Optional)</param>
/// <param name="assembly">The assembly your resource is in. Defaults to calling assembly.</param>
/// <returns></returns>