The main difference between the two pages is the method of sending messages. Recieving messages is the same in both.
Send messages to iframe using iframeEl.contentWindow.postMessage
Recieve messages using window.addEventListener('message')
function isObject(value) { | |
// Avoid an old bug in Chrome 19-20 | |
// See https://code.google.com/p/v8/issues/detail?id=2291 | |
const type = typeof value; | |
return type === 'function' || (!!value && type === 'object'); | |
} | |
function ofPropertyChanges(obj, key) { | |
if (isObject(obj) === false) { | |
return Rx.Observable.return(undefined); |
# Add the "https://github.com/jwt/ruby-jwt" gem to your "Gemfile" | |
gem 'jwt' |
/* | |
Usage: | |
var jsoncheck = require('./wantsJSON') // path to file with this middleware function | |
app.use(jsoncheck) | |
app.get('/', function(req,res,next){ | |
if (req.wantsJSON) { | |
// serve JSON | |
} | |
if (req.wantsHTML) { |
# Example Dockerfile | |
FROM hello-world |
# Convert the .cer file into a .pem file: | |
$ openssl x509 -in aps_development.cer -inform der -out PushChatCert.pem | |
# Convert the private key’s .p12 file into a .pem file: | |
$ openssl pkcs12 -nocerts -in PushChatKey.p12 -out PushChatKey.pem | |
# Finally, combine the certificate and key into a single .pem file | |
$ cat PushChatCert.pem PushChatKey.pem > ck.pem | |
# At this point it’s a good idea to test whether the certificate works. |
Docker does not run natively on OSX, only Linux. Docker Machine was created to add a Linux VM environment to run Docker containers on OSX. Install using Homebrew:
brew install docker
brew install docker-machine
docker-machine create
func staticInsideFunction() { | |
struct Temp { static var hasAnimated = false } | |
if Temp.hasAnimated == false { | |
// ... do something only on the first function call. | |
Temp.hasAnimated = true | |
} else { | |
// ... do something on all subsequent function calls. | |
} | |
} |
# Mixin to (i.e. include in) any worker class that does FB API calls and should be throttled. | |
module FacebookThrottle | |
def perform_throttled(*args, &block) | |
options = args.extract_options! | |
user = User.find_by_fb_uid(options[:fb_uid]) | |
if user | |
if !user.valid_facebook_token? # A bitwise flag managed by flag_shih_tzu gem | |
puts "Skipping #{self.class} #{user.fb_uid}: Invalid Oauth Token for #{user}" | |
return false |