First add your twitter username and password. Then server.rb and once it's started open websocket.html in your browser. You should see some tweets appear. If not take a look at the javascript console.
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
# inside spec_helper.rb | |
def enable_http_request | |
WebMock.reset! | |
WebMock.allow_net_connect! | |
end | |
def disable_http_request | |
WebMock.reset! | |
WebMock.disable_net_connect! | |
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
stub_request(:post, @post_regexp).with(:body => @post_data) | |
.to_return(:status => 200, :body => "",:headers => {'content-type' => 'application/json; charset=utf-8'}) | |
# example of a tub request using webmmock - refer to the original gem sit for more usage details |
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
#!/bin/sh | |
# | |
# nginx - this script starts and stops the nginx daemon | |
# | |
# chkconfig: - 85 15 | |
# description: Nginx is an HTTP(S) server, HTTP(S) reverse \ | |
# proxy and IMAP/POP3 proxy server | |
# processname: nginx | |
# config: /etc/nginx/nginx.conf | |
# config: /etc/sysconfig/nginx |
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
<!-- This is how you lay out cross-browser columns. Stick to this and you're golden --> | |
<style> | |
.clearfix:after { | |
content: "."; | |
display: block; | |
clear: both; | |
visibility: hidden; | |
line-height: 0; | |
height: 0; | |
} |
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 'digest/md5' | |
def gfm(text) | |
# Extract pre blocks | |
extractions = {} | |
text.gsub!(%r{<pre>.*?</pre>}m) do |match| | |
md5 = Digest::MD5.hexdigest(match) | |
extractions[md5] = match | |
"{gfm-extraction-#{md5}}" | |
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 'carrierwave' | |
require 'fileutils' | |
# needed for the RMagick module in CarrierWave | |
def current_path | |
@current_path | |
end | |
include CarrierWave::RMagick |
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
Spork.each_run do | |
silence_warnings do | |
Dir[Rails.root.join('app/**/*.rb')].each do |file| | |
load file | |
end | |
end | |
FactoryGirl.reload | |
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
io.sockets.on('connection', function (socket) { | |
socket.on('message', function(topic){ | |
// adds this socket to the particular topic | |
socket.join(trend); | |
}); | |
// sends a message to all connected clients of topic 'my-trend' | |
socket.broadcast.to('my-topic').emit('a new post'); | |
socket.on('disconnect', function(topic){ |