Skip to content

Instantly share code, notes, and snippets.

@jonlabelle
jonlabelle / string-utils.js
Last active August 13, 2025 12:17
Useful collection of JavaScript string utilities.
// String utils
//
// resources:
// -- mout, https://github.com/mout/mout/tree/master/src/string
/**
* "Safer" String.toLowerCase()
*/
function lowerCase(str) {
return str.toLowerCase();
@maccman
maccman / canvas.physics.coffee
Created April 11, 2013 02:52
A canvas physics engine in 160 lines of CoffeeScript.
class Point
constructor: (@x = 0, @y = 0) ->
if isNaN(@x) or isNaN(@y)
throw new Error('Invalid coords')
add: (point) ->
@x += point.x
@y += point.y
subtract: (point) ->
@markashleybell
markashleybell / index.html
Created April 5, 2013 08:44
Queueing asynchronous functions in JavaScript so that each is executed after the previous function has completed; useful when lookup data or templates are required to be loaded before other code can be executed.
<!DOCTYPE html>
<html>
<head>
<title>Queueing Asynchronous Functions in JavaScript</title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="queue.js"></script>
</head>
<body>
<p><input type="button" id="process-button" value="Process Queue" /></p>
<div id="output"></div>
@pkorac
pkorac / leafletGeoJsonTileLayer.js
Last active July 14, 2025 23:23
A really simple GeoJSON tile layer in Leaflet solution The original idea belongs to Koko A. but this is a really simple and minimal piece of code I found if you want to use tiled json layers in leaflet.js Read more about it below (in the script) and be sure that your coordinates are good in the geojson files (i.e. in the right projection).
/*
# GEOJSON TILE LAYER IN LEAFLET.JS
The original idea for this gist comes from Koko A.'s post on leaflet-js google groups
(https://groups.google.com/forum/#!msg/leaflet-js/d7ur-evSz7Q/p_B4ea_0K1AJ)
Use it at your own peril (•
## The basic concept
- setup the map and the tiles as usual
- respond to the "tileload" event with a function that loads the json file (that has the same name - z, x, y - as the tile)
@AmmarCodes
AmmarCodes / Sublime Text Useful Packages.md
Last active December 14, 2015 15:19
Collection of useful packages for web development
@jrcryer
jrcryer / gist:4981167
Created February 18, 2013 21:58
WPUW - Tablet
/* Mobile First! */
body {
font-size: 100%;
}
#header {
padding: 12px 3.75%; /* (12 / 320) * 100 = 3.75 */
}
#title h1 {
font-size: 2em; /* (32 / 16) * 100 = 2 */
line-height: 1em;
@incompl
incompl / game.js
Last active December 10, 2015 11:39
Code for my Box2d screencast on Bocoup.com
var canvasElem = document.getElementById("game");
var world = boxbox.createWorld(canvasElem);
world.createEntity({
name: "player",
shape: "circle",
radius: 1,
image: "pig.png",
imageStretchToFit: true,
density: 4,
@bmcbride
bmcbride / LeafletToWKT.js
Last active June 7, 2022 02:17
Leaflet layer to WKT
function toWKT(layer) {
var lng, lat, coords = [];
if (layer instanceof L.Polygon || layer instanceof L.Polyline) {
var latlngs = layer.getLatLngs();
for (var i = 0; i < latlngs.length; i++) {
latlngs[i]
coords.push(latlngs[i].lng + " " + latlngs[i].lat);
if (i === 0) {
lng = latlngs[i].lng;
lat = latlngs[i].lat;
@max-mapper
max-mapper / bundle.js
Created November 8, 2012 18:29
html5 color scheme picker
var require = function (file, cwd) {
var resolved = require.resolve(file, cwd || '/');
var mod = require.modules[resolved];
if (!mod) throw new Error(
'Failed to resolve module ' + file + ', tried ' + resolved
);
var cached = require.cache[resolved];
var res = cached? cached.exports : mod();
return res;
};

These instructions work for the Raspberry Pi running Raspbian (hard float) and create a hardware optimized version of NodeJS for the Raspberry PI, (and include a working install and NPM!!!):

  1. Install Raspbian - http://www.raspberrypi.org/downloads

  2. Install the necessary dependecies:

sudo apt-get install git-core build-essential

(If you just installed git then you need to administer your git identity first, else adding the patches below will fail!!!)