Skip to content

Instantly share code, notes, and snippets.

View Arthraim's full-sized avatar
💡
Padawan

Arthur Wang Arthraim

💡
Padawan
View GitHub Profile
@import Photos;
[PHPhotoLibrary requestAuthorizationForAccessLevel:PHAccessLevelReadWrite handler:^(PHAuthorizationStatus status) {
NSLog(@"PHAuthorizationStatus: %ld", status);
PHFetchOptions *fetchOptions = [[PHFetchOptions alloc] init];
fetchOptions.includeHiddenAssets = YES;
fetchOptions.includeAllBurstAssets = YES;
PHFetchResult<PHAsset *> *result = [PHAsset fetchAssetsWithOptions:fetchOptions];
@nicklockwood
nicklockwood / Withable.swift
Created January 28, 2019 12:06
Withable.swift
/// Withable is a simple protocol to make constructing
/// and modifying objects with multiple properties
/// more pleasant (functional, chainable, point-free)
public protocol Withable {
init()
}
public extension Withable {
/// Construct a new instance, setting an arbitrary subset of properties
init(with config: (inout Self) -> Void) {
@lattner
lattner / TaskConcurrencyManifesto.md
Last active May 5, 2024 22:32
Swift Concurrency Manifesto
@tals
tals / meldium_to_1password.py
Last active June 6, 2017 23:01
Meldium to 1Password converter
"""
1Password is good at a lot of things. Importing CSV is not one of them (as of 5.5.BETA-29).
Converts a Meldium CSV to something 1Password will import correctly.
To export: http://support.meldium.com/knowledgebase/articles/656755-export-meldium-data-to-a-spreadsheet
"""
import csv
import sys
@boopathi
boopathi / README.md
Last active August 28, 2023 14:35
Creating a Swift-ReactNative project

Settings

  1. Create a project in XCode with the default settings
    • iOS > Application > Single View Application
    • Language: Swift
  2. Under project General settings, add ReactKit to Linked Framework and Libraries
    • + > Add Other... and choose /path/to/react-native/ReactKit/ReactKit.xcodeproj
  3. Now ReactKit would have been imported. Link it by choosing it from the list.
    • + > lib.ReactKit.a
  4. Under project Build Settings,
@niedhui
niedhui / cdf.fish
Last active August 29, 2015 14:04
~/.config/fish/functions/cdf.fish
function cdf
cd (finder_path )
end
function finder_path
echo '
tell application "Finder"
if (1 <= (count Finder windows)) then
get POSIX path of (target of window 1 as alias)
else
@steipete
steipete / DevelopmentEnviromentDetector.m
Last active October 30, 2019 03:49
Detect if you're currently running a development version or an App Store/Ad Hoc version.
static BOOL PSPDFIsDevelopmentBuild(void) {
#if TARGET_IPHONE_SIMULATOR
return YES;
#else
static BOOL isDevelopment = NO;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
// There is no provisioning profile in AppStore Apps.
NSData *data = [NSData dataWithContentsOfFile:[NSBundle.mainBundle pathForResource:@"embedded" ofType:@"mobileprovision"]];
if (data) {
@danielglh
danielglh / pg_helper
Created August 31, 2013 03:00
pg_helper
pg() {
if [[ $@ == "log" ]]; then
command less /usr/local/var/postgres/default/server.log
elif [[ $@ == "start" || $@ == "stop" || $@ == "restart" ]]; then
command pg_ctl -D /usr/local/var/postgres/default -l /usr/local/var/postgres/default/server.log $@
else
echo "Wrong pg command!"
fi
}
@steipete
steipete / PSPDFUIKitMainThreadGuard.m
Last active March 10, 2024 19:23
This is a guard that tracks down UIKit access on threads other than main. This snippet is taken from the commercial iOS PDF framework http://pspdfkit.com, but relicensed under MIT. Works because a lot of calls internally call setNeedsDisplay or setNeedsLayout. Won't catch everything, but it's very lightweight and usually does the job.You might n…
// Taken from the commercial iOS PDF framework http://pspdfkit.com.
// Copyright (c) 2014 Peter Steinberger, PSPDFKit GmbH. All rights reserved.
// Licensed under MIT (http://opensource.org/licenses/MIT)
//
// You should only use this in debug builds. It doesn't use private API, but I wouldn't ship it.
// PLEASE DUPE rdar://27192338 (https://openradar.appspot.com/27192338) if you would like to see this in UIKit.
#import <objc/runtime.h>
#import <objc/message.h>
@zvving
zvving / CLLocation+Sino.h
Last active January 9, 2019 02:39
火星坐标系转换扩展。Earth(国外 WGS84), mars(国内 GCJ-02), bearPaw(百度 BD-09) 坐标系间相互转换
//
// CLLocation+Sino.h
//
// Created by i0xbean@gmail.com on 13-4-26.
// 火星坐标系转换扩展
//
// earth(国外 WGS84), mars(国内 GCJ-02), bearPaw(百度 BD-09) 坐标系间相互转换
// 未包含 mars2earth. 需要这个可参考 http://xcodev.com/131.html
#import <CoreLocation/CoreLocation.h>