Skip to content

Instantly share code, notes, and snippets.

View azamsharp's full-sized avatar

Mohammad Azam azamsharp

View GitHub Profile
let btn = UIButton.buttonForAddingAnnotation()
extension UIView {
func addToParent(view :UIView) -> UIView {
view.addSubview(self)
return self
}
func bottomMargin(from view: UIView, margin :CGFloat) -> UIView {
self.bottomAnchor.constraint(equalTo: view.bottomAnchor, constant: margin).isActive = true
let addFloodButton = UIButton.buttonForAddingAnnotation()
.addToParent(view: self.view)
.centerX(in: self.view)
.bottomMargin(from: self.view, margin: -40)
.setWidth(width: 75)
.setHeight(height: 75) as! UIButton
addFloodButton.addTarget(self, action: #selector(addFloodAnnotationButtonPressed), for: .touchUpInside)
@objc func tapped(recognizer :UIGestureRecognizer) {
guard let currentFrame = self.sceneView.session.currentFrame else {
return
}
// create a web view
let webView = UIWebView(frame: CGRect(x: 0, y: 0, width: 640, height: 480))
let request = URLRequest(url: URL(string: "http://www.amazon.com")!)
class Transaction : Codable {
var driverLicenseNumber :String
var voilationType :String
var noOfVoilations :Int = 1
var isDrivingLicenseSuspended :Bool = false
init(licenseNoHash :String, voilationType :String) {
self.driverLicenseNumber = licenseNoHash
self.voilationType = voilationType
class Block : Codable {
var index :Int = 0
var previousHash :String = ""
var hash :String!
var nonce :Int
private (set) var transactions :[Transaction] = [Transaction]()
var key :String {
class Blockchain : Codable {
var blocks :[Block] = [Block]()
init(genesisBlock :Block) {
addBlock(genesisBlock)
}
self.drop.get("blockchain") { request in
let blockchain = self.blockchainService.getBlockchain()
return try! JSONEncoder().encode(blockchain)
}
class DrivingRecordSmartContract : Codable {
func apply(transaction :Transaction, allBlocks :[Block]) {
allBlocks.forEach { block in
block.transactions.forEach { trans in
if trans.driverLicenseNumber == transaction.driverLicenseNumber {
transaction.noOfVoilations += 1
class DrivingRecordSmartContract : Codable {
func apply(transaction :Transaction, allBlocks :[Block]) {
allBlocks.forEach { block in
block.transactions.forEach { trans in
if trans.driverLicenseNumber == transaction.driverLicenseNumber {
transaction.noOfVoilations += 1