(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
| # You don't need Fog in Ruby or some other library to upload to S3 -- shell works perfectly fine | |
| # This is how I upload my new Sol Trader builds (http://soltrader.net) | |
| # Based on a modified script from here: http://tmont.com/blargh/2014/1/uploading-to-s3-in-bash | |
| S3KEY="my aws key" | |
| S3SECRET="my aws secret" # pass these in | |
| function putS3 | |
| { | |
| path=$1 |
| package main | |
| import ( | |
| "encoding/json" | |
| "fmt" | |
| "io/ioutil" | |
| "log" | |
| "net/http" | |
| "net/url" | |
| "os" |
| Step 1: Create Certificate .pem from Certificate .p12 | |
| Command: openssl pkcs12 -clcerts -nokeys -out apns-dev-cert.pem -in apns-dev-cert.p12 | |
| Step 2: Create Key .pem from Key .p12 | |
| Command : openssl pkcs12 -nocerts -out apns-dev-key.pem -in apns-dev-key.p12 | |
| Step 3: Optional (If you want to remove pass phrase asked in second step) | |
| Command : openssl rsa -in apns-dev-key.pem -out apns-dev-key-noenc.pem | |
| Step 4: Now we have to merge the Key .pem and Certificate .pem to get Development .pem needed for Push Notifications in Development Phase of App |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
| extension UIColor { | |
| convenience init(hex: Int) { | |
| self.init(red: CGFloat((hex & 0xFF0000) >> 16) / 255.0, | |
| green: CGFloat((hex & 0x00FF00) >> 8) / 255.0, | |
| blue: CGFloat(hex & 0x0000FF) / 255.0, | |
| alpha: 1.0) | |
| } | |
| } |
| ///////////////////////////////////////////////////////////////////// | |
| // finding the height of your UITableView's current content: | |
| ///////////////////////////////////////////////////////////////////// | |
| let tableView = UITableView() | |
| func contentHeight(forTableView tableView: UITableView) -> CGFloat { | |
| let lastSectionIndex = tableView.numberOfSections - 1 | |
| let lastRowIndex = tableView.numberOfRowsInSection(lastSectionIndex) |
| private func mapValueToRange(value: CGFloat, largerRangeMin: CGFloat, largerRangeMax: CGFloat, targetRangeMin: CGFloat, targetRangeMax: CGFloat) -> CGFloat { | |
| let largerSpan = largerRangeMax - largerRangeMin | |
| let targetSpan = targetRangeMax - targetRangeMin | |
| // Scaled to 0-1 range. | |
| var scaleBy = (value - largerRangeMin) / largerSpan | |
| if scaleBy < 0 { scaleBy = 0 } | |
| if scaleBy > 1 { scaleBy = 1 } | |
| import UIKit | |
| class CopyableLabel: UILabel { | |
| override init(frame: CGRect) { | |
| super.init(frame: frame) | |
| userInteractionEnabled = true | |
| addGestureRecognizer(UILongPressGestureRecognizer(target: self, action: #selector(CopyableLabel.showMenu(_:)))) | |
| } | |
| /* | |
| let myName = NSMutableAttributedString(string: " Hey, what's up!? ") | |
| let yellowOnBlack = Styles.textBackground(.redColor(), range: NSMakeRange(2, 3)) >>> Styles.textColor(.darkGrayColor()) | |
| let label = UILabel(frame: CGRectMake(10, 50, 200, 50)) | |
| label.attributedText = yellowOnBlack(myName) | |
| view.addSubview(label) | |
| */ | |
| import UIKit | |
| import Foundation |