Sinatra is a DSL for quickly creating web applications in Ruby with minimal effort:
# myapp.rb require 'sinatra' get '/' do 'Hello world!'
var pubsub = function(l, u, r, i) { // cool! 闭包并且初始化vars | |
return function(n, f) { | |
r = l[n] = l[n] || [], i = -1; | |
if (f && f.call) r.push(f); | |
else while (r[++i]) r[i].apply(u, arguments); | |
} | |
}({}); | |
// subscribe to event | |
pubsub("eat_cookie", function() { |
cfhdojbkjhnklbpkdaibdccddilifddb Adblock Plus 10000000 | |
gighmmpiobklfepjocnamgkkbiglidom AdBlock 10000000 | |
efaidnbmnnnibpcajpcglclefindmkaj Adobe Acrobat 10000000 | |
gomekmidlodglbbmalcneegieacbdmki Avast Online Security 10000000 | |
eofcbnmajmjmplflapaojjnihcjkigck Avast SafePrice 10000000 | |
chfdnecihphmhljaaejmgoiahnihplgn AVG Web TuneUp 10000000 | |
flliilndjeohchalpbbcdekjklbdgfkk Avira Browser Safety 10000000 | |
gpdjojdkbbmdfjfahjcgigfpmkopogic Pin It Button 10000000 | |
lifbcibllhkdhoafpjfnlhfpfgnpldfl Skype 10000000 | |
mallpejgeafdahhflmliiahjdpgbegpk FromDocToPDF 9298905 |
// ==UserScript== | |
// @name 豆藤 Bean vine | |
// @namespace http://userscripts.org/scripts/show/49911 | |
// @description 为豆瓣(www.douban.com)添加各种人性化的功能。 | |
// @require http://autoupdate.sinaapp.com/autoupdatehelper.js | |
// @include http* | |
// @version 2012.12.19 | |
// @grant GM_getValue | |
// @grant GM_setValue | |
// @grant GM_addStyle |
<!doctype html> | |
<html manifest="StickyNotes.manifest"> | |
<head> | |
<title>WebKit HTML 5 SQL Storage Notes Demo</title> | |
<style> | |
body { | |
font-family: 'Lucida Grande', 'Helvetica', sans-serif; | |
} |
require "socket" | |
socket = TCPSocket.open("www.theonion.com", "80") | |
TCPSocket.open("www.theonion.com", 80) do |socket| | |
socket.puts "GET / HTTP/1.0\n\n" | |
puts socket.read | |
end |
data:text/html,<html lang="en"><head><style> html,body { height: 100% } #note { width: 100%; height: 100% } </style> <script> var note, html, timeout; window.addEventListener('load', function() { note = document.getElementById('note'); html = document.getElementsByTagName('html')[0]; html.addEventListener('keyup', function(ev) { if (timeout) clearTimeout(timeout); timeout = setTimeout(saveNote, 100); }); restoreNote(); note.focus(); }); function saveNote() { localStorage.note = note.innerText; timeout = null; } function restoreNote() { note.innerText = localStorage.note || ''; } </script> </head><body><h1>Notepad (type below, notes persist)</h1> <p id="note" contenteditable=""></p> </body></html> |
# RR | |
# RR (Double Ruby) is a test double framework that features a rich selection of double techniques and a terse syntax. | |
# | |
# | |
# one of the goal of RR is to make doubles more scannable. | |
# accomplished by making the double declartion look as much as the actual method invocation as possible | |
flexmock(User).should_receive(:find).with('42').and_return(jane) # Flexmock | |
User.should_receive(:find).with('42').and_return(jane) # Rspec | |
User.expects(:find).with('42').returns {jane} # Mocha | |
User.should_receive(:find).with('42') {jane} # Rspec using return value blocks |
通常来说,JS 开发者不习惯网站开发测试,JS 测试一般会很局限,难以实施,运行慢和写起来费时。
测试类型可以分为很多种,具体可以参考[reference]。但最主要有如下三种:
A complete list of RxJS 5 operators with easy to understand explanations and runnable examples.