Skip to content

Instantly share code, notes, and snippets.

@nateware
nateware / haproxy.conf
Created October 31, 2012 15:36
HAProxy sample config for EC2
#
# This config file is a combination of ideas from:
# http://www.37signals.com/svn/posts/1073-nuts-bolts-haproxy
# http://www.igvita.com/2008/05/13/load-balancing-qos-with-haproxy/
# http://wiki.railsmachine.com/HAProxy
# http://elwoodicious.com/2008/07/15/nginx-haproxy-thin-fastcgi-php5-load-balanced-rails-with-php-support/
# http://upstream-berlin.com/2008/01/09/using-haproxy-with-multiple-backends-aka-content-switching/
# http://wiki.railsmachine.com/HAProxy
# http://gist.github.com/raw/25482/d39fb332edf977602c183194a1cf5e9a0b5264f9
#
@alamboley
alamboley / gist:4022129
Last active October 12, 2015 11:47
How to grab and drag physics objects (Citrus Engine recipe)
// In a state class :
//Here we use Box2D. /!\ Don't forget that your _hero must have its touchable property set to true!
var draggableHeroArt:DisplayObject = view.getArt(_hero) as DisplayObject;
draggableHeroArt.addEventListener(MouseEvent.MOUSE_DOWN, _handleGrab);
stage.addEventListener(MouseEvent.MOUSE_UP, _handleRelease);
private function _handleGrab(mEvt:MouseEvent):void {
@jpsarda
jpsarda / FDrawingSprite.cs
Last active December 11, 2023 04:17
A class to draw lines with Futile, 2D engine for Unity3D. API inspired from Flash AS3 drawing API. Works with transparent colors. Cap styles : NONE, ROUND, SQUARE, TRIANGLE, ARROW Joint styles : MITER, ROUND, BEVEL Experimental (but working for most usages) support of borders (so far only supported with styles NONE / BEVEL).
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
/* Author @jpsarda
* A drawing class.
*
* Examples :
*
@wilburding
wilburding / simulate.py
Last active December 15, 2015 11:39
simulate the mechanism of how BigWorld handles priorities of entities in the aoi of a witness. it seems that the priorities will finally all be cleared to zero, though very slow, hundreds of thousands iterations usually required at least and sometimes 100M iterations won't do, if all other entities are static.
#!/usr/bin/env pypy-c
from __future__ import print_function
import random
import math
import sys
import signal
import os
import time
@mcdurdin
mcdurdin / kex_cryptoapi_cng.cpp
Last active October 29, 2019 09:05
RSA Key Exchange between CryptoAPI and CNG
/*
Example program to demonstrate sharing public keys from CryptoApi to CNG
Note: Reversing the process would allow sharing public keys from CNG to
CryptoApi. You would need to be careful of padding parameters and
versions.
License (yes, yes, BSD):
Copyright (c) 2013, Marc Durdin
@juaxix
juaxix / NetworkLogic.cpp
Last active December 19, 2015 05:49
Photon Cloud SDK with ShiVa 3D : C++
#include "PrecompiledHeader.h"
#include "NetworkLogic.h"
#if defined _EG_MARMALADE_PLATFORM
# if defined I3D_ARCH_X86
# if(defined _MSC_VER && !defined __clang__ && !defined __gcc__)
# define PLAYER_NAME L"Marmalade X86 Windows"
# else
# define PLAYER_NAME L"Marmalade X86 OS X"
# endif
@marcusmoller
marcusmoller / gist:6622766
Last active November 17, 2019 15:58
A small sprite combiner written in shell. Used on: http://opengameart.org/content/700-sprites
#!/bin/sh
for f in *.gif
do
short=${f:0:4}
if ls $short".png" &> /dev/null; then
echo "file exists"
else
montage -tile x1 -geometry +0+0 -background none $short*.gif $short.png
convert $short.png -transparent white $short.png
@theodox
theodox / silencer.py
Created January 2, 2014 18:42
suppress stdout and stderr stdout and stderr are redirected into StringIOs. At exit their contents are dumped into the string fields 'out' and 'error' Typically use this via the with statement: For example:: with Silencer() as fred: print stuff result = fred.out note that if you use a silencer to close down output from the logging module, you s…
import sys
from StringIO import StringIO
class SilencedError ( Exception ):
pass
class Silencer( object ):
'''
suppress stdout and stderr
@sahat
sahat / client.js
Last active February 23, 2022 17:09
Calculate client-server latency using socket.io
var socket = io.connect('http://localhost');
var startTime;
setInterval(function() {
startTime = Date.now();
socket.emit('ping');
}, 2000);
socket.on('pong', function() {
latency = Date.now() - startTime;