Skip to content

Instantly share code, notes, and snippets.

View ripperhe's full-sized avatar
🌝
专注

ripperhe

🌝
专注
  • Beijing China
View GitHub Profile
@onevcat
onevcat / Default.swift
Created November 10, 2020 03:56
Sample code of using Default to decode a property to the default value
import UIKit
protocol DefaultValue {
associatedtype Value: Decodable
static var defaultValue: Value { get }
}
@propertyWrapper
struct Default<T: DefaultValue> {
var wrappedValue: T.Value
@software-mariodiana
software-mariodiana / date_surprise.m
Last active December 3, 2020 10:07
Date localization does unexpected things if all you're familiar with is U.S. dates.
// iPhone settings: "Denmark" for region and "Buddhist" for calendar.
NSDate* now = [NSDate date];
NSDateFormatter* df = [[NSDateFormatter alloc] init];
df.timeZone = [NSTimeZone timeZoneWithName:@"UTC"];
df.timeStyle = NSDateFormatterMediumStyle;
df.dateStyle = NSDateFormatterShortStyle;
// Date: 30/10/2563 BE, 14.32.18
NSLog(@"Date: %@", [df stringFromDate:now]);
@dimitribouniol
dimitribouniol / Bump Project Version.sh
Last active December 10, 2023 02:00
Automatically Bump Versions in Xcode
cd "${PROJECT_DIR}"
# Make sure working directory is clean.
if output=$(git status --porcelain) && [ -n "$output" ]; then
echo "error: Please commit any uncommitted files before proceeding:\n$output"
exit 1
fi
# Make sure we are on master (and not a feature branch, for instance)
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
@IsaacXen
IsaacXen / README.md
Last active May 2, 2024 09:57
(Almost) Every WWDC videos download links for aria2c.
@JunyuKuang
JunyuKuang / UIResponder+performWindowDrag.swift
Last active November 2, 2023 23:32
Customize/extend the window draggable area of your Mac Catalyst app.
//
// UIResponder+performWindowDrag.swift
// JonnyUtility
//
// Created by Jonny Kuang on 10/7/19.
// Copyright © 2019 Junyu Kuang <lightscreen.app@gmail.com>. All rights reserved.
//
import UIKit
//
// LNATextField.swift
// LonaStudio
//
// Created by Devin Abbott on 11/1/18.
// Copyright © 2018 Devin Abbott. All rights reserved.
//
import AppKit
import Foundation
@freak4pc
freak4pc / UIImage+QR.swift
Created August 26, 2018 08:37
Detect text messages from QR code
extension UIImage {
func parseQR() -> [String] {
guard let image = CIImage(image: self) else {
return []
}
let detector = CIDetector(ofType: CIDetectorTypeQRCode,
context: nil,
options: [CIDetectorAccuracy: CIDetectorAccuracyHigh])
@ian-mcdowell
ian-mcdowell / DebuggingOverlay.m
Last active February 27, 2021 19:04
UIDebuggingInformationOverlay for iOS 10, 11, and 12
#import <objc/runtime.h>
@interface DebuggingOverlay: NSObject
@end
@implementation DebuggingOverlay
+ (void)toggleOverlay {
id debugInfoClass = NSClassFromString(@"UIDebuggingInformationOverlay");
@joshbuchea
joshbuchea / semantic-commit-messages.md
Last active May 7, 2024 01:27
Semantic Commit Messages

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example