Skip to content

Instantly share code, notes, and snippets.

View connorjclark's full-sized avatar

Connor Clark connorjclark

View GitHub Profile
connorjclark / gist:5795475
Created June 17, 2013 08:35
amitp Polygonal Map Generation - rendering the outermost polygons
//Written by Hoten
//feel free to use
for (Center c : centers) {
//only used if Center c is on the edge of the graph. allows for completely filling in the outer polygons
Corner edgeCorner1 = null;
Corner edgeCorner2 = null;
require 'filewatcher'
puts 'and now my watch begins ...''.').watch() do |filename, event|
if filename.include? '.rb' and filename != 'watch.rb'
puts "time is #{'%I:%M:%S %P')}"
puts `ruby #{filename}`
def time_it(&block)
before = - before
def display_time(&block)
puts "time took: #{time_it(&block)} seconds"
def play
cards = (-10..10).to_a - [0]
sum = 0
sum += cards.delete_at(rand(cards.length))
end while sum != 0
20 - cards.length
num_trials = 100000
connorjclark /
Created April 25, 2017 18:19

Question came up during the homework review for express-blogpulse: how to redirect a route relative to the Router being used? Example, on POST /post, how can we best redirect to GET /post/:id for the newly created post?

Answer: use req.baseUrl. click for docs:

Something like req.redirect(req.baseUrl + "/" +

req.baseUrl would be equal to /post in this case, because of the line app.use("/post", require("controllers/post.js"))

connorjclark / calc.js
Created August 15, 2017 19:39
cookie clicker grimoire estimation
var fps = 30;
function calcMagicPerSecond(current, maxMagic) {
return Math.max(0.002,Math.pow(current/Math.max(maxMagic,100),0.5))*0.002*fps;
let z = Math.max(maxMagic, 100)
| |
// fyi a 'plugin' is basically just a transform. idk if polyfils are considered plugins but for the purposes here say they aren't.
const pluginData = {"transform-template-literals":{"chrome":"41","edge":"13","firefox":"34","node":"4","samsung":"3.4","opera":"28","electron":"0.24"},"transform-literals":{"chrome":"44","edge":"12","firefox":"53","safari":"9","node":"4","ios":"9","samsung":"4","opera":"31","electron":"0.31"},"transform-function-name":{"chrome":"51","firefox":"53","safari":"10","node":"6.5","ios":"10","samsung":"5","opera":"38","electron":"1.2"},"transform-arrow-functions":{"chrome":"47","edge":"13","firefox":"45","safari":"10","node":"6","ios":"10","samsung":"5","opera":"34","electron":"0.36"},"transform-block-scoped-functions":{"chrome":"41","edge":"12","firefox":"46","safari":"10","node":"4","ie":"11","ios":"10","samsung":"3.4","opera":"28","electron":"0.24"},"transform-c
connorjclark / gist:cc583554ff07cba7cdc416c06721fd6a
Last active November 1, 2019 19:40
detecting core-js polyfills


Oh boy :) cracks knuckles tl;dr no, also I overlooked so much, thanks for pointing this out.

The minified JS I linked to is every polyfill that @babel/present-env would provide. The recommended distribution of these polyfills is not the module I linked (@babel/polyfill), but instead via @babel/preset-env. Regardless, they both use the polyfills as defined by core-js. You can see that the polyfills module has a standard bundling and minifying script:, which is what I linked to before. The question is: does the pattern I'm looking for hold for these core-js polyfills regardless of the minifier used? Additionally: where does this pattern come from? I'll focus on that first.

To further complicate, there's core-js@2 and core-js@3, and both seem to be used (or at leas

connorjclark /
Last active November 21, 2019 17:50
How Lighthouse builds for DevTools


yarn build-devtools && yarn devtools

How Lighthouse builds for DevTools

yarn build-devtools creates these files: