Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am phuesler on github.
  • I am phuesler (https://keybase.io/phuesler) on keybase.
  • I have a public key whose fingerprint is 4C36 0148 3980 766F 7D18 509D AD99 FD67 2E21 510A

To claim this, I am signing this object:

@phuesler
phuesler / timeout_benchmark.rb
Created April 23, 2014 16:04
Testing how big the overhead of ruby timeout is
require 'benchmark'
require 'timeout'
N = 10_000
def just_loop
N.times do |i|
i + 1
end
end
@phuesler
phuesler / netcat_tcp_server.sh
Last active October 7, 2024 14:15
Simple tcp server using netcat
#!/bin/bash
# Simple tcp server using netcat
# - depending on the netcat version either use nc -l 5555 or nc -l -p 5555
# - verify with `telnet locahhost 5555`
# - quit the telnet with `ctrl-]` and then type quit
# - the while loop is there so reopen the port after a client has disconnected
# - supports only one client at a time
PORT=5555;
while :; do nc -l -p $PORT | tee output.log; sleep 1; done
#!/usr/bin/env node
// Start with nohup node log_server.js > output.log &
// Load the TCP Library
net = require('net');
// Keep track of the clients
var clients = [];
// Start a TCP Server
net.createServer(function (socket) {
#!/bin/bash
# save the project root. it seems that the
# python webserver needs absolute paths
PROJECT_ROOT=`pwd`
# We will Log the webserver's output to a log file
# Make sure the directory is there and we have a file
# to append to
mkdir -p log
touch log/webserver.log
@phuesler
phuesler / unity_rake_net_ubuntu.diff
Created March 15, 2013 10:36
Changes to make the unity master server compile on a EC2 Ubuntu instance
diff --git a/Makefile b/Makefile
index d8009c7..a74a6ee 100644
--- a/Makefile
+++ b/Makefile
@@ -3,7 +3,7 @@
CC=g++
DEFINES = -DUNITY_MASTERSERVER
-CFLAGS=-Wall -lpthread $(DEFINES)
+CFLAGS=-Wall -pthread $(DEFINES)
@phuesler
phuesler / autodeploy.sh
Created February 13, 2013 11:06
Poor mans continuous deployment in a screen session
#!/usr/bin/env bash
# Hackisch temporary solution to poll git and compile the code
# The server will reload automatically
while :
do
git remote update > /dev/null && git status -uno | grep -q "Your branch is behind" && git pull && ./rebar compile;
sleep 5;
done
handle_info(tick, State) ->
Now = now(),
Waiting = lists:map(fun ({GameId, WantedPlayers, Players}) ->
{GameId, WantedPlayers,
lists:filter(fun ({_, _, _, Start, _}) ->
timer:now_diff(Now, Start) > 60000
end, Players)}
end, State#state.waiting),
NewWaiting = lists:filter(fun ({_, _, []}) -> false;
(_) -> true
class MyClass
@@myvar = "My Var"
def self.myvar
@@myvar
end
def self.myvar=(new_value)
@@myvar = new_value
end
@phuesler
phuesler / show_ads.js
Last active December 11, 2015 21:48
modified epom show_ads.js
/*
* Asynchronous loading of ads.
* Below is of the top of my head rewrite to load multiple ads at the same time
* in a asynchronous fashion.
*
* I gave it a quick test run and it seems to work as fare as I can see
*
*
* var EpomConfig = EpomConfig || {ads : []};
* (function(){