Skip to content

Instantly share code, notes, and snippets.

🏄
...

John Leidegren leidegre

🏄
...
Block or report user

Report or block leidegre

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@leidegre
leidegre / tundra.lua
Created Apr 20, 2019
Implicit build units with Tundra
View tundra.lua
local msvc_common = {
{"/MDd", Config = "*-msvc-debug-*"},
--Unicode
"/DUNICODE",
"/D_UNICODE",
"/D_CRT_SECURE_NO_WARNINGS",
"/D_WINSOCK_DEPRECATED_NO_WARNINGS",
"/W4",
--treat as error
"/we4701", --Potentially uninitialized local variable 'name' used
View gen-base32-id.js
function genBase32Id() {
// Math.pow(2, 40): 1099511627776
const x = Math.floor(Math.random() * 1099511627776).toString(32) // 40 bits
// padding
switch (x.length) {
case 8:
return x
case 7:
return "0" + x
case 6:
@leidegre
leidegre / channel-test.js
Created Aug 21, 2018
Go channel abstraction for JavaScript
View channel-test.js
const { default: Channel } = require("./channel");
const timeout = 100;
async function unbuffered() {
const xs = [];
var ch = new Channel();
xs.push("start");
setTimeout(async () => {
xs.push("timeout");
View main.go
package main
func main() {
println([]int{})
}
@leidegre
leidegre / local.settings.json
Created Jun 13, 2018
Useful defaults for local.settings.json (Azure Function App)
View local.settings.json
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"AzureWebJobsDashboard": "UseDevelopmentStorage=true"
}
}
@leidegre
leidegre / EventSourcing.cs
Created Feb 11, 2018
An event sourcing example minus the cruft to illustrate basic principles of an event store
View EventSourcing.cs
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 Jan 20, 2018
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
View CSVParser.cs
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 Feb 26, 2017
CL command line, typical warnings to enable
View gist:0cd84189897a6539b073d0782edfa3f3
"/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 Sep 12, 2016
Generate additional types for our entity system
View main.go
package main
import (
"bytes"
"fmt"
"go/ast"
"go/build"
"go/parser"
"go/token"
"io/ioutil"
@leidegre
leidegre / main.go
Created Sep 12, 2016
Create a LISP like representation from a Go AST
View main.go
package main
import (
"bytes"
"flag"
"fmt"
"go/ast"
"go/parser"
"go/token"
"log"
You can’t perform that action at this time.