Skip to content

Instantly share code, notes, and snippets.

// https://muukii.design/engineering/2017/10/17/create-cgaffinetransform-that-represents-cgrect-to-cgrect
extension CGAffineTransform {
init(from: CGRect, to: CGRect) {
self = CGAffineTransform(
a: to.width / from.width,
b: 0,
c: 0,
@sora0077
sora0077 / MKMapView+Extensions.swift
Last active November 24, 2020 14:41 — forked from appsandwich/MKMapView+Extensions
Get & set the zoom level of a MKMapView
import MapKit
// http://troybrant.net/blog/2010/01/set-the-zoom-level-of-an-mkmapview/
private let mercadorRadius: Double = 85445659.44705395
private let mercadorOffset: Double = 268435456
private func longitudeToPixelSpaceX(longitude: Double) -> Double {
return round(mercadorOffset + mercadorRadius * longitude * .pi / 180.0);
}
# setup
# pip install cryptography pyjwt
# ref.
# http://gobiko.com/blog/token-based-authentication-http2-example-apns/
import jwt
import time
ALGORITHM = 'ES256'
@sora0077
sora0077 / HardRubberbandView.swift
Last active June 10, 2017 02:05
HardRubberbandView.swift
import UIKit
final class HardRubberbandView: UIView, UIScrollViewDelegate {
var contentSize: CGSize = .zero {
didSet {
scrollView.contentSize = contentSize
contentView.frame.size = contentSize
}
}
@objc
//: [Previous](@previous)
import Foundation
import UIKit
import XCPlayground
enum ParseError: Swift.Error {
case notSatisfy
}
//
// main.swift
// Formula
//
// Created by 林達也 on 2016/03/20.
// Copyright © 2016年 jp.sora0077. All rights reserved.
//
//: Playground - noun: a place where people can play
// Playground - noun: a place where people can play
import UIKit
import XCPlayground
protocol ObjectProtocol {}
protocol QuerySetProtocol {
}
import UIKit
import XCPlayground
enum Path: Equatable {
case Current
case Parent
case Root
case Letter(String)
}
@sora0077
sora0077 / How To Install
Last active August 29, 2015 14:14
テストデータ生成用Pythonコード
```
pip install rstr
pip install jinja2
```
`Python 3.4.1`
#import <Foundation/Foundation.h>
@interface NSString (NSUserDefaults)
@property BOOL defaultsBool;
@property NSInteger defaultsInteger;
@property float defaultsFloat;
@property double defaultsDouble;
@property id defaultsObject;
@property NSData *defaultsData;
@property NSString *defaultsString;