Skip to content

Instantly share code, notes, and snippets.

View alexdresko's full-sized avatar
💭
I'm not a player, I just code a lot.

Alex Dresko alexdresko

💭
I'm not a player, I just code a lot.
View GitHub Profile
javascript:
var asdf = (window.getSelection && window.getSelection().toString()) || null;
if (!asdf || asdf === "") {
try {
asdf = document.getElementsByClassName('gh-header-title')[0].innerText
} catch (e) {}
}
if (!asdf) {
asdf = prompt("Enter the title");
@alexdresko
alexdresko / app.html
Last active November 20, 2017 21:45 — forked from jdanyow/app.html
Aurelia Validation Demo
<template>
<require from="./registration-form"></require>
<registration-form></registration-form>
</template>
public static IWebHost BuildWebHost(string[] args)
{
var config = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json");
return WebHost.CreateDefaultBuilder(args)
.ConfigureAppConfiguration((context, builder) => {
builder.AddEntityFrameworkConfig(options => options.UseSqlServer(config.GetConnectionString("DefaultConnection")));
});
# Issue Description
{Give a detailed description of the bug. Explain what occurred and the reasons the behavior is incorrect.}
# Steps to Reproduce.
1. X
1. Y
1. Z
# Expected Result:
{Concisely state the proper result. This should be no more than two sentences.}
public override int SaveChanges()
{
ModifyBaseEntity();
return base.SaveChanges();
}
private void ModifyBaseEntity()
{
@alexdresko
alexdresko / tfsonlinekeyboardshortcuts.user.js
Last active August 29, 2015 14:07
Additional TFS online keyboard shortcuts ala TamperMonkey/GreaseMonkey
// ==UserScript==
// @name TFS online shortcuts
// @author Alex Dresko
// @namespace http://www.alexdresko.com
// @version 0.5
// @description Some additional shortcuts for TFS online
// @match https://*.visualstudio.com/*
// @copyright 2014+, Alex Dresko
// @require 'http://code.jquery.com/jquery-1.11.1.min.js'
// @updateURL 'https://gist.githubusercontent.com/alexdresko/1ebd8ff2b1db2fe66c85/raw/tfsonlinekeyboardshortcuts.user.js'
@alexdresko
alexdresko / gist:5b3075d12a9b5abebb4c
Last active August 29, 2015 14:04
Create POCO and CsvHelper map classes from pipe delimited file.linq
void Main()
{
var dir = @"C:\temp\OptumFtp\Root\Extracted\";
foreach (var file in Directory.GetFiles(dir, "*.txt"))
{
var header = File.ReadAllLines(file)[0];
var map = Regex.Replace(header, @"([^|]*).", @"Map(m => m.$1).Name(""$1"");
");
var properties = Regex.Replace(header, @"([^|]*).", @"public string $1 { get; set; }
");
@alexdresko
alexdresko / AccountController Login POST action
Created July 31, 2014 10:51
Identity v2 Login with email confirmation and 2FA support
var user = await UserManager.FindByNameAsync(model.UserName);
if (user != null)
{
if (!await UserManager.IsEmailConfirmedAsync(user.Id)) return View(Mvc.Account.Views.ErrorNotConfirmed);
}
//var result = await SignInManager.PasswordSignInAsync(model.UserName, model.Password, model.RememberMe, shouldLockout: true);
var result = await SignInManager.SignInAsync(model.UserName, model.Password, model.RememberMe);
var stringToCache = "tada!!!";
var absoluteExpirationForCache =
DateTime.Now.AddSeconds(10);
var yeResult = (string) MemoryCache.Default
.AddOrGetExisting
("AnyOleKey", stringToCache, absoluteExpirationForCache);
@alexdresko
alexdresko / soundy.js
Created March 25, 2014 03:19
Greasemonkey/tampermonkey script that plays a sound whenever a matched page is finished loading.
// ==UserScript==
// @name Soundy
// @namespace http://www.alexdresko.com/
// @version 0.1
// @description Plays some kind of noise whenever a matched page finishes loading
// @match https://localhost:44300/*
// @match https://gist.github.com/*
// @copyright 2014+, Alex Dresko
// ==/UserScript==