Skip to content

Instantly share code, notes, and snippets.

View trilliwon's full-sized avatar
🎯
Focusing

WonJo trilliwon

🎯
Focusing
View GitHub Profile
@trilliwon
trilliwon / isPerfectSquare.py
Created August 19, 2019 05:49
is Perfect Square In Python3
def isPerfectSquare(x):
sr = math.sqrt(x)
return (sr - math.floor(sr)) == 0
@trilliwon
trilliwon / coffe&code.swift
Last active January 9, 2020 04:57
☕️
🏋🏻‍♂️ 👨🏻‍💻
@trilliwon
trilliwon / PlayButton.swift
Created July 20, 2019 10:26
Play pause button
//
// PlayButton.swift
// ProgressView
//
// Created by WonJo on 10/03/2019.
// Copyright © 2019 WonJo. All rights reserved.
//
import UIKit
class RaindropView: UIView {
var images: [CGImage] {
return [UIImage(named: "rain"),
UIImage(named: "rain"),
UIImage(named: "rain"),
UIImage(named: "rain"),
UIImage(named: "rain")].map({ $0?.cgImage }).compactMap({ $0 })
}
@trilliwon
trilliwon / AVSpeechSynthesizer+Rx.swift
Created June 25, 2019 14:01
AVSpeechSynthesizer+Rx
#if os(iOS)
import AVFoundation
import RxCocoa
import RxSwift
extension AVSpeechSynthesizer: HasDelegate {
public typealias Delegate = AVSpeechSynthesizerDelegate
}
@trilliwon
trilliwon / increaseBuildNumber.sh
Created June 6, 2019 05:24
increaseBuildNumber.sh
buildNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "${PROJECT_DIR}/${INFOPLIST_FILE}")
buildNumber=$(($buildNumber + 1))
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "${PROJECT_DIR}/${INFOPLIST_FILE}"
@trilliwon
trilliwon / makeTextureFromCVPixelBuffer.swift
Created May 7, 2019 04:48
makeTextureFromCVPixelBuffer
func makeTextureFromCVPixelBuffer(pixelBuffer: CVPixelBuffer, textureFormat: MTLPixelFormat) -> MTLTexture? {
let width = CVPixelBufferGetWidth(pixelBuffer)
let height = CVPixelBufferGetHeight(pixelBuffer)
// Create a Metal texture from the image buffer.
var cvTextureOut: CVMetalTexture?
CVMetalTextureCacheCreateTextureFromImage(kCFAllocatorDefault, textureCache, pixelBuffer, nil, textureFormat, width, height, 0, &cvTextureOut)
guard let cvTexture = cvTextureOut, let texture = CVMetalTextureGetTexture(cvTexture) else {
CVMetalTextureCacheFlush(textureCache, 0)
@trilliwon
trilliwon / bobp-python.md
Created April 19, 2019 02:53 — forked from sloria/bobp-python.md
A "Best of the Best Practices" (BOBP) guide to developing in Python.

The Best of the Best Practices (BOBP) Guide for Python

A "Best of the Best Practices" (BOBP) guide to developing in Python.

In General

Values

  • "Build tools for others that you want to be built for you." - Kenneth Reitz
  • "Simplicity is alway better than functionality." - Pieter Hintjens
class DownloadCircleProgressView: UIView {
// Interface
var progress: Float = 0.0 {
didSet {
// animate from [oldValue] to [newValue]
animateProgressLayer(from: CGFloat(oldValue), to: CGFloat(progress), duration: 0.1)
}
}
class TriangleView: UIView {
override func draw(_ rect: CGRect) {
guard let context = UIGraphicsGetCurrentContext() else { return }
context.beginPath()
context.move(to: CGPoint(x: rect.midX, y: rect.minY))
context.addLine(to: CGPoint(x: rect.minX, y: rect.maxY))
context.addLine(to: CGPoint(x: rect.maxX, y: rect.maxY))
context.closePath()
context.setFillColor(UIColor.black.withAlphaComponent(0.6).cgColor)