Skip to content

Instantly share code, notes, and snippets.

@msheakoski
msheakoski / gist:7b430277c14e6c5a59b418364048e14b
Created March 11, 2022 18:11 — forked from RubyTuesdayDONO/gist:5006455
logic revisions to pass test case
// Dependency resolution, adapted from https://gist.github.com/1232505/f16308bc14966c8d003c2686b1c258ec41303c1f
function resolve(graph) {
var sorted = [], // sorted list of IDs ( returned value )
visited = {}; // hash: id of already visited node => true
// 2. topological sort
Object.keys(graph).forEach(function visit(name, ancestors) {
if (!Array.isArray(ancestors)) ancestors = [];
ancestors.push(name);
visited[name] = true;
@msheakoski
msheakoski / 0_reuse_code.js
Last active August 29, 2015 14:19
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
# Is there a better way to simplify this such as instance_eval or another way to
# dynamically evaluate code in a limited context?
#
# What I'm trying to accomplish:
#
# - I have HTML widgets that accept form posts so they each have a basic input
# handler written in Ruby that for managability reasons is stored in the
# database. I'm aware of the dangers of eval. The code is from a trusted
# source only.
#