This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Basic XMPP bot example for HipChat using node.js | |
| // To use: | |
| // 1. Set config variables | |
| // 2. Run `node notube_bot.js` | |
| // 3. Send a message like "!weather 94085" in the room with the bot | |
| // based on https://raw.github.com/gist/940969/413b5601292df26e06f325cbd6e3944a728fb590/hipchat_bot.js | |
| var request = require('request'); // github.com/mikeal/request | |
| var sys = require('sys'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Update, upgrade and install development tools: | |
| apt-get update | |
| apt-get -y upgrade | |
| apt-get -y install build-essential | |
| apt-get -y install git-core | |
| # Install rbenv | |
| git clone git://github.com/sstephenson/rbenv.git /usr/local/rbenv | |
| # Add rbenv to the path: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| w = %w[a c d b e] | |
| w.sort #=> ["a", "b", "c", "d", "e"] | |
| w.sort.reverse #=> ["e", "d", "c", "b", "a"] | |
| w.sort { |a,b| b<=>a } #=> ["e", "d", "c", "b", "a"] | |
| w.reduce(&:+) #=> "acdbe" | |
| w.map(&:upcase) #=> ["A", "C", "D", "B", "E"] | |
| w.include? "a" #=> true | |
| w.member? "a" #=> true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Simple, scrappy UDP DNS server in Ruby (with protocol annotations) | |
| # By Peter Cooper | |
| # | |
| # MIT license | |
| # | |
| # * Not advised to use in your production environment! ;-) | |
| # * Requires Ruby 1.9 | |
| # * Supports A and CNAME records | |
| # * See http://www.ietf.org/rfc/rfc1035.txt for protocol guidance | |
| # * All records get the same TTL |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| # | |
| # Script: HipChat bot in Ruby | |
| # Author: Jordan Ritter <[email protected]> | |
| # | |
| unless `rvm-prompt i g`.chomp == "ree@xmpp" | |
| exec("rvm ree@xmpp ruby #{$0}") | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'rubygems' | |
| require 'mongo' | |
| module MongoPubSub | |
| QUEUES_COLLECTION = 'queues' | |
| class EndSubscriptionException < Exception; end | |
| class Publisher | |
| def initialize(queue_name, mongo_connection) | |
| # Initialize queue collection as a capped collection | |
| if not mongo_connection[QUEUES_COLLECTION].collection_names.include?(queue_name) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Update, upgrade and install development tools: | |
| apt-get update | |
| apt-get -y upgrade | |
| apt-get -y install build-essential | |
| apt-get -y install git-core | |
| # Extras for RubyGems and Rails: | |
| apt-get -y install zlib1g-dev | |
| apt-get -y install libssl-dev libsqlite3-dev |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* Ismael Celis 2010 | |
| Simplified WebSocket events dispatcher (no channels, no users) | |
| var socket = new FancyWebSocket(); | |
| // bind to server events | |
| socket.bind('some_event', function(data){ | |
| alert(data.name + ' says: ' + data.message) | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'em-redis' | |
| require 'redis' | |
| require 'redis/distributed' | |
| require "fiber_pool" | |
| class Redis | |
| class Distributed | |
| def initialize(urls, options = {}) | |
| @tag = options.delete(:tag) || /^\{(.+?)\}/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var tls = require('tls'); | |
| var fs = require('fs'); | |
| var Buffer = require('buffer').Buffer; | |
| var zlib = require('zlib'); | |
| var BufferList = require('bufferlist'); | |
| var Binary = require('bufferlist/binary'); | |
| var Put = require('put'); | |
| var http = require('http'); | |
| var options = |