Skip to content

Instantly share code, notes, and snippets.

@senthilnathansk
senthilnathansk / Edge.cs
Created April 12, 2018 06:43 — forked from IanMercer/Edge.cs
A simple in-memory graph
using System.Diagnostics;
namespace AboditUnits.Graph
{
public partial class Graph<TNode, TRelation>
{
/// <summary>
/// A relationship between two objects
/// </summary>
[DebuggerDisplay("{Start} -- {Predicate} --> {End}")]
@senthilnathansk
senthilnathansk / JsonPatches.cs
Created April 12, 2018 06:35 — forked from IanMercer/JsonPatches.cs
JSONPatch - a simple, crude implementation of calculating and applying patches to Json objects
using System.Collections.Generic;
using System.Linq;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace Abodit
{
public class JPatch
{
public string op { get; set; } // add, remove, replace
@senthilnathansk
senthilnathansk / DAG_MySQL.sql
Created April 4, 2018 12:22 — forked from xib/DAG_MySQL.sql
Direct Acyclic Directed Graph in MySQL database
-- Based on the original articel at http://www.codeproject.com/Articles/22824/A-Model-to-Represent-Directed-Acyclic-Graphs-DAG-o
-- Here is a port to MySQL
-- Edge table
DROP TABLE IF EXISTS `Edge`;
CREATE TABLE IF NOT EXISTS `Edge` (
`id` int(11) NOT NULL,
`entry_edge_id` int(11) DEFAULT NULL COMMENT 'The ID of the incoming edge to the start vertex that is the creation reason for this implied edge; direct edges contain the same value as the Id column',
`direct_edge_id` int(11) DEFAULT NULL COMMENT 'The ID of the direct edge that caused the creation of this implied edge; direct edges contain the same value as the Id column',
`exit_edge_id` int(11) DEFAULT NULL COMMENT 'The ID of the outgoing edge from the end vertex that is the creation reason for this implied edge; direct edges contain the same value as the Id column',
let cache = new Map();
let pending = new Map();
function fetchTextSync(url) {
if (cache.has(url)) {
return cache.get(url);
}
if (pending.has(url)) {
throw pending.get(url);
}
import { Observable } from "rxjs";
Observable.prototype[Symbol.asyncIterator] = createAsyncIterator;
async function* createAsyncIterator() {
const promise = [];
const values = [];
let done = false;
let error = null;