Skip to content

Instantly share code, notes, and snippets.

View lukencode's full-sized avatar
🙃

Luke Lowrey lukencode

🙃
View GitHub Profile
@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 / 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 / CacheExtensions.cs
Created December 1, 2014 00:50
CacheExtensions
public static class CacheExtensions
{
static object sync = new object();
/// <summary>
/// Executes a method and stores the result in cache using the given cache key. If the data already exists in cache, it returns the data
/// and doesn't execute the method. Thread safe, although the method parameter isn't guaranteed to be thread safe.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="cache"></param>
@lukencode
lukencode / boxstarter.ps1
Last active August 29, 2015 14:08
Boxstarter
#####################
# BEGIN CONFIGURATION
#####################
# Boxstarter options
$Boxstarter.RebootOk=$true # Allow reboots?
$Boxstarter.NoPassword=$false # Is this a machine with no login password?
$Boxstarter.AutoLogin=$true # Save my password securely and auto-login after a reboot
#region Initial Windows Config
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>
@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;