Skip to content

Instantly share code, notes, and snippets.

@joates
joates / round_floats.js
Last active May 17, 2016 23:16
rounding float values in javascript can produce undesirable results (i.e. errors in the exponent), although certain situations can still produce inaccuracy, this fixes the common cases, ** use with caution **
// fixes rounding of float values in javascript
Number.prototype.round = function(num_places) {
return +(Math.round(this +'e+'+ num_places) +'e-'+ num_places)
}
@joates
joates / array_unique.js
Created May 17, 2016 22:55
extract *only* unique values from an existing array
// private implementation of '[].unique'
Array.prototype.unique = function() {
var orig = {}
, i
, il = this.length
, res = []
for (i = 0; i < il; i++) orig[this[i]] = this[i]
for (i in orig) res.push(orig[i])
return res
}
@joates
joates / algorithms.md
Last active February 5, 2017 20:49
Geometric algorithms
  • Barycentric subdivision
  • Newton–Raphson division
  • Closest pair problem: find the pair of points (from a set of points) with the smallest distance between them
  • Collision detection algorithms: check for the collision or intersection of two given solids
  • Cone algorithm: identify surface points
  • Convex hull algorithms: determining the convex hull of a set of points
    • Graham scan
    • QuickHull
    • Gift wrapping algorithm or Jarvis march
  • Chan's algorithm
@joates
joates / menu.md
Last active December 15, 2016 12:29
/** DEPRECATED **/

website navigation menu

my website is impossible to navigate conventionally...
please use these links:

  • homepage
    • which is also the 404 page (all invalid routes are redirected)
  • a menu (prototype, which turned out to be unsuitable)
  • blog (http_//blog.joat.es) deprecated

WebGL (terrain)

@joates
joates / app.err
Last active August 29, 2015 14:06
testing squatconf website..
{ [Error: Sending failed]
errors: [ { [Error: queryMx ENOTFOUND] code: 'ENOTFOUND', errno: 'ENOTFOUND', syscall: 'queryMx' } ] }
@joates
joates / index.js
Created September 15, 2014 03:05
code to join some JSON files into one Object..
var fs = require('fs')
, extend = require('extend')
, async = require('async')
, obj = {}
var files = [
'001-050.json'
, '051-100.json'
, '101-150.json'
, '151-200.json'
@joates
joates / js-mvc-choices.md
Last active August 29, 2015 14:06
A few alternatives to Sails.js.. (Javascript MVC-style framewonks)
@joates
joates / label-style-tag.css
Last active August 29, 2015 14:06
website taxonomy tags that look like green luggage labels (uses CSS3 transform & gradient) demo image -> http://i.imgur.com/X3vARcK.png
/** Tags that look like labels (CSS3) **/
a.label-style-tag {
display: inline-block;
padding: 0px 10px;
height: 30px;
line-height: 30px;
border-radius: 5px;
font-weight: bold;
font-size: 0.9em;
text-decoration: none; }
@joates
joates / mmmovies_api.misc.inc
Last active August 29, 2015 14:05
for reference: here is the Drupal / PHP version of my Mmmovies project (i think i did this about 2 years ago) it works really well actually, it's quite a lot of code though (at over 1k LoC) in the main file, plus a tiny bit more in the include file.
<?php
/**
* @file
* Miscellaneous supporting functions.
*/
/**
* Returns a structured array defining the fields bundled with this content type.
@joates
joates / keybase.md
Created August 27, 2014 11:28
keybase.io verify

Keybase proof

I hereby claim:

  • I am joates on github.
  • I am joates (https://keybase.io/joates) on keybase.
  • I have a public key whose fingerprint is C91E 057B 45C8 0E57 5D7D AF27 F665 0811 4B33 8905

To claim this, I am signing this object: