Skip to content

Instantly share code, notes, and snippets.

@dreadjr
dreadjr / PubSub
Last active August 29, 2015 14:07 — forked from dux/PubSub
sudo npm install nodemon -g
nodemon server.coffee
open stand-alone.html
stand-alone.html?room1
stand-alone.html?room2
stand-alone.html?room3
function go() {
var userId = prompt('Username?', 'Guest');
checkIfUserExists(userId);
}
var USERS_LOCATION = 'https://SampleChat.firebaseIO-demo.com/users';
function userExistsCallback(userId, exists) {
if (exists) {
alert('user ' + userId + ' exists!');
function go() {
var userId = prompt('Username?', 'Guest');
// Consider adding '/<unique id>' if you have multiple games.
var gameRef = new Firebase(GAME_LOCATION);
assignPlayerNumberAndPlayGame(userId, gameRef);
};
// The maximum number of players. If there are already
// NUM_PLAYERS assigned, users won't be able to join the game.
var NUM_PLAYERS = 4;
// pros: does not fetch entire record set
// cons: grabs the last record which needs to be ignored
var first = true;
var ref = new Firebase(...);
ref.endAt().limit(1).on("child_added", function(snap) {
if( first ) {
first = false;
}
else {
console.log('new record', snap.val());
// Helper function to extract claims from a JWT. Does *not* verify the
// validity of the token.
// credits: https://github.com/firebase/angularFire/blob/master/angularFire.js#L370
// polyfill window.atob() for IE8: https://github.com/davidchambers/Base64.js
// or really fast Base64 by Fred Palmer: https://code.google.com/p/javascriptbase64/
function deconstructJWT(token) {
var segments = token.split(".");
if (!segments instanceof Array || segments.length !== 3) {
throw new Error("Invalid JWT");
}
#!/bin/bash
###################
#configuration here
####################
bucketname="your_bucket_name"
##########################
cd /home/hadoop
#first we set two vars...I had errors without this
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
export LD_RUN_PATH=/usr/local/lib:$LD_RUN_PATH
# Check java version
JAVA_VER=$(java -version 2>&1 | sed 's/java version "\(.*\)\.\(.*\)\..*"/\1\2/; 1q')
if [ "$JAVA_VER" -lt 18 ]
then
# Download jdk 8
echo "Downloading and installing jdk 8"
wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8-b132/jdk-8-linux-x64.rpm"
# Silent install
add-apt-repository ppa:cwchien/gradle
apt-get update
apt-get install gradle
@dreadjr
dreadjr / intellij-protoc
Created July 17, 2014 19:27
intellij "Cannot run program "protoc": error=2, No such file or directory"
gradle build using
plugin: 'protobuf'
buildscript {
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath 'ws.antonov.gradle.plugins:gradle-plugin-protobuf:0.9.1'
# Artie - Artie Server
#
# Real-time messaging service
description "artie"
start on filesystem
stop on runlevel S
respawn