Skip to content

Instantly share code, notes, and snippets.

@jpatel531
jpatel531 / queue.js
Created November 10, 2015 17:02
Pusher Message Queue
function MessageQueue(){
this.pusher = new Pusher('key');
this.items = [];
this.timeWindow = 100; // 100 ms
}
// send messages every 100ms
MessageQueue.prototype.cycle = function(){
var self = this;
@jpatel531
jpatel531 / app.js
Created October 1, 2015 10:23
Pusher Node
var express = require('express');
var path = require('path');
var favicon = require('serve-favicon');
var logger = require('morgan');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
var Pusher = require('pusher');
var pusher = new Pusher({
@jpatel531
jpatel531 / gist:95e0184a1e87e3d3e543
Last active August 29, 2015 14:25
Python Authenticate Private Channels
@app.route("/pusher/auth", methods=['POST'])
def authenticate_channel():
socket_id = request.form['socket_id']
channel = request.form['channel_name']
auth = pusher.authenticate(
channel=channel_name,
socket_id=socket_id
)
return auth
@jpatel531
jpatel531 / gist:55d9745368aac487d3d1
Last active August 29, 2015 14:23
Pusher + Chrome Notifications
<head>
<title>Pusher Test</title>
<script src="//js.pusher.com/2.2/pusher.min.js"></script>
<script>
Notification.requestPermission();
var pusher = new Pusher('YOUR_APP_KEY');
@jpatel531
jpatel531 / local_scanner.sh
Created November 3, 2014 17:08
'Who's In?' Local Scanner
#!/bin/bash
APP_PASSWORD="bar"
WHOSIN_URL=$1
AUTH_KEY=$2
local_scan() {
macs=( $(sudo nmap -sn 192.168.1.0/24 | grep -Eio "([0-9A-F]{2}:){5}[0-9A-F]{2}") )
}