Skip to content

Instantly share code, notes, and snippets.

View glaidler's full-sized avatar

Graham Laidler glaidler

View GitHub Profile
@glaidler
glaidler / gist:0381a9fbae54c2e30c088197f1809e0c
Last active March 17, 2025 08:15 — forked from pitch-gist/gist:2999707
HTML: Simple Maintenance Page
<!doctype html>
<title>Site Maintenance</title>
<style>
body { text-align: center; padding: 150px; }
h1 { font-size: 50px; }
body { font: 20px Helvetica, sans-serif; color: #333; }
article { display: block; text-align: left; width: 650px; margin: 0 auto; }
a { color: #dc8100; text-decoration: none; }
a:hover { color: #333; text-decoration: none; }
</style>
@glaidler
glaidler / sample.cs
Last active May 26, 2022 15:17
decimal-split
using System;
using System.Collections.Generic;
using System.Linq;
public class Program
{
// from https://stackoverflow.com/questions/67067274/how-to-divide-a-decimal-number-into-rounded-parts-that-add-up-to-the-original-nu
public static IEnumerable<decimal> RoundedDivide(decimal amount, int count)
{
int totalCents = (int)Math.Floor(100 * amount);
// work out the true division, integer portion and error values
@glaidler
glaidler / MyApp.csproj
Last active September 9, 2021 13:56 — forked from gistlyn/MyApp.csproj
OrmLite Tour
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<NoWarn>1591</NoWarn>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="ServiceStack.OrmLite.Sqlite" Version="5.*" />
@glaidler
glaidler / main.cs
Last active September 9, 2021 13:53 — forked from gistlyn/main.cs
Simple OrmLite CRUD demo
using System;
using System.Collections.Generic;
using ServiceStack;
using ServiceStack.Text;
using ServiceStack.OrmLite;
using ServiceStack.OrmLite.Sqlite;
using ServiceStack.DataAnnotations;
public class User
{
@glaidler
glaidler / main.cs
Last active September 8, 2017 14:52
RedisSerializationTest
using System;
using ServiceStack;
using ServiceStack.Text;
using ServiceStack.Redis;
using ServiceStack.DataAnnotations;
var redisManager = new RedisManagerPool("localhost:6379");
var redis = redisManager.GetClient();
@glaidler
glaidler / main.cs
Created November 4, 2016 14:04 — forked from mythz/main.cs
Insert Id in AutoIncrement PK at runtime
using ServiceStack;
using ServiceStack.Logging;
using ServiceStack.Text;
using ServiceStack.OrmLite;
using ServiceStack.OrmLite.Sqlite;
using ServiceStack.DataAnnotations;
LogManager.LogFactory = new ConsoleLogFactory();
var dbFactory = new OrmLiteConnectionFactory(":memory:", SqliteDialect.Provider);
var db = dbFactory.Open(); // Open ADO.NET DB Connection