Skip to content

Instantly share code, notes, and snippets.

import UIKit
class ViewController: UITableViewController {
override func viewDidLoad() {
super.viewDidLoad()
print("Hello")
}
}
@jasonyunjoonpark
jasonyunjoonpark / ParseAttemptWithDecodable.swift
Created February 10, 2018 03:37
Parse Attempt with Swift 4's Decodable protocol
import UIKit
struct Weather: Decodable {
let location: Location
let current: Current
}
struct Location: Decodable {
let name: String
}
@jasonyunjoonpark
jasonyunjoonpark / Game.swift
Created February 1, 2018 23:21
Word matching game by guessing individual letters
import Foundation
struct Game {
var word: String
var incorrectMovesRemaining: Int
}
@jasonyunjoonpark
jasonyunjoonpark / ToothFairy.sol
Created January 5, 2018 00:43
Smart contract between mom and child to pay child when the child confirms that his tooth has fallen out. The mom can confirm the validity through the contract and the contract will pay the child.
pragma solidity ^0.4.18;
contract ToothFairy {
address owner ;
address mom = 0xd2dE66A09F48A96b8cd429951ca70F79715beBCc;
address child = 0x80bFb3c5C9386e687936868A79f2e626F38a4AC2;
bool paymentStatusToChild = false;
enum ToothStatus {Mouth, WaitingForApproval, Fallen}
@jasonyunjoonpark
jasonyunjoonpark / Course.sol
Created January 4, 2018 19:11
Course registration contract with a variable fee amount that can only be set by the deployer of contract. Allows people to sign up by paying fee.
pragma solidity ^0.4.18;
contract Course {
address owner;
uint fee;
struct personalInfo {
string name;
uint age;
bool active;
@jasonyunjoonpark
jasonyunjoonpark / SavingsAccount.sol
Last active January 4, 2018 00:24
Smart contract that acts as a savings account for the deployer of the contract. Only the deployer can withdraw from this contract.
pragma solidity ^0.4.18;
contract SavingsAccount {
address owner;
event UpdateStatus(string msg);
event UserStatus(string msg, address user, uint amount);
function SavingsAccount() public {
owner = msg.sender;
}
@jasonyunjoonpark
jasonyunjoonpark / Paycheck.sol
Last active January 3, 2018 04:20
Smart contract that allows 4 employees to withdraw an equal amount of ether deposited to the contract by the deployer.
pragma solidity ^0.4.18;
contract Paycheck {
address[] Employees = [0xd2dE66A09F48A96b8cd429951ca70F79715beBCc, 0x80bFb3c5C9386e687936868A79f2e626F38a4AC2, randomaddress, randomaddress];
mapping (address => uint) WithdrawnAmount;
function Paycheck() public payable {
}
@jasonyunjoonpark
jasonyunjoonpark / Calculator.sol
Created January 1, 2018 18:49
Calculator contract that calls another contract to function.
pragma solidity ^0.4.19;
contract Calculator {
Math math = new Math();
function TwoPlusFour() public view returns (int) {
return math.add(2,4);
}
function TwoTimesFour() public view returns (int) {
return math.multiply(2,4);
@jasonyunjoonpark
jasonyunjoonpark / Inheritance.sol
Last active January 2, 2018 01:43
Two contracts inheriting a function from another contract.
pragma solidity ^0.4.19;
contract mortal {
address public owner;
function mortal() {
owner = msg.sender;
}
modifier onlyOwner {
@jasonyunjoonpark
jasonyunjoonpark / CallerContract.sol
Last active January 2, 2018 01:44
Using a contract to call another contract that exists in the same file.
pragma solidity ^0.4.19;
contract callerContract {
calledContract toBeCalled = new calledContract();
function receive() public constant returns (uint) {
return toBeCalled.getNumber();
}
}