Skip to content

Instantly share code, notes, and snippets.

View danprince's full-sized avatar

Dan Prince danprince

View GitHub Profile
@danprince
danprince / sandbox.js
Last active April 3, 2024 19:35
Sandbox for Code Evaluation
var app = {};
// go through the application and find every single instance of a div
// with the class of 'sandbox'
app.bootstrap = function() {
var sandboxes = document.getElementsByClassName('sandbox');
// for each sandbox, run the createSandbox function
[].forEach.call(sandboxes, app.createSandbox);
};
@danprince
danprince / astar.clj
Last active December 2, 2021 02:20
Clojure A-star Search
(ns common.astar
(:require [clojure.data.priority-map :refer [priority-map]]))
;; Based on: https://www.redblobgames.com/pathfinding/a-star/implementation.html#python-astar
(defn- build-path
"Returns the reconstructed path from the start to the goal."
[goal came-from]
(loop [path [], node goal]
(if-let [parent (came-from node)]
@danprince
danprince / README.md
Last active May 27, 2020 21:33
Types/Sequelize Scope Repro

Reproducing types/sequelize/120. Run npm test to see compile errors.

index.ts(14,3): error TS2345: Argument of type '{ scopes: { human: { slack_id: { $ne: string; }; }; }; }' is not assignable to parameter of type 'InitOptions'.
  Property 'sequelize' is missing in type '{ scopes: { human: { slack_id: { $ne: string; }; }; }; }'.
index.ts(25,1): error TS2684: The 'this' context of type 'typeof Model' is not assignable to method's 'this' of type '(new () => Model) & typeof Model'.
  Type 'typeof Model' is not assignable to type 'new () => Model'.
    Cannot assign an abstract constructor type to a non-abstract constructor type.
@danprince
danprince / comment.html
Last active March 17, 2020 23:45
Game of Life Golf
<canvas id="$"></canvas><script>
// alias -1 (writing m is shorter than -1)
m=-1
// resize canvas to screen through its global variable (created from its id)
w=$.width=innerWidth,h=$.height=innerHeight
// create image data for rendering
d=new ImageData(w,h)
@danprince
danprince / .gitignore
Last active December 29, 2018 22:52
PM2 & Docker Example
node_modules
*.log
@danprince
danprince / helpscout-custom.css
Last active January 3, 2018 18:34 — forked from jeffmohr/helpscout-custom.css
Compass Help CSS
body, input, button {
color: #0a0a29;
font-family: 'Avenir Next','Lato','Helvetica Neue',Helvetica,Arial,sans-serif;
}
.navbar .navbar-inner {
background: white;
color: #0a0a29;
font-weight: 500;
padding: 8px;
@danprince
danprince / particles.js
Created February 19, 2017 01:59
particles
function range(x) {
var xs = [];
for (var i = 0; i < x; i++) {
xs[i] = i;
}
return xs;
}
function distance(a, b) {
return (
@danprince
danprince / filter-controls.scss
Created January 20, 2017 03:37
A Game of Networks
@controls {
bottom {
filter {
target: connection;
default: select-all;
option {
label: "Marriages";
selector: ['connection type'='marriage'];
}
We can make this file beautiful and searchable if this error is corrected: Illegal quoting in line 3.
name position state stance_1 date_1 quote_1 notes_1 link_1 stance_2 date_2 quote_2 notes_2 link_2 stance_3 date_3 quote_3 notes_3 link_3 image
Alexander, Lamar Senator TN voteForNominee 05/05/2016 politico asserts http://www.politico.com/story/2016/05/donald-trump-gop-endorsements-222894 a000360.jpg
Ayotte, Kelly Senator NH voteForNominee 04/05/2016 As she's said from the beginning, Kelly plans to support the nominee." Later Wednesday morning, however, spokeswoman Johnson added: "As a candidate herself, she hasn't and isn't planning to endorse anyone in this cycle." http://www.wmur.com/politics/wmur-first-after-trump-win-ayotte-plans-to-support-him-spokeswoman-says/39373086 antiTrump 08/10/2016 I will not vote for Donald Trump. https://twitter.com/KellyAyotte/status/784779876796665857 a000368.jpg
Barrasso, John Senator WY voteForNominee 05/05/2016 "No matter who we nominate, they're going to be better for Wyoming than Hillary Clinton or whoever the Democrats nominate." Also: "I'm going to c