Skip to content

Instantly share code, notes, and snippets.

@mdlawson
mdlawson / game.coffee
Created August 6, 2012 15:21
Rogue example state
state = require 'state'
game = new Rogue.Game
fps: true
game.input = new Rogue.Keyboard game.canvas
game.mouse = new Rogue.Mouse game
game.assets = assets = new Rogue.AssetManager
baseUrl: ""
packs:
core: [
@mdlawson
mdlawson / Cakefile
Created August 8, 2012 00:24
Parser demo
task 'doc', 'Build docs', ->
fs = require 'fs'
dox = require '../dox'
jade = require 'jade'
fs.readFile 'doc/template.jade', 'utf-8', (err,tmpl) ->
fn = jade.compile tmpl
for file in files
code =fs.readFileSync "src/#{file}.coffee", 'utf-8'
json = dox.parseComments code
html = fn({"dox":json,"file":file})
@mdlawson
mdlawson / factory.coffee
Created August 10, 2012 20:01
Rogue factory
class Factory
constructor: (options) ->
@hanger = []
@entity = options.entity or Rogue.Entity
@opts = options.options or {}
@initial = options.initial
for i in [0...@initial]
@hanger.push @build()
deploy: (num) ->
@mdlawson
mdlawson / usefulstuff.md
Last active December 12, 2015 07:58
Cass project

Useful stuff

Routing: we need to make routes that take people to games. To do this we can use URL slugs, eg:

/game/200

express allows us to create routes that work like this by using : in the route. eg

app.get("/game/:id", function(req,res){

res.send("This is game id " + req.params.id);

@mdlawson
mdlawson / gist:4995703
Last active December 13, 2015 23:59 — forked from anonymous/gist:4995688
<head>
<title>Grassington Town Hall</title>
<%= javascript_include_tag "jquery-latest", :media => "all" %>
<%= javascript_include_tag "bootstrap", :media => "all" %>
<%= stylesheet_link_tag "bootstrap", :media => "all" %>
<%= stylesheet_link_tag "application", :media => "all" %>
<%= csrf_meta_tags %>
</head>
<body>
<div class="navbar navbar-static-top">
@mdlawson
mdlawson / hosts.coffee
Last active December 16, 2015 01:29
Windows host file rewriter
fs = require "fs"
os = require "os"
{exec} = require "child_process"
HOSTS = if os.platform() is "win32" then "C:\\Windows\\System32\\Drivers\\etc\\hosts" else "/etc/hosts"
hosts = (name,read,write) ->
entry = -1
exit = -1
@mdlawson
mdlawson / fb.js
Last active December 20, 2015 00:09
var express = require('express');
var facebook = require('connect-facebook-session');
var app = express();
app.configure(function () {
app.use(express.bodyParser());
app.use(express.cookieParser());
app.use(express.session({ secret: 'foo bar' }));
app.use(facebook({
send: (message,id) ->
$http.post(APIURL+"addUserMessage",
#userIdFrom: User.id
userIdTo: id
message: message
).success (data) ->
console.log "send message",message,"to",toId
markRead: (id) ->
$http.post(APIURL+"markRead",
userIdFrom: id
%!PS-Adobe-3.0
/Xpos { 300 } def
/Ypos { 500 } def
/Heading { 0 } def
/Arg { 0 } def
/Right {
Heading exch add Trueheading
/Heading exch def
} def
/Left {
@mdlawson
mdlawson / gist:ce834829a4a0db9188c4
Last active August 29, 2015 14:06
Everything's a feature
Everything's a feature
Everything is cool we don't have any bugs
Everything's a feature when your code is fucked up
Everything is working if it builds without an error
Side by side, code and I, lets not loop forever, please don't loop forever
We're insane, I made you, you hate me, but we're all totally bug free
Everything's a feature
Everything is cool we don't have any bugs