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
| It uses WebSocket, EventSource, or HTTP polling to establish a persistent connection between every client on the server. It uses the best network transport available in the user's browser. The server's job is to accept messages from clients and route them to other clients based on the channels that each client is subscribed to. If a client has a socket connection, the message is pushed immediately. If it has an HTTP connection, the message is queued on the server and returned the next time the client sends a polling request -- this makes sure that clients don't drop messages while they are not connected to the server. |
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
| def broadcast_message | |
| uri = URI.parse('http://ws.192.168.2.3.xip.io:9292/faye') | |
| message = {:channel => '/devices/location/coordinates/b8de8b239eafb3f7', :data => "this is a test message"} | |
| Net::HTTP.post_form(uri, :message => message.to_json) | |
| 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
| curl http://your_domain_com_and_port_no/faye -d 'message={"channel":"your/channel/here", "data":["latitude_here","longitude_here"]}' | |
| #ex: | |
| curl http://ws.192.168.2.4.xip.io:9292/faye -d 'message={"channel":"/devices/location/coordinates/b8de8b239eafb3f7", "data":["52.38021","4.895679"]}' |
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
| $(document).ready(function() { | |
| if( typeof(WebSocket) != "function" ) { | |
| // Display error message here ! | |
| } | |
| }); |
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
| <div id="container"> | |
| <ul id="menu"> | |
| <li><a href="#">About Me</a> | |
| <ul> | |
| <li><a href="#">Lorem ipsum dolor</a></li> | |
| <li><a href="#">Maecenas lacinia sem</a></li> | |
| <li><a href="#">Suspendisse fringilla</a></li> | |
| </ul> | |
| </li> | |
| <li><a href="#">Portfolio</a> |
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
| <div class="timer-group"> | |
| <div class="timer hour"> | |
| <div class="hand"><span></span></div> | |
| <div class="hand"><span></span></div> | |
| </div> | |
| <div class="timer minute"> | |
| <div class="hand"><span></span></div> | |
| <div class="hand"><span></span></div> | |
| </div> | |
| <div class="timer second"> |
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
| [ | |
| { | |
| device_id: 6, | |
| outgoing: 6, | |
| incoming: 5 | |
| }, | |
| { | |
| device_id: 5, | |
| outgoing: 6, | |
| incoming: 5 |
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
| %html | |
| %body | |
| %div.container | |
| %div.search-container | |
| %input{:type => "text", :placeholder => "search"} | |
| %a.button | |
| %i.icon-search |
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 'irb/completion' | |
| require "irb/ext/save-history" | |
| IRB.conf[:PROMPT_MODE] = :SIMPLE | |
| IRB.conf[:SAVE_HISTORY] = 1000 | |
| IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb_history" | |
| # Break out of the Bundler jail | |
| # from https://github.com/ConradIrwin/pry-debundle/blob/master/lib/pry-debundle.rb | |
| if defined? Bundler |
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
| # DOES NOT HANDLE 'half a minute' AND 'about a minute' among others | |
| # dotiw is the distance_of_time_in_words | |
| if dotiw | |
| # split it with ' ' and get an array. | |
| # Your array contains things such as : | |
| # ["1", "year,", "11", "months,", "27", "days,", "13", "hours,", "and", "39", "minutes"] | |
| split_distance_of_time_into_array = dotiw.split(' ') | |
| total_time=0 | |
| split_distance_of_time_into_array.each_with_index do |t,index| |