Skip to content

Instantly share code, notes, and snippets.

View bjartwolf's full-sized avatar

Bjørn Einar Bjartnes bjartwolf

View GitHub Profile
@bjartwolf
bjartwolf / realtime.js
Created March 7, 2013 14:29
realtime for blog
module.exports = function (io) {
io.of('/SPio').on('connection', function (client) {
client.on('moveEvent', function (moveEvent) {
client.broadcast.emit('moveEvent', moveEvent);
});
});
}
@bjartwolf
bjartwolf / tasks.js
Created March 8, 2013 09:14
shared domain object
(function (exports) {
exports.Task = function(id, owner, title, description, priority, progress, dueOn, modified) {
var self = this;
this.ID = id;
this.AuthorId = owner; //16
this.Title = title;
this.Body = description;
this.Priority = priority; //(2) Normal
this.PercentComplete = progress; //100
this.DueDate = dueOn; //
app.get('/_api/:entitytype', ensureLoggedIn('/authenticate/login'), function (req,res) {
// do magic
});
app.post('/_api/:entitytype', ensureLoggedIn('/authenticate/login'), function (req,res) {
// do magic
});
app.put('/_api/:entitytype/:id', ensureLoggedIn('/authenticate/login'), function (req,res) {
// do magic
@bjartwolf
bjartwolf / gist:5195270
Created March 19, 2013 11:04
server.js
var http = require('http');
http.createServer(function (req, res) {
// 200 betyr ok på internett (eller, http, da)
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Vi er da for f@€n ikke kids!!! \n');
}).listen(process.env.port);
var http = require('http');
http.createServer(function (req, res) {
// 200 betyr ok på internett (eller, http, da)
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Vi er da for f@€n ikke kids!!! \n');
}).listen(process.env.port);
var http = require('http');
http.createServer(function (trine, nils) {
// 200 betyr ok på internett (eller, http, da)
nils.writeHead(200, {'Content-Type': 'text/plain'});
nils.end('Vi er da for f@€n ikke kids!!! \n');
}).listen(process.env.port);
var kristian = require('http');
kristian.createServer(function (req, res) {
// 200 betyr ok på internett (eller, http, da)
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Vi er da for f@€n ikke kids!!! \n');
}).listen(process.env.port);
@bjartwolf
bjartwolf / rollespill_web.js
Last active December 15, 2015 04:38
Til kidsakoder
var http = require('http');
var kristian = http.createServer(function (trine, truls) {
truls.writeHead(200, {'Content-Type': 'text/plain'});
truls.end('Vi er da for sv@rt€ ikke kids!!! \n');
});
kristian.listen(process.env.port || 8080);
@bjartwolf
bjartwolf / simplesttemplate.cs
Created March 20, 2013 13:36
Just the simplest ever template
using System;
using Antlr4.StringTemplate;
namespace stringtemplatetest
{
class Program
{
static void Main(string[] args)
{
var hello = new Template("Hello, $name$", '$', '$');
using System;
using System.Collections.Generic;
using Antlr4.StringTemplate;
namespace stringtemplatetest
{
class Bjorn
{
public Bjorn(int alder)
{