Skip to content

Instantly share code, notes, and snippets.

View beyond-code-github's full-sized avatar

Pete Smith beyond-code-github

View GitHub Profile
@beyond-code-github
beyond-code-github / min-heap-range-four-lists.js
Created April 17, 2024 08:47
Use min-heap to find lowest range spanning four lists - Javascript
"use strict";
const Heap = require("heap")
const input = [
[3, 6, 8, 10 , 15],
[1, 5, 12],
[4, 8, 15, 16],
[2, 6]
]
@beyond-code-github
beyond-code-github / trie-heap-words.js
Created April 17, 2024 08:45
Basic Trie implementation and problem solve with Heap - Javascript
"use strict";
const Heap = require("heap");
class Trie {
count = 0;
key = null;
// each node stores a map to its child nodes
character = {};
@beyond-code-github
beyond-code-github / moch-karat-studio.js
Last active April 17, 2024 08:43
Mocha test boilerplate for Karat studio - Javascript
"use strict";
const Mocha = require('mocha');
const {describe, it} = Mocha;
const chai = require('chai');
const {assert} = chai;
chai.should();
@beyond-code-github
beyond-code-github / binary-tree-diameter.js
Created April 17, 2024 00:23
Calculate binary tree diameter in linear time - Javascript
"use strict";
class TreeNode {
data;
left;
right;
constructor(data) {
this.data = data;
@beyond-code-github
beyond-code-github / binary-tree-terse.js
Created April 17, 2024 00:01
Initialise a simple binary tree in a terse way - Javascript
"use strict";
class TreeNode {
data;
left;
right;
constructor(data) {
this.data = data;
@beyond-code-github
beyond-code-github / changetracking.js
Created January 31, 2014 22:42
Change tracking implementation for knockout.js supporting complex objects
var getObjProperties = function (obj) {
var objProperties = [];
var val = ko.utils.unwrapObservable(obj);
if (val !== null && typeof val === 'object') {
for (var i in val) {
if (val.hasOwnProperty(i)) objProperties.push({ "name": i, "value": val[i] });
}
}
@beyond-code-github
beyond-code-github / Examples.txt
Last active February 5, 2018 09:14
Pub name generator, simply wire in a function r that provides a random number (min, max) =>
"The King's Arms"
"The Three Dragons"
"The Wise Old Star"
"The George's Retreat"
"The Rising George"
"The Trout's Tavern"
"The Four Moons"
"The Bird's Arms"
"The Great Cross"
"The Angry Lion"
using System;
using System.Collections.Generic;
namespace OnlineShop
{
delegate decimal Discount(decimal amount, int yearsAccountHeld);
public static class Discounts
{
public static decimal NotRegistered(decimal amount, int yearsAccountHeld) => amount;

Pete is a software consultant and speaker based near London with almost 10 years of experience making web applications with ASP.net, specialising in API design and JavaScript browser-based applications. He's also a keen distributed systems enthusiast who enjoys helping clients solve their cloud-scale problems.

He is the author of Superscribe - an open source routing framework - and HTTP query library Linq to Querystring among others. Just recently he's embarked on a journey learning JVM and Scala, with a little Python thrown in to boot.

Pete is a software consultant, speaker & writer living near London, UK. With over 10 years of experience making web applications, he started off with C# and Javascript and nowadays likes to build distributed systems in Scala.

He enjoys running training courses and speaking at conferences. Sometimes he works on OSS, and one time he even finished something. He believes a microservice should be twice as large as half it's height.

@beyond-code-github
beyond-code-github / efficientiteratortests.cs
Created January 21, 2014 22:09
Efficient iterator specifications
public class ItemA
{
public string Identifier { get; set; }
}
public class ItemB
{
public string Name { get; set; }
}