Skip to content

Instantly share code, notes, and snippets.

View azamsharp's full-sized avatar

Mohammad Azam azamsharp

View GitHub Profile
class Block {
constructor() {
this.index = 0
this.previousHash = ""
this.hash = ""
this.nonce = 0
this.transactions = []
class Blockchain {
constructor(genesisBlock) {
this.blocks = []
}
}
addTransaction(transaction) {
this.transactions.push(transaction)
}
get key() {
return JSON.stringify(this.transactions) + this.index + this.previousHash + this.nonce
}
let Block = require('./block')
let sha256 = require('js-sha256')
class Blockchain {
constructor(genesisBlock) {
this.blocks = []
this.addBlock(genesisBlock)
let Block = require('./models/block')
let Transaction = require('./models/transaction')
let Blockchain = require('./models/blockchain')
// create genesis block
let genesisBlock = new Block()
let blockchain = new Blockchain(genesisBlock)
// create a transaction
private func registerGestureRecognizers() {
let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(tapped))
self.sceneView.addGestureRecognizer(tapGestureRecognizer)
}
@objc func tapped(recognizer :UIGestureRecognizer) {
guard let currentFrame = self.sceneView.session.currentFrame else {
return
}
let videoNode = SKVideoNode(fileNamed: "big_buck_bunny.mp4")
videoNode.play()
let skScene = SKScene(size: CGSize(width: 640, height: 480))
let addFloodButton = UIButton(frame: CGRect.zero)
addFloodButton.setImage(UIImage(named: "plus-image"), for: .normal)
addFloodButton.addTarget(self, action: #selector(addFloodAnnotation), for: .touchUpInside)
addFloodButton.translatesAutoresizingMaskIntoConstraints = false
self.view.addSubview(addFloodButton)
addFloodButton.centerXAnchor.constraint(equalTo: self.view.centerXAnchor).isActive = true
import Foundation
import UIKit
extension UIButton {
static func buttonForAddingAnnotation() -> UIButton {
let addFloodButton = UIButton(frame: CGRect.zero)
addFloodButton.translatesAutoresizingMaskIntoConstraints = false
addFloodButton.setImage(UIImage(named: "plus-image"), for: .normal)