Skip to content

Instantly share code, notes, and snippets.

@bennidhamma
bennidhamma / example.ts
Last active May 30, 2021 00:53
This is a type safe replacement for lodash _.orderBy
// use like:
items.sort(orderBy<WorkGroup>([x => x.priorityScore, x => x.sortTime], ['desc', 'asc']);
@bennidhamma
bennidhamma / _watersheds.cs
Last active March 12, 2021 06:32
Watersheds
using System;
using System.Collections.Generic;
using System.Linq;
List<(int x, int y)>[] FindWatersheds(int[,] map) {
var ans = new Dictionary<int, List<(int x, int y)>>();
var h = map.GetLength(0);
var w = map.GetLength(1);
var uf = new UF(w * h);
for (int x = 0; x < w; x++) {
@bennidhamma
bennidhamma / reconcile.cs
Created February 26, 2021 00:39
yew reconcile
/*
* say we have
*/
@bennidhamma
bennidhamma / unionfind.cs
Last active February 23, 2021 00:30 — forked from ashwath10110/unionfind.cs
Simple Union-Find Datastructure in C#
public class UF
{
public int[] id { get; set; }
public int[] sz { get; set; }
public int cnt { get; set; }
public UF(int N)
{
cnt = N;
@bennidhamma
bennidhamma / fibheap.cs
Last active February 24, 2021 16:10
Until we get a standard priority queue in dotnet, here is a standalone heap for use in random projects.
public enum PriorityQueueType
{
Minimum,
Maximum
}
public sealed class FibonacciHeap<TItem, TPriority> : IEnumerable
{
public sealed class FibonacciNode
{
{
"log": {
"version": "1.2",
"creator": {
"name": "WebInspector",
"version": "537.36"
},
"pages": [
{
"startedDateTime": "2018-06-19T19:51:14.901Z",
@bennidhamma
bennidhamma / batterylow.xml
Last active March 8, 2018 20:43
batterylow.xml
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Say voice="alice">The system is down. The system is down. Your battery is dying and will soon go down</Say>
</Response>
import PropTypes from 'prop-types'
import { withStyles } from 'material-ui/styles'
import React, { Component } from 'react'
import Paper from 'material-ui/Paper'
import Collapse from 'material-ui/transitions/Collapse'
import { MenuList } from 'material-ui/Menu'
import { Manager, Target, Popper } from 'react-popper'
import Portal from 'material-ui/Portal';
import ClickAwayListener from 'material-ui/utils/ClickAwayListener'
@bennidhamma
bennidhamma / sprinke.js
Created October 12, 2017 16:25
Who wants some sprinkles?? @El-Gregory does!!
Array.prototype.sprinkle = function sprinkle(every, makeSprinkle) {
let numSprinkles = 0
return this.reduce((a, v, i) => {
a.push(v)
let doSprinkle = false
if (typeof every === 'function') {
doSprinkle = every(i, v, numSprinkles)
} else {
doSprinkle = i && i % every === 0
}

Keybase proof

I hereby claim:

  • I am bennidhamma on github.
  • I am bennidhamma (https://keybase.io/bennidhamma) on keybase.
  • I have a public key whose fingerprint is 0772 3A9B 1E56 6535 2ACF 2B7D AD97 66B7 33C9 EE4F

To claim this, I am signing this object: