Skip to content

Instantly share code, notes, and snippets.

View stleamist's full-sized avatar

Dongkyu Kim stleamist

View GitHub Profile
@christopherweems
christopherweems / UIViewAnimationCurve+ToOptions.swift
Created December 8, 2015 15:08
Convert from UIViewAnimationCurve to UIViewAnimationCurveOptions
// Simple function converting from UIViewAnimationCurve to UIViewAnimationCurveOptions
// Not all UIViewAnimationCurve values have a specified equivalent UIViewAnimationCurveOptions,
// making it tricky to use the animation curve of the keyboard with UIView.animateWithDuration(...) API.
// This works as late as iOS 9.1, but could change in the future.
extension UIViewAnimationCurve {
func toOptions() -> UIViewAnimationOptions {
return UIViewAnimationOptions(rawValue: UInt(rawValue << 16))
}
}
@afshin-hoseini
afshin-hoseini / CustomBlurView.swift
Created February 13, 2016 06:07
Custom blur view which you can determine blur radius for
//
// APCustomBlurView.swift
// Created by Collin Hundley on 1/15/16.
//
import UIKit
public class APCustomBlurView: UIVisualEffectView {
private let blurEffect: UIBlurEffect
@camdenfullmer
camdenfullmer / CMFWallpaper.m
Last active February 18, 2024 03:05
Set the wallpaper (lock and/or home screen) on iOS using Apple's private API. Please be aware that including this code in an App Store submission will result in a rejection. This has only been tested on iOS 9.2.
@implementation CMFWallpaper
+ (void)setImage:(UIImage *)image {
NSAssert([PHPhotoLibrary authorizationStatus] == PHAuthorizationStatusAuthorized, @"access to photos is needed to set the wallpaper");
NSString *path;
#if TARGET_OS_SIMULATOR
path = @"/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/PrivateFrameworks/PhotoLibrary.framework";
#else
path = @"/System/Library/PrivateFrameworks/PhotoLibrary.framework";
@muukii
muukii / UIView+Util.swift
Last active March 13, 2023 05:54
Find UIView by AccessibilityIdentifier
extension UIView {
public class func findByAccessibilityIdentifier(identifier: String) -> UIView? {
guard let window = UIApplication.sharedApplication().keyWindow else {
return nil
}
func findByID(view: UIView, _ id: String) -> UIView? {
if view.accessibilityIdentifier == id { return view }
for v in view.subviews {
@tinydew4
tinydew4 / lun2sol.js
Last active November 6, 2019 06:36 — forked from twkang/lun2sol.js
JavaScript: Google spreadsheet scripts to convert dates between Korean lunar calendar and solar calendar
function test_lun2sol() {
Logger.log(lun2sol(2013, 1, 4, 0));
}
function test_sol2lun() {
Logger.log(sol2lun(2013, 1, 26, 1));
}
/**
* lun2sol 의 date 버전
@marmelroy
marmelroy / MKMapCameraAltitude
Created April 20, 2016 15:58
Calculating MKMapCamera's altitude for a distance
let altitude = distance*tan(M_PI*(75.0/180.0))
@westerlund
westerlund / UISlider.swift
Created May 3, 2016 09:19
Snapping UISlider in Swift
final class SnappingSlider: UISlider {
override var value: Float {
set { super.value = newValue }
get {
return round(super.value * 1.0) / 1.0
}
}
}
@steipete
steipete / ios-xcode-device-support.sh
Last active April 22, 2026 17:21
Using iOS 15 devices with Xcode 12.5 (instead of Xcode 13)
# The trick is to link the DeviceSupport folder from the beta to the stable version.
# sudo needed if you run the Mac App Store version. Always download the dmg instead... you'll thank me later :)
# Support iOS 15 devices (Xcode 13.0) with Xcode 12.5:
sudo ln -s /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/15.0 /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport
# Then restart Xcode and reconnect your devices. You will need to do that for every beta of future iOS versions
# (A similar approach works for older versions too, just change the version number after DeviceSupport)
@mbleigh
mbleigh / firebase.json
Created August 2, 2016 18:42
Firebase Hosting for apple-app-site-association
{
"hosting": {
"headers": [
{
"source": "/.well-known/apple-app-site-association",
"headers": [{"key": "Content-Type", "value": "application/json"}]
}
]
}
}
@nosix
nosix / Capture.kt
Created September 18, 2016 08:40
Taking a snapshot of the screen for Android (SDK 21) in Kotlin 1.0.3
package xxx
import android.content.Context
import android.graphics.Bitmap
import android.graphics.PixelFormat
import android.hardware.display.DisplayManager
import android.hardware.display.VirtualDisplay
import android.media.ImageReader
import android.media.projection.MediaProjection
import android.util.Log