If the client makes a request, let's say this is an initial request to a resource that the client knows nothing about. It goes along and does a little something like this:
GET /foo HTTP/1.1
Accept: text/html
dso.search = function() { | |
var data = false; | |
var search = $('#search'); | |
var template = _.template('<li><a href="<%=url%>"><span class="title"><%=title%></span><small><%=subtitle%></small><small class="date"><%=date%></small></a></li>'); | |
var find = function(phrase) { | |
if (!data) return $.ajax({ | |
url: '/search.json', | |
dataType: 'json', | |
success: function(resp) { | |
data = _(resp).chain() |
function dateToArray(ts, length, utc) { | |
var length = length || 6, | |
d = new Date(ts), | |
utc = Boolean(local) || true; | |
if (utc) { | |
return [d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()].slice(0, length); | |
} else { | |
return [d.getFullYear(), d.getMonth(), d.getDate(), d.getHours(), d.getMinutes(), d.getSeconds(), d.getMilliseconds()].slice(0, length); | |
} |
class PostsController < ActionController::Base | |
def create | |
Post.create(post_params) | |
end | |
def update | |
Post.find(params[:id]).update_attributes!(post_params) | |
end | |
private |
#!/bin/sh | |
# ------------------------------------------------------------------------------ | |
# SOME INFOS : fairly standard (debian) init script. | |
# Note that node doesn't create a PID file (hence --make-pidfile) | |
# has to be run in the background (hence --background) | |
# and NOT as root (hence --chuid) | |
# | |
# MORE INFOS : INIT SCRIPT http://www.debian.org/doc/debian-policy/ch-opersys.html#s-sysvinit | |
# INIT-INFO RULES http://wiki.debian.org/LSBInitScripts | |
# INSTALL/REMOVE http://www.debian-administration.org/articles/28 |
def disable_notifications! | |
auth_url = "https://twitter.com/login" | |
notifications_url = "https://twitter.com/settings/notifications" | |
agent = Mechanize.new | |
page = agent.get(auth_url) | |
puts "DISABLING NOTIFICATIONS for #{self.username}" | |
puts "Logging in..." | |
page.forms_with(:action => 'https://twitter.com/sessions') do |forms| |
Pragma: akamai-x-cache-on, akamai-x-cache-remote-on, akamai-x-check-cacheable, akamai-x-get-cache-key, akamai-x-get-extracted-values, akamai-x-get-nonces, akamai-x-get-ssl-client-session-id, akamai-x-get-true-cache-key, akamai-x-serial-no |
using mocha/chai/sinon for node.js unit-tests? check out my utility: mocha-stirrer to easily reuse test components and mock require dependencies