Skip to content

Instantly share code, notes, and snippets.

# required in process.env: host, cloudant_account, cloudant_key, cloudant_pass,
# cloudant_db_accounts, cloudant_db_data, cookie_secret, redis_url, redis_port, redis_path,
# smtp_email, smtp_pass, smtp_host, smtp_ssl
bodyParser = require 'body-parser'
cloudant = require 'cloudant' account: process.env.cloudant_account,
key: process.env.cloudant_key,
password: process.env.cloudant_pass
email = require 'email'
express = require 'express' ()
app = require('http').createServer(handler)
io = require('socket.io').listen(app)
fs = require('fs')
app.listen 80
handler = () ->
fs.readFile __dirname + '/index.html', (err, data) ->
if err
res.writeHead 500
player = false
inGame = false
me = undefined
dead = undefined
gameID = window.location.hash.slice 1
socket = io.connect 'http://localhost'
# PLAYER EVENTS
kill = (target) ->
if inGame and player and not dead then socket.emit 'kill', target
style
* {
box-sizing: border-box;
}
body {
margin: 0 0;
padding: 0;
background-color: #eee;
text-align: center;
}
@jda0
jda0 / home.jade
Created January 26, 2014 22:42
Farkle Part 1: Welcome Template (save as index in /home)
!!!
html
head
title Welcome to Farkle
link(rel="stylesheet", href="http://getbootstrap.com/dist/css/bootstrap.css")
style(type="text/css").
body {
margin: 50px auto !important;
}
label.dice {
@jda0
jda0 / farkle.c
Last active June 17, 2016 06:24
Super Awful C to keep scores in a game of Farkle.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
// Copyright James Daly 2014
// Compile with: gcc farkle.c -std=c99 -o farkle
typedef struct Leader
{
char name[16];
Public Class Form1
' Form Controls: Label Label1, Label Label2, TextBox TxtDice, TextBox TxtLimit, CheckBox CbxUntilDone, Button BtnExe, ListBox LstItems, Label LblInfo
Public Enum FlipMode
FLIP_UNTIL_LIMIT
FLIP_UNTIL_MATCH
End Enum
Private rand As Random
Private dice, limit As Integer
Private until_limit As FlipMode
Public Class Form1
' Form Controls: Label Label1, TextBox TxtCoins, Label Label2, TextBox TxtLimit, CheckBox CbxUntilDone, Button BtnExe, ListBox LstItems, Label LblInfo
Public Enum FlipMode
FLIP_UNTIL_LIMIT
FLIP_UNTIL_MATCH
End Enum
Private rand As Random
Private coins, limit As Integer
Private until_limit As FlipMode
Module Module1
Private peg0 As Stack(Of Integer)
Private limit As UInteger = 5
Private key As ConsoleKeyInfo
Private cin, log, output As String
Private fileOutput As Boolean = False
Private done As Boolean = False
Private WithEvents daemon As ComponentModel.BackgroundWorker
Sub Main()
Public Class Form1
' Form Controls: Button Button1, Button Button2
' ulong input stores user input
' ulong output stores result of factorial
Private input, output As ULong
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
UInteger.TryParse(InputBox("Enter number to find factorial"), input)