Skip to content

Instantly share code, notes, and snippets.

View jongwonwoo's full-sized avatar

Jongwon Woo jongwonwoo

View GitHub Profile
#!/bin/bash
# This is a companion script to https://github.com/konstantin-kelemen/arduino-amiibo-tools
# The original post this was crafted for was https://games.kel.mn/en/create-amiibo-clones-with-arduino/
# For more info go to https://games.kel.mn/en/companion-script-to-simplify-amiibo-cloning-with-arduino/
#requirements:
#sha1sum (part of coreutils)
#xxd (part of vim)
#hexdump
#amiitool (https://github.com/socram8888/amiitool)
@jongwonwoo
jongwonwoo / amiibo.sh
Created March 14, 2021 07:34 — forked from gretel/amiibo.sh
query, read, encode (using amiitool), write and lock NTAG215 (using uFR Nano hardware) for the purpose of researching Nintendo's Amiibo infrastructure Raw
#!/bin/bash
# This is a companion script to https://github.com/konstantin-kelemen/arduino-amiibo-tools
# The original post this was crafted for was https://games.kel.mn/en/create-amiibo-clones-with-arduino/
# For more info go to https://games.kel.mn/en/companion-script-to-simplify-amiibo-cloning-with-arduino/
#requirements:
#sha1sum (part of coreutils)
#xxd (part of vim)
#hexdump
#amiitool (https://github.com/socram8888/amiitool)
@jongwonwoo
jongwonwoo / JWScrollStateMachine.swift
Created April 22, 2017 06:30
State Machine for scroll events
//
// JWScrollStateMachine.swift
// JWThumbnailsNavigation
//
// Created by Jongwon Woo on 26/03/2017.
// Copyright © 2017 CocoaPods. All rights reserved.
//
import UIKit
public class ElasticTransition : NSObject, ElasticMotionStateMachineDelegate {
init(presentedViewController: UIViewController, presentingViewWidth: Float) {
self.stateMachine = ElasticMotionStateMachine(ElasticMotionDirection.Right, threshold: threshold, vibrationSec: 2.0)
self.stateMachine.delegate = self
}
func elasticMotionStateMachine(stateMachine: ElasticMotionStateMachine, didChangeState state: ElasticMotionState, deltaPoint: CGPoint) {
if stateMachine.direction == ElasticMotionDirection.Right {
let fullOpenedWidth = CGFloat(presentingViewWidth)
switch state {
func elasticMotionStateMachine(stateMachine: ElasticMotionStateMachine, didChangeState state: ElasticMotionState, deltaPoint: CGPoint) {
switch state {
case .MayOpen:
let newOriginX = self.view.frame.origin.x + deltaPoint.x
if newOriginX >= 0 && newOriginX < CGFloat(threshold) {
self.view.center = CGPointMake(self.view.center.x + deltaPoint.x, self.view.center.y)
}
// other state
}
class ViewController: UIViewController {
@IBAction func handlePan(recognizer: UIPanGestureRecognizer) {
let currentPoint = recognizer.translationInView(self.view)
if let stateMachine = self.stateMachine {
switch recognizer.state {
case .Began, .Changed:
stateMachine.keepMoving(currentPoint)
default:
stateMachine.stopMoving()
enum ElasticMotionState {
case Closed
case MayOpen
case WillOpen
case Opened
case MayClose
case WillClose
}
class ElasticMotionStateMachine {
func keepMoving(currentPoint: CGPoint) {
if self.state == .Closed || self.state == .WillClose || self.state == .Opened || self.state == .WillOpen {
self.beginPoint = currentPoint
self.totalMovingPoint = CGPointZero
}
let delta = self.deltaPointFromCurrentPoint(currentPoint)
self.addMovingPoint(delta)
func panGestureRecognized(recognizer: UIPanGestureRecognizer) {
if recognizer.state == .Began {
setupContentViewShadow()
originalPoint = CGPointMake(contentViewContainer.center.x - CGRectGetWidth(contentViewContainer.bounds) / 2.0,
contentViewContainer.center.y - CGRectGetHeight(contentViewContainer.bounds) / 2.0)
menuViewContainer.transform = CGAffineTransformIdentity
if (scaleBackgroundImageView) {
backgroundImageView.transform = CGAffineTransformIdentity
class Country {
let name:String
var capitalCity:City?
init (name:String, capitalName:String) {
self.name = name
self.capitalCity = City(name: capitalName, country: self)
}
}
class City {