Skip to content

Instantly share code, notes, and snippets.

@kingiol
kingiol / ios10-url-open-location-service.swift
Created November 9, 2021 03:54 — forked from devxoul/ios10-url-open-location-service.swift
Open Settings > Privacy > Location Service in iOS 10
// Example Usage
func openLocation() {
guard let workspaceClass = NSClassFromString("LSApplicationWorkspace") else { return }
let workspace: AnyObject = execute(workspaceClass, "defaultWorkspace")
let url = URL(string: "Prefs:root=Privacy&path=LOCATION")!
execute(workspace, "openSensitiveURL:withOptions:", with: url)
}
private func getImplementation(_ owner: AnyObject, _ name: String) -> IMP {
let selector = Selector(name)
git config --global https.proxy http://127.0.0.1:1080
git config --global https.proxy https://127.0.0.1:1080
git config --global --unset http.proxy
git config --global --unset https.proxy
npm config delete proxy
@kingiol
kingiol / PresentationLink2.swift
Created July 10, 2019 10:25 — forked from vmanot/PresentationLink2.swift
PresentationLink bug workaround for SwiftUI (Xcode b3)
extension UIApplication {
/// The top most view controller
static var topMostViewController: UIViewController? {
return UIApplication.shared.keyWindow?.rootViewController?.visibleViewController
}
}
extension UIViewController {
/// The visible view controller from a given view controller
var visibleViewController: UIViewController? {
@kingiol
kingiol / memoryAddress.swift
Created April 10, 2019 03:06 — forked from matsuda/memoryAddress.swift
Get memory address in Swift
///
/// https://stackoverflow.com/a/29741007
///
let s = Struct() // Struct
withUnsafePointer(to: s) {
print(String(format: "%p", $0)
}
///
/// http://stackoverflow.com/a/36539213/226791
@kingiol
kingiol / fiindsize.swift
Created March 13, 2019 06:07 — forked from rayfix/fiindsize.swift
Getting the Size of a file or directory in Swift
//
// main.swift
// findsize
//
// Created by Ray Fix on 2/6/16.
// Copyright © 2016 Neko Labs. All rights reserved.
//
import Foundation
@kingiol
kingiol / whatsapp-image-compression
Created November 22, 2018 07:56 — forked from akshay1188/whatsapp-image-compression
Whatsapp like image compression
- (UIImage *)compressImage:(UIImage *)image{
float actualHeight = image.size.height;
float actualWidth = image.size.width;
float maxHeight = 600.0;
float maxWidth = 800.0;
float imgRatio = actualWidth/actualHeight;
float maxRatio = maxWidth/maxHeight;
float compressionQuality = 0.5;//50 percent compression
if (actualHeight > maxHeight || actualWidth > maxWidth) {
@kingiol
kingiol / AsynchronousOperation.swift
Created November 18, 2018 08:26 — forked from Sorix/AsynchronousOperation.swift
Subclass of NSOperation to make it asynchronous in Swift 3
//
// AsynchronousOperation.swift
//
// Created by Vasily Ulianov on 09.02.17.
// Copyright © 2017 Vasily Ulianov. All rights reserved.
//
import Foundation
/// Subclass of `Operation` that add support of asynchronous operations.
//
// MyMetalWaterfall.swift
// version 0.1.104
//
// Demonstrates using a MetalKit compute shader to render a live waterfall
// RGB spectrogram bitmap from iOS RemoteIO audio input into a UIView
//
// This is a single file iOS app (it only compiles for iOS devices, not the Simulator)
//
// It includes AppDelegate for a minimal demonstration app
@kingiol
kingiol / iosbuild.sh
Created September 3, 2018 05:44 — forked from reqshark/iosbuild.sh
libmill iOS cross-compile for 32 bit (armv7) and 64 bit (arm64) iOS, and i386 and x86_64 simulators
# Copyright (c) 2015 Bent Cardan
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom
# the Software is furnished to do so, subject to the following conditions:
@kingiol
kingiol / Storage.swift
Created August 12, 2018 11:44 — forked from saoudrizwan/Storage.swift
Helper class to easily store and retrieve Codable structs from/to disk. https://medium.com/@sdrzn/swift-4-codable-lets-make-things-even-easier-c793b6cf29e1
import Foundation
public class Storage {
fileprivate init() { }
enum Directory {
// Only documents and other data that is user-generated, or that cannot otherwise be recreated by your application, should be stored in the <Application_Home>/Documents directory and will be automatically backed up by iCloud.
case documents