Skip to content

Instantly share code, notes, and snippets.

View dgershman's full-sized avatar
🔒

Danny Gershman dgershman

🔒
View GitHub Profile
@dgershman
dgershman / app.js
Created June 27, 2012 14:24
Node Server - RAPJS
io.sockets.on('connection', function(socket) {
const redisQueue = redis.createClient(port, hostname);
redisQueue.subscribe('reporting');
socket.emit('connected', "connected to the server" );
count++;
socket.emit('real-action', getVisitEvent(count));
socket.on('disconnect', function() {
@dgershman
dgershman / clientrapjs.html
Created June 27, 2012 14:27
Client Code - RAPJS
<script src="/socket.io/socket.io.js"></script>
<script type="text/javascript">
var socket = io.connect();
var presence = 0;
socket.on('real-action', function(data) {
presence = data.data;
});
</script>
@dgershman
dgershman / gist:4041563
Created November 8, 2012 20:59
user agent detection with regexp
var str = "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/12.0.782.220 Safari/535.1";
var found = (new RegExp("Chrome/1[2-3]", "g").exec(str));
alert(found);
@dgershman
dgershman / procs.sh
Created November 12, 2012 18:18
Count cores on Linux
cat /proc/cpuinfo | grep processor | wc -l
@dgershman
dgershman / lb1.sh
Created November 13, 2012 22:15
Reducing weight in a load balancer
ssh eqsupport@192.168.20.22 su -l root -c \'eqcfg weight qa.platform.cinchcast.com:QA-Platform-AWS 100\'
#!/bin/sh
#
# chkconfig: 35 99 99
# description: Node.js /home/nodejs/sample/app.js
#
. /etc/rc.d/init.d/functions
USER="nodejs"
@dgershman
dgershman / centos5.8-upgrade-nodejs0.10.28.sh
Last active December 9, 2015 23:59
added changes for checking for root, since sudo su don't work right
#!/bin/bash
# Danny Gershman
# Cinchcast
FILE="/tmp/out.$$"
# Make sure only root can run our script
if [ "$(id -u)" != "0" ]; then
echo "This script must be run as root" 1>&2
exit 1
@dgershman
dgershman / runner-centos5.8-upgrade-nodejs0.10.28.sh
Last active December 10, 2015 04:38
runner-centos5.8-upgrade-nodejs0.8.16.sh
# retrieve
curl https://gist.github.com/radius314/4348083/download > centos5.8-upgrade-nodejs0.10.28.tar.gz
# extract
tar -xvf centos5.8-upgrade-nodejs0.10.28.tar.gz --strip 1
# prepare
chmod 744 centos5.8-upgrade-nodejs0.10.28.sh
# execute
#!/bin/sh
#
# chkconfig: 35 99 99
# description: Node.js /home/nodejs/sample/app.js
#
. /etc/rc.d/init.d/functions
USER="nodejs"
@dgershman
dgershman / app.js
Created January 10, 2013 22:14
async example forEach
var async = require('async');
var obj = [ "apple", "banana", "orange", "pineapple", "kiwi", "watermelon", "grape" ];
function getObj(i, callback) {
setTimeout(function() {
console.log(i)
callback(null);
}, 2000);
}