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
######## | |
# app.rb | |
# | |
require 'sinatra/base' | |
require_relative 'helpers' | |
require_relative 'routes/secrets' | |
require_relative 'routes/sessions' |
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
=calc($property, $expression) | |
#{$property}: -moz-calc(#{$expression}) | |
#{$property}: -o-calc(#{$expression}) | |
#{$property}: -webkit-calc(#{$expression}) | |
#{$property}: calc(#{$expression}) |
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
response = Faraday.get 'http://www.google.com' | |
puts response | |
puts 'Done!' |
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
request('http://www.google.com', function(error, response, body) { | |
console.log(body); | |
}); | |
console.log('Done!'); |
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
function init() { | |
var link = document.getElementById("foo"); | |
link.addEventListener("click", function changeColor() { | |
this.style.color = "burlywood"; | |
}); | |
} | |
init(); |
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
function f() { | |
console.log("foo"); | |
setTimeout(g, 0); | |
console.log("baz"); | |
h(); | |
} | |
function g() { | |
console.log("bar"); | |
} |
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
// our worker, which does some CPU-intensive operation | |
var reportResult = function(e) { | |
pi = SomeLib.computePiToSpecifiedDecimals(e.data); | |
postMessage(pi); | |
}; | |
onmessage = reportResult; |
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
// our main code, in a <script>-tag in our HTML page | |
var piWorker = new Worker("pi_calculator.js"); | |
var logResult = function(e) { | |
console.log("PI: " + e.data); | |
}; | |
piWorker.addEventListener("message", logResult, false); | |
piWorker.postMessage(100000); |
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
function changeHeaderDeferred() { | |
var header = document.getElementById("header"); | |
setTimeout(function changeHeader() { | |
header.style.color = "red"; | |
return false; | |
}, 100); | |
return false; |
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
// in the test code: | |
it("updates the page title on click", function() { | |
assert.equals(view.find("h1").text(), "before update"); | |
view.find("button").trigger("click"); // uh oh-async! | |
assert.equals(view.find("h1").text(), "after update"); // will fail due to callback being part of different stack | |
}); |