This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension UIImage { | |
func rgb2GrayScale() -> UIImage? { | |
let rect = CGRect(x: 0, y: 0, width: size.width, height: size.height) | |
guard let context = CGContext(data: nil, | |
width: Int(size.width), | |
height: Int(size.height), | |
bitsPerComponent: 8, | |
bytesPerRow: 0, | |
space: CGColorSpaceCreateDeviceGray(), | |
bitmapInfo: CGImageAlphaInfo.none.rawValue), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import MetalKit | |
struct FrameUniforms { | |
var projectionViewMatrinx: matrix_float4x4 | |
var normalMatrinx: matrix_float3x3 | |
} | |
class ViewController: NSViewController, MTKViewDelegate { | |
private let defaultCameraMatrix = Matrix.lookAt(eye: float3(0, 2, 6), center: float3(), up: float3(0, 1, 0)) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
guard let url = Bundle.main.url(forResource: "embedded", withExtension: "mobileprovision") else { | |
return | |
} | |
guard let data = try? Data(contentsOf: url), | |
let start = "<?xml".data(using: .utf8), | |
let end = "</plist>".data(using: .utf8) | |
let startRange = data.range(of: start), | |
let endRange = data.range(of: end) else { | |
return |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let CRLF = "\r\n" | |
let fileData = try! Data(contentsOf: URL(string: "ローカルのパス")!) | |
let filename = "test.txt" // ファイル名 | |
let formName = "filename" // formでのファイルのname | |
let type = "text/plain" // ファイルのタイプ | |
let titleData = "hoge" // 入力されたタイトルデータ | |
let titleName = "title" // formでのタイトルのname | |
let boundary = String(format: "----iOSURLSessionBoundary.%08x%08x", arc4random(), arc4random()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="jp"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>アップロード</title> | |
</head> | |
<body> | |
<form name="upload"> | |
タイトル <input name="title"> | |
<br> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import MultipeerConnectivity | |
class P2PConnectivity: NSObject, MCSessionDelegate, | |
MCNearbyServiceAdvertiserDelegate, MCNearbyServiceBrowserDelegate { | |
static let manager = P2PConnectivity() | |
var state = MCSessionState.notConnected { | |
didSet { | |
stateChangeHandler?(state) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'vendor/autoload.php'; | |
use GuzzleHttp\Client; | |
use GuzzleHttp\Pool; | |
$tokenList = [ | |
'a72d4aa72b3e506e8970f5d07feb95c4f7cb598c955115eca0b6132f38b5cb1e', | |
... | |
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use GuzzleHttp\Client; | |
use GuzzleHttp\Pool; | |
$urls = [ | |
'https://example.com/1', | |
'https://example.com/2', | |
... | |
]; | |
$client = new Client(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum NotificationKey: String { | |
// ここで使いたい名前を一元管理 | |
case ChangeStatus | |
} | |
extension NotificationCenter { | |
func post(key: NotificationKey, object: Any? = nil) { | |
post(Notification(key: key, object: object)) | |
} | |