Skip to content

Instantly share code, notes, and snippets.

"use strict";
var User = require('./User.js').User;
var Message = require('./Message.js').Message;
var PrivateMessage = require('./Message.js').PrivateMessage;
var Command = require('./Message.js').Command;
var SessionHandler = require('./SessionHandler.js').SessionHandler;
module.exports.ChatServer = function (port, debug) {
var http = require('http');
var qs = require('querystring');
@Cacodaimon
Cacodaimon / Session.js
Created November 11, 2012 14:59
Node.js Session handling, used @ cacodaemon.de
module.exports.Session = function () {
var getRandom = function () {
return Math.floor(Math.random() * 1e16).toString(36);
}
this.sessionId = getRandom() + '-' + new Date().getTime().toString(36) + '-' + getRandom();
this.doDestroy = false;
this.toString = function () {
return this.sessionId;
@Cacodaimon
Cacodaimon / MiniHttp.js
Created November 7, 2012 21:39
A minimalistic http server for serving static files with Node.js. Used @ cacodaemon.de
/*
* A minimalistic http server for serving static files with Node.js.
* Don't use this in a production enviroment, this http server is not fast or secure!
*
* Autor: Guido Krömer <mail@cacodaemon.de>
* Page: www.cacodaemon.de
* Date: 2012-11-07
*/
module.exports.MiniHttp = function (path, port, ip, indexPage) {
var path = path;
@Cacodaimon
Cacodaimon / client.js
Created October 22, 2012 17:55
WebSocket nodejs server & client tutorial used @ cacodaemon.de
module.exports.Client = function (name, socket) {
this.name = name
this.socket = socket
this.send = function (msg) {
this.socket.send(msg)
}
this.toString = function (msg) {
return this.name
#!/bin/bash
for num in {1..1000}; do
netcat localhost 1337 &
done
@Cacodaimon
Cacodaimon / server.js
Created October 15, 2012 18:19
nodejs simple chat server used@cacodaemon.de
var net = require('net');
function Clients () {
var clients = new Array()
var clientCounter = 0
var Client = function (socket, name) {
this.send = function(msg) {
this.socket.write(msg + '\n')
}
@Cacodaimon
Cacodaimon / Index.aspx
Created October 2, 2012 20:00
Used @ cacodaemon.de
<%@ Page Title="" Language="C#" MasterPageFile="/Views/Shared/Site.master" Inherits="System.Web.Mvc.ViewPage<MongoDB.Driver.MongoCursor>" %>
<asp:Content ID="Content" ContentPlaceHolderID="MainContent" runat="server">
<% foreach (Blog.Article article in this.ViewData.Model) { %>
<article>
<h2><a href="<%= Url.Action("ShowArticle", "Blog", new RouteValueDictionary(new { id = article.Id })) %>"><%= article.Title %></a></h2>
<span><%= article.Date %></span>
<p><%= article.Text %></p>
<p></p>
<% if (article.Comments == null) { %>
<p>Comments: <a href="<%= Url.Action("ShowArticle", "Blog", new RouteValueDictionary(new { id = article.Id })) %>#comments">[0]</a></p>
@Cacodaimon
Cacodaimon / article.phtml
Created October 2, 2012 19:56
Used @ cacodaemon.de
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>MVC Test Blog</title>
</head>
<body>
<header>
<h1>MVC Test Blog</h1>
</header>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Mvc.Ajax;
using System.Web.Routing;
using MongoDB.Driver;
using MongoDB.Bson;
<?php
class BlogController extends Zend_Controller_Action
{
public function indexAction()
{
try {
$model = new Application_Model_Article;
$this->view->articles = $model->fetchAll();
}