Skip to content

Instantly share code, notes, and snippets.

View leidegre's full-sized avatar

John Leidegren leidegre

View GitHub Profile
@leidegre
leidegre / local.settings.json
Created June 13, 2018 06:36
Useful defaults for local.settings.json (Azure Function App)
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"AzureWebJobsDashboard": "UseDevelopmentStorage=true"
}
}
@leidegre
leidegre / EventSourcing.cs
Created February 11, 2018 18:17
An event sourcing example minus the cruft to illustrate basic principles of an event store
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
namespace EventSourcingExample
{
struct Event
{
@leidegre
leidegre / CSVParser.cs
Created January 20, 2018 13:56
CSV parser, compliant with RFC4180 can be customized to do new line normalization and does handle new line in quoted string literal without reading all text up front
static class CSV
{
public struct Record
{
public readonly string[] Row;
public string this[int index] => Row[index];
public Record(string[] row)
{
@leidegre
leidegre / gist:0cd84189897a6539b073d0782edfa3f3
Created February 26, 2017 16:32
CL command line, typical warnings to enable
"/MDd",
"/Zi",
"/FS",
"/W4", // warning level 4
"/we4013", // undefined; assuming extern returning int
"/we4020", // different types for formal and actual parameter
"/we4024", // too many actual parameters
"/we4047", // differs in levels of indirection
"/we4244", // 'conversion' conversion from 'type1' to 'type2', possible loss of data
// "/we4456", // declaration of '...' hides previous local declaration (issue with glew.c)
@leidegre
leidegre / main.go
Created September 12, 2016 19:40
Generate additional types for our entity system
package main
import (
"bytes"
"fmt"
"go/ast"
"go/build"
"go/parser"
"go/token"
"io/ioutil"
@leidegre
leidegre / main.go
Created September 12, 2016 12:52
Create a LISP like representation from a Go AST
package main
import (
"bytes"
"flag"
"fmt"
"go/ast"
"go/parser"
"go/token"
"log"
@leidegre
leidegre / index.js
Created June 15, 2016 08:20
Figure out what casing various Unicode code points are mapped to by javascript
// This program only mapps the Latin-1 and Latin-1 Supplement code range but can be extended to support anything
function mkInterval(a) {
return [a[0], a[1], a[1] - a[0]]
}
function adj(a, b) {
return (a[0] + 1 == b[0])
&& (a[1] + 1 == b[1])
&& (a[2] == b[2])
@leidegre
leidegre / BindablePasswordBox.cs
Created September 23, 2015 14:02
Represents a way to bind to the password property while still being able to use the default PasswordBox
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
public class BindablePasswordBox : ContentControl
{
private static void OnPasswordPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var bindablePasswordBox = (BindablePasswordBox)d;
bindablePasswordBox.OnPasswordPropertyChanged((string)e.OldValue, (string)e.NewValue);
@leidegre
leidegre / StackMachineTreeConstruction
Created June 6, 2015 20:04
An example of how to do syntax tree construction without using return values
using System;
using System.Collections.Generic;
using System.Text;
namespace StackMachineTreeConstruction
{
public class Class1
{
enum TokenType
{
void Dummy()
{
// so that we have at least one object file
}