Skip to content

Instantly share code, notes, and snippets.

@mdlawson
mdlawson / keybase.md
Last active September 28, 2016 22:53
keybase.md

Keybase proof

I hereby claim:

  • I am mdlawson on github.
  • I am mdlawson (https://keybase.io/mdlawson) on keybase.
  • I have a public key whose fingerprint is 0DF6 B13E D6E7 CD09 285F 9EB8 8B90 A4DF E816 05A1

To claim this, I am signing this object:

@mdlawson
mdlawson / Code.gs
Last active September 15, 2015 14:21
Google script for slack invites, deploy on https://script.google.com
function doGet(e) {
var response = UrlFetchApp.fetch("https://" + SLACK_TEAM_NAME + ".slack.com/api/users.admin.invite", {
"method" : "post",
"payload": {
"token": SLACK_API_TOKEN,
"set_active": "true",
"email": Session.getActiveUser().getEmail(),
}
});
var result = JSON.parse(response.getContentText());
@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
%!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 {
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
@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({
@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 / 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 / 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 / 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) ->