Skip to content

Instantly share code, notes, and snippets.

View GrantCuster's full-sized avatar

grant GrantCuster

View GitHub Profile
@fabiovalse
fabiovalse / README.md
Last active June 29, 2020 14:42
Points Along an Archimedean Spiral
@unicornist
unicornist / caretRangeFromPoint.js
Last active August 30, 2023 01:39
Cross browser caretRangeFromPoint
//demo: http://jsfiddle.net/heZ4z/
if (document.addEventListener) { // standard
document.addEventListener('click', function onclick(e) {
var r;
if (document.caretRangeFromPoint) { // standard (WebKit)
r = document.caretRangeFromPoint(e.pageX, e.pageY);
} else if (e.rangeParent) { // Mozilla
r = document.createRange();
@joyrexus
joyrexus / README.md
Last active October 1, 2019 01:32
Asteroids-style motion

Use the left and right arrow keys to rotate the ship. Press the up arrow key to turn on the engine.

Notes

This is an example of Asteroids-style motion. The ship moves in straight lines until the engine is turned on and accelerates. When the ship reaches any of the stage boundaries it is repositioned to the opposite side. The ship rotates at ROTATION_SPEED degrees/second.

All code here is taken straight from the Game Mechanic Explorer, a collection of concrete examples for various game mechanics, algorithms, and effects. The examples are all implemented in JavaScript using the Phaser game framework, but the concepts and methods are general and can be adapted to any engine.

@automata
automata / index.js
Created January 10, 2014 16:59
react + dat.gui
var KielerOptions = function () {
this.spacing = 15.0;
this.apply = function () {
var event = new CustomEvent("kieler", { detail: this });
window.dispatchEvent(event);
};
};
@vdavez
vdavez / docx2md.md
Last active April 21, 2024 20:05
Convert a Word Document into MD

Converting a Word Document to Markdown in Two Moves

The Problem

A lot of important government documents are created and saved in Microsoft Word (*.docx). But Microsoft Word is a proprietary format, and it's not really useful for presenting documents on the web. So, I wanted to find a way to convert a .docx file into markdown.

The Solution

As it turns out, there are several open-source tools that allow for conversion between file types. Pandoc is one of them, and it's powerful. In fact, pandoc's website says "If you need to convert files from one markup format into another, pandoc is your swiss-army knife." But, although pandoc can convert from markdown into .docx, it doesn't work in the other direction.

@shawnbot
shawnbot / README.md
Last active December 11, 2018 09:09
d3 bounded zoom behavior

This gist shows how to restrict d3's zoom behavior so that users can't pan outside of a rectangular bounding box. Use your scroll wheel to zoom in and out of the field of circles, and click and drag to move when zoomed in. Note how when you zoom back out (by scrolling up) the view snaps to the original extent at zoom 1.

Make it real

Ideas are cheap. Make a prototype, sketch a CLI session, draw a wireframe. Discuss around concrete examples, not hand-waving abstractions. Don't say you did something, provide a URL that proves it.

Ship it

Nothing is real until it's being used by a real user. This doesn't mean you make a prototype in the morning and blog about it in the evening. It means you find one person you believe your product will help and try to get them to use it.

Do it with style

@cobyism
cobyism / gh-pages-deploy.md
Last active May 23, 2024 10:55
Deploy to `gh-pages` from a `dist` folder on the master branch. Useful for use with [yeoman](http://yeoman.io).

Deploying a subfolder to GitHub Pages

Sometimes you want to have a subdirectory on the master branch be the root directory of a repository’s gh-pages branch. This is useful for things like sites developed with Yeoman, or if you have a Jekyll site contained in the master branch alongside the rest of your code.

For the sake of this example, let’s pretend the subfolder containing your site is named dist.

Step 1

Remove the dist directory from the project’s .gitignore file (it’s ignored by default by Yeoman).