Skip to content

Instantly share code, notes, and snippets.

View schourode's full-sized avatar

Jørn Schou Sandager schourode

  • Copenhagen, Denmark
View GitHub Profile
@schourode
schourode / dynamodb_capacity_report.py
Created May 20, 2020 09:25
List provisioned and consumed capacity for all DynamoDB tables
# Usage: python3 dynamodb_capacity_report.py 2020-04-01 2020-05-01
import csv
import sys
from datetime import datetime
import boto3
cloudwatch = boto3.client('cloudwatch')
@schourode
schourode / SynchronizedCronJob.cs
Last active May 30, 2019 18:16
Provides a base class for NCron jobs which are not allowed to be executed in parallel.
namespace NCron
{
public abstract class SynchronizedCronJob<TJob> : CronJob where TJob : SynchronizedCronJob<TJob>
{
private static readonly object SyncRoot = new object();
private static bool IsRunning = false;
public override void Execute()
{
var runNow = false;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Autofac;
using Rebus;
using Rebus.Bus;
using Rebus.Configuration;
namespace Rebus.Autofac
@schourode
schourode / BinaryGuidType.cs
Created July 9, 2012 11:26
NHibernate user type for storing sequential GUIDs as BINARY(16) with minimum fragmentation
using System;
using System.Data;
using NHibernate;
using NHibernate.SqlTypes;
using NHibernate.UserTypes;
public class BinaryGuidType : IUserType
{
private static readonly int[] ByteOrder = new[] { 10,11,12,13,14,15,8,9,6,7,4,5,0,1,2,3 };
private static readonly SqlType[] Types = new[] { new SqlType(DbType.Binary) };
@schourode
schourode / DisplayNameHelper.cs
Created July 22, 2011 08:14 — forked from dalager/DisplayNameHelper.cs
GetDisplayNameFor<MyType>(x=>x.MyProperty);
public class DisplayNameHelper
{
/// <summary>
/// Get the DataAnnotation attributed DisplayName attribute value.
/// </summary>
/// <example>
/// GetDisplayNameFor&lt;VagtTyper&gt;(x =&gt; x.Doegnvagt) ==&gt; "Døgnvagt"
/// </example>
/// <typeparam name="TSource">The type you wish to work on</typeparam>
/// <typeparam name="TProp">The type of the property</typeparam>
// Or if you use binding by parameter, don't do anything at all :-)
public ActionResult Create(Bar bar)
{
if (ModelState.IsValid)
{
// Do something;
}
// Do something else;
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Stretched image in background</title>
<style type="text/css">
body, html { margin: 0; padding: 0 }
img { position:absolute; z-index:-1; width:100%; height:100% }
</style>
</head>
<body>
/*
(c) 2008, Joern Schou-Rode <jsr@malamute.dk>
This work ‘as-is’ we provide.
No warranty, express or implied.
We’ve done our best,
to debug and test.
Liability for damages denied.
Permission is granted hereby,