Skip to content

Instantly share code, notes, and snippets.

View theosp's full-sized avatar

Daniel C theosp

View GitHub Profile
@theosp
theosp / lecture
Last active December 26, 2015 09:39
(Legend: [Slide title | point 1 / point 2...])
[Multiplayer Pong | Rapid Web App Development]
Hello everyone.
My name is Daniel Chcouri.
...
I'll present to you a little multiplayer game, which I've developed as a showcase for rapid web app development, with a very cool stack that includes Node.js, Express and Socket.IO.
var tls = require('tls');
var fs = require('fs');
var jspack = require('jspack').jspack;
var options = {
key: fs.readFileSync('test-key.pem'),
cert: fs.readFileSync('test-cert.pem'),
// This is necessary only if the client uses the self-signed certificate.
//ca: [ fs.readFileSync('client-cert.pem') ]
Developing Multiplayer Pong - with node.js, express and socket.io + Pong Tournament
The lecture takes about 45 minutes.
In the lecture I'll demonstrate a Pong game in which the audience smart phones will be used as remote controllers for a game arena that will be displayed in a main screen.
I'll talk briefly about the stack I used to develop the game and go over interesting parts of the code.
In the end of the lecture the audeince will be invited to join a Pong tournament. In each stage the players will be splitted into two teams randomly. The players of the winning team will stay in the tournament and will be splitted again until we'll have a winner.
@theosp
theosp / redis.conf
Created September 8, 2013 15:48
upstart redis.conf for old upstarts
description "Redis Server"
start on local-filesystems
stop on shutdown
exec sudo -u redis /usr/bin/redis-server /etc/redis/redis.conf
respawn
respawn limit 10 5
@theosp
theosp / apns_testing_server.js
Created September 2, 2013 13:16
Mimic APNS server
var tls = require('tls');
var fs = require('fs');
var jspack = require('jspack').jspack;
String.prototype.repeat = function(num) {
return new Array(num + 1).join( this );
}
var options = {
key: fs.readFileSync('test-key.pem'),
var tls = require('tls');
var fs = require('fs');
var options = {
key: fs.readFileSync('test-key.pem'),
cert: fs.readFileSync('test-cert.pem'),
// This is necessary only if using the client certificate authentication.
requestCert: true,
@theosp
theosp / redis.screenrc
Created August 19, 2013 09:18
Launch redis-server and redis-commander in a splitted gnu screen
# launch with: $ screen -c redis.screenrc
screen -t server 0 bash -c 'echo "Launching redis server"; redis-server; bash'
split
focus
screen -t redis-commander 1 bash -c 'redis-commander; bash'
<?php
function sendMessageViaApplePush($apns_environment, $certificate, $pushToken, $messageText) {
if ($apns_environment == "development") {
$serverURL = 'gateway.sandbox.push.apple.com:2195';
} else {
$serverURL = 'gateway.push.apple.com:2195';
}
$ctx = stream_context_create();
stream_context_set_option($ctx, 'ssl', 'local_cert', $certificate);
@theosp
theosp / permutations.js
Created August 16, 2013 10:03
A play with permutations
var _ = require("underscore");
var array_size = 4;
var iterations = 200000000;
var get_array = function () {
var a = [];
for (var i = 0; i < array_size; i++) {
a.push(i);
@theosp
theosp / pension.js
Last active May 12, 2021 17:27
Pension Calculator
var _ = require("underscore");
var percent = function (i) {
return i / 100;
}
var pensionSumCalculator = function (params) {
var default_params = {
current_savings_in_pensions_funds: 0,