Skip to content

Instantly share code, notes, and snippets.

Philip Jander janderit

  • Wunder Mobility, Jander.IT
  • Hamburg, Germany
Block or report user

Report or block janderit

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
@janderit
janderit / OptionExtension.fs
Created Aug 26, 2015
Option evaluation operator for F#
View OptionExtension.fs
type OptionDefault<'a> =
| Default of 'a
| Lazy of (unit->'a)
| Expected of reason:string
let (|.) (opt:'a option) (def:OptionDefault<'a>) : 'a =
match opt with
| Some (v) -> v
| None ->
match def with
@janderit
janderit / F# Game of life
Created Jun 17, 2015
Concise F# version of Conway's Game of Life
View F# Game of life
(*
F# Game of life
Philip Jander
@ph_j
2015
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
https://creativecommons.org/licenses/by-nc-sa/3.0/
*)
@janderit
janderit / DatabaseObserver.cs
Created Sep 2, 2015
C# class to observe SQL Server databases via Service Broker / SqlDependency
View DatabaseObserver.cs
public sealed class DatabaseObserver : IDisposable
{
private readonly string _connectionstring;
private readonly string _sqlcommand;
private readonly Action<Observation> _onChange;
private readonly Action<Exception> _onError;
private readonly Action<string> _onWarning;
private SqlConnection _connection;
private SqlCommand _cmd;
private SqlDependency _dependency;
@janderit
janderit / nodecqrs.js
Created Jul 16, 2012
Very brief cqrs projection proof of concept in node.js
View nodecqrs.js
function UserWasCreated(id, name){
this.Event = arguments.callee.name;
this.UserId=id;
this.Name=name;
}
function UserWasRenamed(id, name){
this.Event = arguments.callee.name;
this.UserId=id;
@janderit
janderit / gist:3237207
Created Aug 2, 2012
Reporting/Data/Kontext
View gist:3237207
public interface IProvideData
{
bool Provides(string key);
string Key { get; }
string Description { get; }
string Target { get; }
DatenTabelle DesignData();
DatenTabelle DemoData();
@janderit
janderit / gist:3283001
Created Aug 7, 2012
Dataprovider/code generation
View gist:3283001
public static ModulKonfigurator EntlassungsantragReporting(this ModulKonfigurator cfg)
{
cfg.AttachDataproviderToViewmodel("EntlassungBeantragenViewmodel", "VM:Entlassungsantrag")
.Provide("Antragsdaten", "Antragsdaten zum Entlassungsantrag")
.Datenspalte("Stichtag", "01.01.2000", "Stichtag der Entlassung")
.Datenspalte("Grund", "Ablauf der Förderhöchstdauer", "Grund der Entlassung")
.Datenspalte("Aufnahme", "01.01.2000", "Aufnahmedatum des ersten Kindes")
.End()
@janderit
janderit / ZmqPollPool.cs
Created Sep 10, 2012
ZeroMQ 3.2 Single threaded container
View ZmqPollPool.cs
/// <summary>
/// Encapsulates a zeroMQ context and a worker thread.
/// Use the ZmqPollPool to server multiple 0mq sockets with single-threaded semantics.
///
/// Use MarshalAndWait or MarshalAsync to marshal 0mq context access to the working thread.
/// Call Dispose to close all registered sockets and terminate the context and thread.
/// </summary>
public class ZmqPollPool : IDisposable
{
private TimeSpan _pollTimeout;
@janderit
janderit / gist:3691683
Created Sep 10, 2012
Example zeromq usage
View gist:3691683
public sealed class ZmqEventServer
{
public ZmqEventServer(ZmqPollPool pool, NetworkAddress broadcastAddress, NetworkAddress listenAddress)
{
if (!listenAddress.IsBindable) throw new ArgumentException("listen address must be bindable (i.e. IP address instead of DNS name)");
ZmqSocket broadcast=null;
var broadcastAddr = broadcastAddress.String;
var listenAddr = listenAddress.String;
@janderit
janderit / Concurrency_bug_in_2_0_5.cs
Created Sep 18, 2012
Test for (absence of) concurrency bug in fastJson. Fails with 2.0.5
View Concurrency_bug_in_2_0_5.cs
using System;
using System.Diagnostics;
using System.Threading;
using NUnit.Framework;
using fastJSON;
namespace UnitTests
{
[TestFixture]
internal class Concurrency_bug_in_2_0_5
@janderit
janderit / JSON.patch
Created Sep 18, 2012
Patch fixing concurrency bug in fastJSON 2.0.5
View JSON.patch
diff --git a/fastJSON/JSON.cs b/fastJSON/JSON.cs
index d2f651e..0915fc1 100644
--- a/fastJSON/JSON.cs
+++ b/fastJSON/JSON.cs
@@ -64,7 +64,17 @@ namespace fastJSON
public sealed class JSON
{
- public readonly static JSON Instance = new JSON();
+ [ThreadStatic]
You can’t perform that action at this time.