Skip to content

Instantly share code, notes, and snippets.

View davesag's full-sized avatar
:octocat:
Coding

Dave Sag davesag

:octocat:
Coding
View GitHub Profile
@davesag
davesag / countries.yml
Created May 4, 2015 01:06
Countries, currencies, dial codes, and subnational divisions
- al:
name: 'Albania'
dial_code: '+355'
currency:
name: Lek
iso: ALL
fractional_unit: Qindarkë
number_to_basic: 100
symbol: 'L'
subnational_divisions:
@davesag
davesag / thingy.yml
Last active August 29, 2015 14:19
Defining a map of arbitrary translation keys in Swagger 2.0
swagger: '2.0'
info:
version: "0.0.1"
title: Localised Thingy demonstration
definitions:
translation:
required:
- default
@davesag
davesag / range_to_array.md
Last active August 29, 2015 14:10
Turning ranges into arrays.

Say you have a range of integers - 0 thru 100, and you wish to create an Array containing elements [0, 1, 2, … 100], what's the simplest way to do it?

For me the easiest has to be:

var results = []
for (var i = 0, l = 101; i < l; i++) { results.push(i) }

Another approach is to do this:

@davesag
davesag / onename
Created November 13, 2014 02:09
OneName verification
Verifying that +davesag is my openname (Bitcoin username). https://onename.io/davesag
@davesag
davesag / sails0.10_notes.md
Last active August 29, 2015 14:02
Upgrading from Sails.js 0.9 to 0.10 - Notes
@davesag
davesag / hello-world-server.coffee
Created April 11, 2014 07:14
A very simple hello-world http server in Coffeescript
###
A hello world server written in Coffeescript
Step 0: Install Node.js `brew install node`
Step 1: Install Coffeescript `npm install -g coffee-script`
Step 2: `coffee -c hello-world-server.coffee`
Step 3: `node hello-world-server`
Step 4: point your browser of choice at http://localhost:8000
Profit!
@davesag
davesag / keybase.md
Created March 12, 2014 02:55
My keybase identity

Keybase proof

I hereby claim:

  • I am davesag on github.
  • I am davesag (https://keybase.io/davesag) on keybase.
  • I have a public key whose fingerprint is 3DA6 3036 0827 026E EE92 CA8E 01C5 7612 BDF7 CFD7

To claim this, I am signing this object:

@davesag
davesag / Example Game server with Sinatra and Event Machine.
Last active August 18, 2020 01:51
This is the shell of my Game server built using Sinatra and EventMachine Websockets. I am trying to extract the cookie information that is passed to the Websocket's `onopen` method via the `handshake.headers['Cookie'], but have been unable to work out how to properly decode the cookie. See https://github.com/rack/rack/issues/551 or http://stacko…
#!/user/bin/env ruby
#coding: utf-8
APP_ROOT = File.dirname(__FILE__)
PROJECT_NAME = 'My Fantastic Game'
PROJECT_HOST = '0.0.0.0'
WEB_PORT = 9292
WS_PORT = 8080
COOKIE_KEY = 'my.session.key'
COOKIE_SECRET = 'shh_replace_me_withsomething_moresecret'
@davesag
davesag / maptest1
Created November 13, 2012 01:51
Experimenting with maps
var start_point = [1060, 3360]; // lon, lat, ie x, y (not correct yet)
var map_bbox = [0, 0, 6000, 5000]; // minx, miny, maxx, maxy
var map_zoom = 1;
var minimap_scale = 1/20;
$(document).ready(function() {
$.geo.proj = null; // images don't use a projection.
var map = $("#map").geomap({
center: start_point,
zoom: map_zoom,