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 / my haml override.
Created September 27, 2010 02:25
i18n aware haml and erb template loader for Sinatra
helpers do
def haml(template, options = {}, *)
# template will either be the name of a template or the body of a template.
# if it's the body then it will contain a "%" symbol and so we can skip any processing
template_name = template.to_s
do_not_localise = false
if template_name.include?('%')
Summary
-------
Heroku crashes consistently with an "Ouchie Guy" whenever a logged-in user of my app creates or edits any data.
Details
-------
See the app http://frank-demo.heroku.com
I can log into my app as a root user (with 'root' and 'password' to keep it simple) but from that point on any attempt to
* edit my profile
@davesag
davesag / frank.rb extract
Created February 14, 2011 23:57
setting r18n locale
# r18n will grab locale info from the session first and if it's not in the session, the browser, if it can.
# add this to your code to allow for a manual override of the session
before do
session[:locale] = params[:locale] if params[:locale] #the r18n system will load it automatically
end
@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,
@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 / 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 / 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 / sails0.10_notes.md
Last active August 29, 2015 14:02
Upgrading from Sails.js 0.9 to 0.10 - Notes
@davesag
davesag / onename
Created November 13, 2014 02:09
OneName verification
Verifying that +davesag is my openname (Bitcoin username). https://onename.io/davesag