Skip to content

Instantly share code, notes, and snippets.

View mathisonian's full-sized avatar

Matthew Conlen mathisonian

View GitHub Profile
### Keybase proof
I hereby claim:
* I am mathisonian on github.
* I am mathisonian (https://keybase.io/mathisonian) on keybase.
* I have a public key whose fingerprint is 80C1 97B6 BB09 F9D3 D2D5 11B8 4AEB CDE4 E46B 0304
To claim this, I am signing this object:
@mathisonian
mathisonian / model.js
Created September 17, 2014 17:48
mimicking an array data type with sequelize.js
var MyModel = sequelize.define('MyModel', {
myArrayField: {
type: DataTypes.STRING,
get: function() {
return JSON.parse(this.getDataValue('myArrayField'));
},
set: function(val) {
return this.setDataValue('myArrayField', JSON.stringify(val));
}
}
@mathisonian
mathisonian / app.css
Last active August 29, 2015 14:05
penrose
#viz {
max-width: 500px; }
@mathisonian
mathisonian / index.md
Last active March 22, 2023 05:31
requiring npm modules in the browser console

demo gif

The final result: require() any module on npm in your browser console with browserify

This article is written to explain how the above gif works in the chrome (and other) browser consoles. A quick disclaimer: this whole thing is a huge hack, it shouldn't be used for anything seriously, and there are probably much better ways of accomplishing the same.

Update: There are much better ways of accomplishing the same, and the script has been updated to use a much simpler method pulling directly from browserify-cdn. See this thread for details: mathisonian/requirify#5

inspiration

@mathisonian
mathisonian / requirify-browser.js
Created August 21, 2014 02:14
requirify-browser
!function e(r,o,t){function n(a,s){if(!o[a]){if(!r[a]){var u="function"==typeof require&&require;if(!s&&u)return u(a,!0);if(i)return i(a,!0);throw new Error("Cannot find module '"+a+"'")}var d=o[a]={exports:{}};r[a][0].call(d.exports,function(e){var o=r[a][1][e];return n(o?o:e)},d,d.exports,e,r,o,t)}return o[a].exports}for(var i="function"==typeof require&&require,a=0;a<t.length;a++)n(t[a]);return n}({1:[function(e,r){function o(e,r){if("function"!=typeof r)throw new Error("Bad callback given: "+r);if(!e)throw new Error("No options given");var a=e.onResponse;if(e="string"==typeof e?{uri:e}:JSON.parse(JSON.stringify(e)),e.onResponse=a,e.verbose&&(o.log=i()),e.url&&(e.uri=e.url,delete e.url),!e.uri&&""!==e.uri)throw new Error("options.uri is a required argument");if("string"!=typeof e.uri)throw new Error("options.uri must be a string");for(var s=["proxy","_redirectsFollowed","maxRedirects","followRedirect"],d=0;d<s.length;d++)if(e[s[d]])throw new Error("options."+s[d]+" is not supported");if(e.callback=r,e.meth

"That is a matter upon which I have pondered deeply," sighed Mahmoud. "It is evident that she understands our talk. She has the iron upon hers leg, yet his talk is not the talk of the Menial People. Alas, I can not be sure on this point. These Master People have strange ways and a strange [Pg 10]tongue. When their skins are dark, as they are in the jungle, their talk is not so difficult; but when their skins are white and covered with strange raiment, their words convey no meaning to my ears."

Mahmoud's head drooped again. He was very old, and, like all those who are burdened with years, he was wont to ponder sadly on the joys of his past. But presently she raised his head and seemed to be listening.

"Look, Friend of my Youth," she said, after a moment, "is it the chirp of our merry little gossip, the sparrow, that I hear?"

@mathisonian
mathisonian / poygon.pde
Last active August 29, 2015 14:01
polygon painting
// setup params
int rows = 4;
int columns = 4;
int squareSize = 40;
int spreadSize = squareSize;
// whitespace
int margin = 200;
@mathisonian
mathisonian / color-cube.pde
Created May 12, 2014 02:18
color-cube.pde
/**
* Bouncing ball modified from http://www.instructables.com/id/Control-a-RepStrap-RepRap-CNCCartesian-Bot-usi/step20/3D-Bouncing-Ball-Processing/
NOTE: 0,0,0 - top left corner (facing the computer monitor)
negative Z axis points 'into' the computer monitor
positive Y axis points down
positive X axis points to the right
*/
@mathisonian
mathisonian / colors.pde
Created May 9, 2014 15:21
cosmic latte gradients
void setup() {
size(640, 360);
colorMode(HSB, 360, 1, 1);
background(0);
}
void draw() {

Mouseover to see flights originating at the specified airport. The cool thing about this technique is that the interaction requires zero JavaScript — it’s all done in CSS using the :hover state to toggle visibility of an airport’s associated outgoing flight routes.