Skip to content

Instantly share code, notes, and snippets.

@zuk
zuk / pm2
Created February 6, 2014 20:51
/etc/init.d/pm2 for CentOS
#!/bin/bash
# chkconfig: 2345 98 02
#
# description: PM2 next gen process manager for Node.js
# processname: pm2
#
### BEGIN INIT INFO
# Provides: pm2
# Required-Start:
# Required-Stop:
@zuk
zuk / compass.js
Last active August 29, 2015 13:56
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="format-detection" content="telephone=no" />
<!-- WARNING: for iOS 7, remove the width=device-width and height=device-height attributes. See https://issues.apache.org/jira/browse/CB-4323 -->
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
<link rel="stylesheet" type="text/css" href="css/index.css" />
<title>Hello World</title>
</head>
@zuk
zuk / ruby_warrior_beginner.rb
Last active August 29, 2015 14:19
Ruby Warrior (Beginner)
class Player
DIRS = [:forward, :backward]
def initialize
@dir = :forward
end
def play_turn(warrior)
@warrior = warrior
<!-- this is how you generate unique DOM IDs in XSLT for use in generating HTML -->
<!-- generate the unique ID with "uid-" prefix and assign it to the uid variable -->
<xsl:variable name="uid">
<xsl:value-of select="concat('uid-',generate-id(.))"/>
</xsl:variable>
<!-- now use the unique id to generate a <label>-<select> pair -->
<label for="{$uid}">Menu:</label>
<select id="{$uid}">
<!-- footnote heeds to toggle the corresponding footnote div -->
<xsl:template match="aos:footnote" mode="aos-content"><xsl:variable name="footnoteNumber"><xsl:apply-templates select="." mode="get-footnote-number"/></xsl:variable><sup id="footnote-{$footnoteNumber}-link" class="footnote-link"><a href="#" onclick="revealFootnote('#footnote-{$footnoteNumber}'); return false"><xsl:value-of select="$footnoteNumber"/></a></sup>
</xsl:template>
@zuk
zuk / restful_blog2.rb
Created March 23, 2010 19:36
Attempt at re-writing Reststop for Camping 2.0
#!/usr/bin/env ruby
require 'rubygems'
require 'ruby-debug'
#gem 'camping', '~> 2.0'
#gem 'reststop', '~> 0.3'
$: << '../../camping-camping/lib'
$: << '../lib'
require 'camping-unabridged'
$(document).ready(function() {
rollcall = new S3.Rollcall('http://proto.encorelab.org:7070')
token = rollcall.getCurrentToken()
rollcall.fetchSessionForToken(token, function(data) {
console.log(data.session.user.username)
console.log(data.session.user.encrypted_password)
// log in to xmpp from here using those credentials
}
}
// uses jquery.url.js --> https://github.com/allmarkedup/jQuery-URL-Parser
var S3 = window.S3 || {}
S3.Rollcall = function(url) {
this.url = url
}
S3.Rollcall.prototype = {
/**
@zuk
zuk / ruby-xmpp-example.rb
Created February 26, 2011 22:16
Ruby XMPP Example
require 'rubygems'
require 'xmpp4r/client'
require 'xmpp4r/roster'
require 'colored'
require 'pp'
include Jabber
Jabber.debug = true
@zuk
zuk / blather-groupchat-example.rb
Created February 27, 2011 22:36
XMPP Groupchat reverse echo using Blather
require 'rubygems'
require 'blather/client'
# CONFIGURATION
jid = 'tester@proto.encorelab.org'
password = "foofoo"
chatroom = "s3@conference.proto.encorelab.org"
setup(jid, password)