Skip to content

Instantly share code, notes, and snippets.

@erajabzadeh
erajabzadeh / allen_interval_rules.py
Created February 6, 2025 08:25
Allen Interval Rules
class AllenIntervalRules(object):
@staticmethod
def ContainedBy(x, y):
return (x.UtcStartTime > y.UtcStartTime) and (x.UtcEndTime < y.UtcEndTime)
@staticmethod
def Contains(x, y):
return (y.UtcStartTime > x.UtcStartTime) and (y.UtcEndTime < x.UtcEndTime)
@erajabzadeh
erajabzadeh / gremlin-topological-sort.js
Last active August 4, 2021 13:30
Gremlin Topological Sort
g.V()
.not(__.inE())
.store("x")
.repeat(
outE()
.store("e")
.inV()
.not(inE().where(without("e")))
.store("x")
)
const ApplyToAll = (decorator: Function, options: { exclude?: string[] } = {}) => {
return (target: any) => {
const descriptors = Object.getOwnPropertyDescriptors(target.prototype);
for (const [propName, descriptor] of Object.entries(descriptors)) {
const isMethod = (typeof descriptor.value == 'function') && propName != 'constructor';
if (options.exclude?.includes(propName)) continue;
if (!isMethod) continue;
decorator(target, propName, descriptor)
Object.defineProperty(target.prototype, propName, descriptor);
}