Skip to content

Instantly share code, notes, and snippets.

View harshvishu's full-sized avatar
🍥
Learning

हर्ष • Harsh • ハラシャ harshvishu

🍥
Learning
View GitHub Profile
@harshvishu
harshvishu / Swift-Blockchain-Chain-NewTransaction.sh
Created January 8, 2019 17:39
Swift-Blockchain-NewTransaction
curl -X POST \
http://localhost:5000/transactions/new \
-H 'content-type: application/json' \
-d '{
"sender": "d4ee26eee15148ee92c6cd394edd974e",
"recipient": "4as226eee1514743e92c6cd394edd974f",
"amount": 5
}'
@harshvishu
harshvishu / Swift-Blockchain-Chain-Chain.sh
Created January 8, 2019 17:39
Swift-Blockchain-Chain-Chain
curl -X GET \
http://localhost:5000/chain \
import Foundation
public typealias CompletionHandler = () -> Void
protocol CountDown: NSObjectProtocol {
// 1
var timeElapsed: TimeInterval {get set}
var timeLimit: TimeInterval {get set}
// 2
//
// CountDownTimer.swift
//
// Created by Harsh Vishwakarma.
//
import Foundation
import UIKit
final class CountDownTimer: NSObject, CountDown {
public typealias CompletionHandler = () -> Void
class LiftOffViewController : UIViewController {
var countDownTimer: CountDown?
@IBOutlet weak var labelTimeLeft: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
@harshvishu
harshvishu / UIViewController+ShorthandAlerts.swift
Created August 1, 2020 06:55 — forked from aydenp/UIViewController+ShorthandAlerts.swift
Creating alerts on iOS is annoying. This extension allows you to easily present alerts on view controllers. It also improves UIAlertAction by adding a quicker more Swift-like shorthand for making actions.
//
// UIViewController+ShorthandAlerts.swift
//
// Created by Ayden Panhuyzen on 2017-07-31.
// Copyright © 2017-2018 Ayden Panhuyzen. All rights reserved.
// https://gist.github.com/aydenp
//
import UIKit
@harshvishu
harshvishu / PercentLayoutConstraint.swift
Created August 20, 2020 07:25
PercentLayoutConstraint
// PercentLayoutConstraint.swift
import Foundation
import UIKit
@IBDesignable
final class PercentLayoutConstraint: NSLayoutConstraint {
@IBInspectable var marginPercent: CGFloat = 0
var screenSize: (width: CGFloat, height: CGFloat) {
//
// ConnectorView.swift
// Helper
//
// Created by Harsh 20/08/20.
// Copyright © 2020 Harsh. All rights reserved.
//
import UIKit
@harshvishu
harshvishu / Cargo.toml
Last active March 9, 2021 08:42
'Blockchain in Rust' snippets
[package]
name = "blockchain"
version = "0.1.0"
authors = ["Harsh Vishwakarma"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
chrono = { version = " 0.4", features = ["serde"] }
@harshvishu
harshvishu / Block.rs
Last active March 4, 2021 16:03
Block & Chain skeleton
pub struct Block {
index: u64,
timestamp: DateTime<Utc>,
transactions: Vec<Transaction>,
proof: u64,
previous_hash: String,
}