Skip to content

Instantly share code, notes, and snippets.

@Warry
Forked from NV/README.md
Created January 24, 2011 09:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Warry/792990 to your computer and use it in GitHub Desktop.
Save Warry/792990 to your computer and use it in GitHub Desktop.

XRefresh for Chrome

Deprecated! Use LiveReload instead.

via xrefresh#17

How to use

  • ruby ws_dir_watcher.rb ~/my_site
  • Open chrome://extensions/
  • "Developer mode", then press "Load unpacked extension" button
  • edit ~/my_site/something and XRefresh reload current tab for you

Similar stuff

Google Chrome Repl

<script>
var ws = new WebSocket("ws://localhost:41258/");
ws.onmessage = function(e){
try {
chrome.tabs.executeScript(null, {code:'location.reload();'});
} catch (er) {
console.warn(er);
}
};
</script>
{
"name": "XRefresh",
"version": "0.1",
"background_page": "background.html",
"permissions": [
"tabs",
"http://*/*"
]
}
# Usage: ruby ws_dir_watcher.rb ~/my_site
require 'em-websocket'
require 'directory_watcher'
EM.kqueue = true
dw = DirectoryWatcher.new ARGV[0], :glob => '**/*', :scanner => :em
EventMachine::WebSocket.start(:host => "0.0.0.0", :port => 41258, :debug => true) do |ws|
ws.onopen {
dw.add_observer {
|*args| args.each {|event|
ws.send event if event[:type] == :modified
}
}
dw.start
}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment