Skip to content

Instantly share code, notes, and snippets.

View MrAntix's full-sized avatar
🏠
Working from home

Anthony Johnston MrAntix

🏠
Working from home
View GitHub Profile
@MrAntix
MrAntix / Update-Antix.ps1
Created October 17, 2012 13:39
Update all Nuget Packages in a solution given the Id starts with "Antix."
# Put in the solution root and call with .\Update-Antix.ps1
$startingWith = "Antix."
$projects = Get-Project -All
$packagesFound = @()
foreach($project in $projects)
{
$path = Join-Path (Split-Path $project.FileName) packages.config
if(Test-Path $path)
@MrAntix
MrAntix / web.config
Last active May 22, 2019 10:38
Url rewrite to get rid of www. sub-domain, works on sub-sub-domains too
<?xml version="1.0" encoding="utf-8"?>
<configuration>
...
<system.webServer>
...
<rewrite>
...
<rules>
...
<rule name="Redirect from WWW" stopProcessing="true">
@MrAntix
MrAntix / form-loses-focus.htm
Last active January 1, 2016 07:49
callback when a form loses focus on all its inputs and links tab through the fields, as the form loses focus the callback sets the background to green here we check if the form is dirty (using https://github.com/snikch/jquery.dirtyforms) then we do a save
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>forms</title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script>
<style>
@MrAntix
MrAntix / Log.cs
Last active January 4, 2016 03:39
Abstract away your logger behind this Log.Delegate, only has two levels to show passing an exception, more levels easy enough. Easier than mocking ILogger in unit tests, no tie in to logging library
public static class Log
{
public const string MessageFormat = "{0:mm:ss:ffff} [{1}]: {2}";
public static readonly Delegate ToConsole
= l => (ex, f, a) =>
{
var m = string.Format(f, a);
Console.WriteLine(
MessageFormat, DateTime.UtcNow, l, m);
@MrAntix
MrAntix / test.html
Last active August 29, 2015 14:08
Determining my endian
<html>
<head>
<title>Testin</title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.1/angular.min.js"></script>
</head>
<body ng-app="app" ng-controller="AppController">
<input id="test" ng-model="dateInput" />
@MrAntix
MrAntix / DataTableNameConvention.cs
Last active August 29, 2015 14:12
I like my data models to have 'Data' as a suffix to make it easy to see that they are data models e.g. 'PersonData', but when I use EF this means that I get table names like 'UserDatas' or 'PersonDatas'. This EF Convention removes the Data suffix and still applies the pluralisation you expect
public class DataTableNameConvention :
Convention
{
public DataTableNameConvention(
IPluralizationService pluralizationService,
IDictionary<string, string> explicitNames)
{
Types().Configure(
c => c.ToTable(
GetName(c.ClrType, pluralizationService, explicitNames))
@MrAntix
MrAntix / index.html
Created January 7, 2015 00:09
angularjs cell layout // source http://jsbin.com/xeyife
<!DOCTYPE html>
<html ng-app="antix.cells">
<head>
<meta name="description" content="angularjs cell layout" />
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.2/angular.min.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
<style>
@MrAntix
MrAntix / antix.select.multiple,json
Last active April 27, 2017 17:01
AngularJS Multi Select (checkbox list)
// what the data looks like
// demo http://jsbin.com/yocolomife/1/edit?html,js,output
scope.things = [
{ id : 1, name: 'raindrows on roses' },
{ id : 2, name: 'wiskers on kittens' },
{ id : 3, name: 'brown paper packages tied up with strings' }
];
scope.myModel = {
@MrAntix
MrAntix / param-array-example-use.js
Last active August 29, 2015 14:22
js param array
var someFunction = function(text, moreThings) {
var moreThingsArray = paramArray(moreThings, arguments, 1);
// ... do stuff
};
someFunction('test with array', [new thing(), new thing()]);
someFunction('test with params', new thing(), new thing());
@MrAntix
MrAntix / CreateQRService.cs
Last active August 29, 2015 14:23
Use a service resolved from a DI container with Owin Middleware
public class CreateQRService :
ICreateQRService
{
readonly Log.Delegate _log;
byte[] _qr;
public CreateQRService(
Log.Delegate log)
{
_log = log;