Skip to content

Instantly share code, notes, and snippets.

View nicksheffield's full-sized avatar

Nick Sheffield nicksheffield

View GitHub Profile
@khalidx
khalidx / node-typescript-esm.md
Last active November 14, 2024 08:26
A Node + TypeScript + ts-node + ESM experience that works.

The experience of using Node.JS with TypeScript, ts-node, and ESM is horrible.

There are countless guides of how to integrate them, but none of them seem to work.

Here's what worked for me.

Just add the following files and run npm run dev. You'll be good to go!

package.json

@nicksheffield
nicksheffield / gist:d4cc9228de0dca472dc0
Created February 25, 2015 00:17
random number generator
// r( max, min, decimal places)
function r(a,b,c){ return parseFloat((Math.random()*((a?a:1)-(b?b:0))+(b?b:0)).toFixed(c?c:0)); }
@dsuket
dsuket / js-scale
Last active July 12, 2017 03:22
js scale like D3
(function() {
/**
Usage:
```javascript
var userScale = scale()
.domain(0, 10)
.range(0,100);
userScale(2);
// => 20
@nicksheffield
nicksheffield / angleTools.js
Last active July 20, 2016 04:22
Work out angles and distances between objects that have x and y properties.
// es6
const at = {
angle: (a,b)=>Math.atan2(b.y-a.y,b.x-a.x)/Math.PI*180,
dist: (a,b)=>Math.sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y)),
step: (a,s)=>({x:s*Math.cos(a*Math.PI/180),y:s*Math.sin(a*Math.PI/180)})
}
// es5
var at = {
angle: function(a,b){return Math.atan2(b.y-a.y,b.x-a.x)/Math.PI*180},
@astorm
astorm / gist:992233
Created May 25, 2011 23:29
Fix console.log in Chrome and Magento
<!-- Add to the package layout (via local.xml or however you prefer) -->
<!-- Also, best to remove before deployment, as some users report -->
<!-- it makes IE 7 crash -->
<default>
<reference name="content">
<block type="core/text" name="fix.console" as="fix.console">
<action method="setText">
<text><![CDATA[<script type="text/javascript">
iframe = document.createElement('iframe');
iframe.style.display = 'none';