Skip to content

Instantly share code, notes, and snippets.

View tathamoddie's full-sized avatar

Tatham Oddie tathamoddie

View GitHub Profile
@tathamoddie
tathamoddie / DOCO.md
Last active August 29, 2015 13:56
Change all ng- attributes to data-ng- instead

So, you built an AngularJS app.

You used ng- attributes everywhere, and now your W3C validation is failing.

You wish you had used data-ng- instead.

This script will fix them all for you.

.\Fix-AllAngularAttributesForHtml5.ps1 c:\code\myapp\web\Views -TfvcAware -Verbose -PrefixesToQuality @('ng', 'app')
@tathamoddie
tathamoddie / gist:9927848
Created April 2, 2014 04:17
Workaround visual bug with Windows Phone when you change themes, and then fast app switch back
void WorkaroundThemeResumeBugInWindowsPhone()
{
var backgroundColor = (Color)Application.Resources["PhoneBackgroundColor"];
var chromeColor = (Color)Application.Resources["PhoneChromeColor"];
var foregroundColor = (Color)Application.Resources["PhoneForegroundColor"];
RootFrame.Navigated += (sender, args) =>
{
SystemTray.BackgroundColor = backgroundColor;
SystemTray.ForegroundColor = foregroundColor;
@tathamoddie
tathamoddie / gist:b35a8f43e81a1cfd2383
Created June 19, 2014 05:39
window.clockSync.clientTimeAheadOfServerInMilliseconds
<script src="~/Scripts/moment.min.js"></script>
<script>
(function() {
var clientNow = moment();
var serverNow = moment('@(DateTimeOffset.UtcNow.ToString("o"))');
var diff = clientNow.diff(serverNow);
if (!!window.performance && !!window.performance.timing) {
var responseStartToNow = new Date().valueOf() - window.performance.timing.responseStart;
diff -= responseStartToNow;
}
@tathamoddie
tathamoddie / Home.aspx
Created March 29, 2010 23:16
Tixi homepage teaser
<%@ Page Language="C#" MasterPageFile="~/tixi/Masters/Default.Master" AutoEventWireup="true" CodeBehind="Home.aspx.cs" Inherits="FuelAdvance.Galapagos.WebUI.tixi.Home" EnableViewState="False" Title="" %>
<%@ Register TagPrefix="tixi" TagName="Step1" Src="~/Components/GettingStarted/Step1/Step1Control.ascx" %>
<asp:Content ContentPlaceHolderID="NoFormPlaceHolder" runat="server">
<div id="homepage-content">
<div id="signup-teaser">
<div class="image-panel">
<span class="images">
<img runat="server"
src="~/App_Themes/Default/Assets/HomepagePanelTrackDay.jpg"
alt="Revving up a day on the track?"
@tathamoddie
tathamoddie / AccountsDashboard.aspx
Created April 13, 2010 00:13
Example of nested presenters with Web Forms MVP
<%@ Register Src="~/Controls/AccountsDashboard.ascx" TagPrefix="app" TagName="dashboard" %>
<app:Dashboard runat="server" />
@tathamoddie
tathamoddie / gist:371001
Created April 19, 2010 12:43
Enumerable.SetEqual<T> extension
/// <summary>
/// An order independent version of <see cref="Enumerable.SequenceEqual{TSource}(System.Collections.Generic.IEnumerable{TSource},System.Collections.Generic.IEnumerable{TSource})"/>.
/// </summary>
internal static bool SetEqual<T>(this IEnumerable<T> x, IEnumerable<T> y)
{
if (x == null) throw new ArgumentNullException("x");
if (y == null) throw new ArgumentNullException("y");
var objectsInX = x.ToList();
var objectsInY = y.ToList();
@tathamoddie
tathamoddie / Merge-Assets.cmd
Created June 21, 2010 01:03
Web asset merging with PowerShell
@echo off
setlocal
set tempscript=%temp%\%~n0.%random%.ps1
echo $ErrorActionPreference="Stop" >"%tempscript%"
echo ^& "%~dpn0.ps1" %* >>"%tempscript%"
powershell.exe -command "& \"%tempscript%\""
set errlvl=%ERRORLEVEL%
del "%tempscript%"
exit /b %errlvl%
@tathamoddie
tathamoddie / Publish-Version.ps1
Created June 22, 2010 04:54
Copies /Static/Base/ to /Static/v1234/ where 1234 is derived from the TFS version number
#requires -Version 2
[CmdletBinding()]
param (
$VersionIdentifier
)
$ErrorActionPreference = "Stop"
Set-PSDebug -Strict
$PSScriptFilePath = (Get-Item $MyInvocation.MyCommand.Path).FullName
namespace TechList
{
[TestFixture]
public class Luke
{
class DemoObject
{
public string GroupId { get; set; }
public int GroupCount { get; set; }
}
void Test()
{
new UnitOfWork()
.AddWork(SomeMethod, 123.5)
.AddWork(SomeOtherMethod, "hello", 123);
}
void SomeMethod(double something)
{