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')
| # nil? can be used on any Ruby object. It returns true only if the object is nil. | |
| nil.nil? # => true | |
| [].nil? # => false | |
| {}.nil? # => false | |
| "".nil? # => false | |
| " ".nil? # => false | |
| true.nil? # => false | |
| # empty? can be used on some Ruby objects including Arrays, Hashes and Strings. It returns true only if the object's length is zero. | |
| nil.empty? # NoMethodError: undefined method `empty?' for nil:NilClass |
| var https = require('https'); | |
| var gunzip = require('zlib').createGunzip(); | |
| var options = { | |
| host: 'api.stackexchange.com', | |
| path: '/2.1/info?site=stackoverflow' | |
| }; | |
| https.get(options, function(res) { | |
| var body = ''; |
| import Foundation | |
| import CryptoSwift | |
| extension String { | |
| func aesEncrypt(key: String, iv: String) throws -> String{ | |
| let data = self.dataUsingEncoding(NSUTF8StringEncoding) | |
| let enc = try AES(key: key, iv: iv, blockMode:.CBC).encrypt(data!.arrayOfBytes(), padding: PKCS7()) | |
| let encData = NSData(bytes: enc, length: Int(enc.count)) | |
| let base64String: String = encData.base64EncodedStringWithOptions(NSDataBase64EncodingOptions(rawValue: 0)); |
| import Foundation | |
| import CryptoSwift | |
| extension String { | |
| func aesEncrypt(key: String, iv: String) -> String { | |
| let data = self.dataUsingEncoding(NSUTF8StringEncoding) | |
| let enc = AES(key: key, iv: iv, blockMode:.CBC)?.encrypt(data!.arrayOfBytes(), padding: PKCS7()) | |
| let encData = NSData(bytes: enc!, length: Int(enc!.count)) | |
| let base64String: String = encData.base64EncodedStringWithOptions(NSDataBase64EncodingOptions(rawValue: 0)); |
| /// | |
| /// Author : Gaurav D. Sharma | |
| /// Run on Swift 3.0 | |
| /// IBM swift sandbox : https://swiftlang.ng.bluemix.net/#/repl | |
| /// | |
| //// Are you using ObjectMapper for model mapping in swift. | |
| //// Object creation like Mapper<T>().map(jsonString) | |
| //// And you are irritaed with the type name passing and syntex memorization | |
| //// |
| # 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. |
| @interface Model (AdditionalParam) | |
| @property (nonatomic, strong) NSString <Optional> * new_key_name; | |
| @end |
| - (void)setMaskImage { | |
| CALayer *mask = [CALayer layer]; | |
| mask.contents = (id)[[UIImage imageNamed:@"infoLogo"] CGImage]; | |
| mask.frame = self.imgItem.bounds; | |
| self.imgItem.layer.mask = mask; | |
| self.imgItem.layer.masksToBounds = YES; | |
| self.imgItem.contentMode = UIViewContentModeCenter; | |
| } |
| - (CGPathRef)renderRect:(UIView*)imgView { | |
| UIBezierPath *path = [UIBezierPath bezierPathWithRect:imgView.bounds]; | |
| return path.CGPath; | |
| } | |
| - (CGPathRef)renderTrapezoid:(UIView*)imgView { | |
| CGSize size = imgView.bounds.size; | |
| UIBezierPath *path = [UIBezierPath bezierPath]; | |
| [path moveToPoint:CGPointMake(size.width * 0.33f, size.height * 0.66f)]; |