Skip to content

Instantly share code, notes, and snippets.

View aljorhythm's full-sized avatar
💻
👥

Joel Lim aljorhythm

💻
👥
View GitHub Profile
@ruby0x1
ruby0x1 / ServerSession.js
Created March 27, 2012 14:55
Multi-player games in HTML5 : Server Side Session Class
var Session = Class.extend({
init : function( socket ) {
this.socket = socket;
this.serverid = UUID();
this.initListeners();
},
@ruby0x1
ruby0x1 / ServerClass.js
Created March 27, 2012 14:54
Multi-player games in HTML5 : Server Side Server Class
var Server = Class.extend({
init : function( ) {
this.connections = [];
this.games = [];
},
addConnection : function( connection ) {
@ruby0x1
ruby0x1 / Server.js
Created March 27, 2012 14:55
Multi-player games in HTML5 : Socket.io on the server side with session
io.sockets.on('connection', function (socket) {
//create a new player, which registers its events
var connection = new Session( socket );
//add to the list of connections (for finding a game)
server.addConnection( connection );
//This will send a message to all clients saying that they connected,
//And hand them their serverid for future interactions.
socket.emit('onConnect', { serverid : connection.serverid });
@ruby0x1
ruby0x1 / Ball.js
Created March 27, 2012 14:56
Multi-player games in HTML5 : Server Side Ball Class
var Ball = Class.extend({
init : function( attachTo, isServer ) {
//Only create meshes on the client side
if( !isServer ) {
//Create meshes
this.setupBall( );
@ruby0x1
ruby0x1 / socket.io.example.js
Created February 18, 2012 23:12
socket.io + express in node.js for multiplayer games
//We will call this file server.js
var app = require('express').createServer(),
io = require('socket.io').listen(app),
url = require('url'),
pth = require('path'),
UUID = require('node-uuid');
/* Start of express/web server code. note this is just thrown here quick so you can grasp how it works. This obviously isn't good code or anything. */
@ruby0x1
ruby0x1 / multi-player-html5-games-02-socket.io-client.html
Created March 27, 2012 14:58
Multi-player games in HTML5 : Client Side Socket.io
<!DOCTYPE html>
<html>
<head>
<title> Real time multi-player games with HTML5</title>
<style type="text/css">
html , body {
@ruby0x1
ruby0x1 / multi-player-html5-games-01-socket.io-server.js
Created March 27, 2012 14:59
Multi-player games in HTML5 : Setting up Socket.io on the server side
//Create and listen for clients on the existing web server
//we created above. app is the express server.
var io = require('socket.io').listen( app );
//We also introduce a UUID library, for unique identifiers.
//Not required, but I find useful.
var UUID = require('node-uuid');
/* Socket.io Configuration */
@roryokane
roryokane / ExampleFilter.java
Created March 17, 2014 19:13
Java generic pipe and filter classes, plus examples
package pipe_foundations.example;
import pipe_foundations.Pipe;
import pipe_foundations.SimpleFilter;
public class ExampleFilter extends SimpleFilter<Integer, String> {
public ExampleFilter(Pipe<Integer> input, Pipe<String> output) {
super(input, output);
}
@tamas-molnar
tamas-molnar / kubectl-shortcuts.sh
Last active March 3, 2024 09:09
aliases and shortcuts for kubectl
alias kc='kubectl'
alias kclf='kubectl logs --tail=200 -f'
alias kcgs='kubectl get service -o wide'
alias kcgd='kubectl get deployment -o wide'
alias kcgp='kubectl get pod -o wide'
alias kcgn='kubectl get node -o wide'
alias kcdp='kubectl describe pod'
alias kcds='kubectl describe service'
alias kcdd='kubectl describe deployment'
alias kcdf='kubectl delete -f'