Skip to content

Instantly share code, notes, and snippets.

View gaving's full-sized avatar
🎯
Focusing

Gavin Gilmour gaving

🎯
Focusing
View GitHub Profile
/*
* a smart poller for jquery.
* (by github)
*
* simple example:
*
* $.smartPoller(function(retry) {
* $.getJSON(url, function(data) {
* if (data) {
* doSomething(data)
@jwage
jwage / SplClassLoader.php
Last active August 16, 2024 17:36
Add MIT license.
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
var http = require('http'),
io = require('socket.io'),
redis = require('redis');
server = http.createServer(function(req,response) {});
server.listen(8080);
var redisConn = redis.createClient();
var socket = io.listen(server);
@3rd-Eden
3rd-Eden / socket.io.broadcast.http.url.js
Created November 30, 2010 21:20
Broadcast messages through socket.io based on server urls.
var http = require("http"), io = require("socket-io")
.. do your require stuff
var server = http.createServer(function(req,res){
.. determine the location, and if its the same use the socket.io broadcast fn to send a message
if( req url is the same as /ping )
socketio.broadcast("pong")
});
@Kilian
Kilian / annoying.js
Created January 6, 2011 15:04
How to be an asshole
/**
* Annoying.js - How to be an asshole to your users
*
* DO NOT EVER, EVER USE THIS.
*
* Copyright (c) 2011 Kilian Valkhof (kilianvalkhof.com)
* Visit https://gist.github.com/767982 for more information and changelogs.
* Visit http://kilianvalkhof.com/2011/javascript/annoying-js-how-to-be-an-asshole/ for the introduction and weblog
* Check out https://gist.github.com/942745 if you want to annoy developer instead of visitors
*
@springmeyer
springmeyer / degress2meters.js
Last active August 22, 2024 14:22
convert from long/lat to google mercator (or EPSG:4326 to EPSG:900913)
// See https://wiki.openstreetmap.org/wiki/Slippy_map_tilenames for more details.
var degrees2meters = function(lon,lat) {
var x = lon * 20037508.34 / 180;
var y = Math.log(Math.tan((90 + lat) * Math.PI / 360)) / (Math.PI / 180);
y = y * 20037508.34 / 180;
return [x, y]
}
x= -77.035974
@mbostock
mbostock / .block
Last active November 14, 2023 03:46
Google Maps + D3
license: gpl-3.0
@nathansmith
nathansmith / screwed.js
Last active June 10, 2020 17:01
Force yourself to learn JavaScript.
// If you're a glutton for punishment, and/or claim
// that JavaScript libraries have too much "bloat",
// use this to force yourself to write JS longhand.
(function(window) {
function screwed() {
window._ = null;
window.$ = null;
window.$A = null;
window.$F = null;
10:02 < gavin> just jammin, im jammin
10:02 < gavin> who sang that again is that marley
10:02 < gavin> i need to put it on
10:02 < mike> yeah
10:03 < mike> I remember years ago the photocopier in the office jammed and one of the guys started singing that
10:03 < mike> in tears
10:03 < gavin> lol
@tokumine
tokumine / redis_pool.js
Created June 12, 2011 15:38
A pool implementation for redis in node.js. 1 pool per redis database.
var redis = require('redis')
, Pool = require('generic-pool').Pool;
var RedisPool = {
// Acquire resource.
//
// - `database` {String} redis database name
// - `callback` {Function} callback to call once acquired. Takes the form
// `callback(err, resource)`
acquire: function(database, callback) {