Skip to content

Instantly share code, notes, and snippets.

View cheeyeo's full-sized avatar
💭
Researching on use of transformers in computer vision

Chee Yeo cheeyeo

💭
Researching on use of transformers in computer vision
View GitHub Profile
@cheeyeo
cheeyeo / webmock_helpers.rb
Created January 21, 2011 18:33
Generic webmock methods inside spec_helper.rb for rspec tests
# 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
@cheeyeo
cheeyeo / webmock_example_1.rb
Created January 21, 2011 18:38
Example of WebMock stubbing request
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
#!/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 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;
}
@cheeyeo
cheeyeo / README.md
Created February 14, 2011 21:22 — forked from mloughran/README.md

Getting started

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.

@cheeyeo
cheeyeo / gfm.rb
Created February 15, 2011 20:25 — forked from mojombo/gfm.rb
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
@cheeyeo
cheeyeo / README.md
Created February 18, 2011 19:19 — forked from anonymous/README.md
EM + Twitter Stream example

Getting started

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.

require 'rubygems'
require 'carrierwave'
require 'fileutils'
# needed for the RMagick module in CarrierWave
def current_path
@current_path
end
include CarrierWave::RMagick
@cheeyeo
cheeyeo / gist:1242013
Created September 26, 2011 10:56 — forked from jugyo/gist:1210929
Spork.each_run
Spork.each_run do
silence_warnings do
Dir[Rails.root.join('app/**/*.rb')].each do |file|
load file
end
end
FactoryGirl.reload
end
@cheeyeo
cheeyeo / node_socketio_example.js
Created September 26, 2011 23:41
socket.io nodejs channels
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){