Skip to content

Instantly share code, notes, and snippets.

View iHTCboy's full-sized avatar
:octocat:
Coding

iHTCboy iHTCboy

:octocat:
Coding
View GitHub Profile
@iHTCboy
iHTCboy / Judge iOS app is Running TestFlight Beta.swift
Created February 2, 2023 02:57
检测 iOS App 是否 TestFlight 下载的 ipa
OC
```
if ([[NSBundle mainBundle] pathForResource:@"embedded" ofType:@"mobileprovision"]) {
// TestFlight
} else {
// App Store (and Apple reviewers too)
}
BOOL isRunningTestFlightBeta = [[[[NSBundle mainBundle] appStoreReceiptURL] lastPathComponent] isEqualToString:@"sandboxReceipt"];
```
@iHTCboy
iHTCboy / SqliteDataConvertToFile.python
Created February 2, 2023 02:46
sqlite binary data convert to file
#!/usr/bin/env python3
import sqlite3
def write_file(data, filename):
'''Convert binary data and write it on Hard Disk'''
with open(filename, 'wb') as file:
file.write(data)
print(f"Stored blob data into:{filename}\n")
@iHTCboy
iHTCboy / UIWindowSceneKeyWindow.swift
Created February 2, 2023 02:45
iOS get Current KeyWindow
extension UIApplication {
public var currentKeyWindow: UIWindow? {
if #available(iOS 13.0, *) {
if let window = connectedScenes
.filter({ $0.activationState == .foregroundActive })
.map({ $0 as? UIWindowScene })
.compactMap({ $0 })
.first?.windows
.filter({ $0.isKeyWindow }).first {
return window
@iHTCboy
iHTCboy / popularDomains.json
Created February 2, 2023 02:45
popular Domains
[
"facebook.com",
"twitter.com",
"youtube.com",
"google.com",
"instagram.com",
"linkedin.com",
"plus.google.com",
"gmpg.org",
"pinterest.com",
@iHTCboy
iHTCboy / Judge Mach-O library type static or dynamically.sh
Created February 2, 2023 02:44
检查 Mach-O 是静态库还是动态库
#!/bin/bash
# 定义用到的变量
project_path=""
# 定义读取输入字符的函数
function getProjectPath() {
# 输出换行,方便查看
echo "================================================"
# 监听输入并且赋值给变量
@iHTCboy
iHTCboy / Find Mach-O symbols.sh
Last active February 2, 2023 02:44
判断 Mach-O SDK 是否包含某个符号
#!/bin/bash
# 定义用到的变量
project_path=""
# 定义读取输入字符的函数
function getProjectPath() {
# 输出换行,方便查看
echo "================================================"
# 监听输入并且赋值给变量
@iHTCboy
iHTCboy / web视频加速倍速快进播放
Created May 5, 2020 06:41
web视频加速倍速快进播放
```
var videos = document.querySelectorAll("video");
for (var video of videos) {
video.playbackRate = 1.5;
}
```
@iHTCboy
iHTCboy / iOS 数字加¥或者$的符号
Created April 13, 2020 12:00
iOS 数字加¥或者$的符号
给数字加上千位分隔符,对于金钱的余额,甚至还需要加上¥或者$的符号:
- (NSString *)formattedNumber: (double)number {
NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc]init];
[numberFormatter setFormatterBehavior:NSNumberFormatterBehavior10_4];
[numberFormatter setNumberStyle:NSNumberFormatterDecimalStyle];
NSString *numberString = [numberFormatter stringFromNumber:[NSNumber numberWithDouble:number]];
NSLog(@"%@",numberString);
return numberString;
}
@iHTCboy
iHTCboy / Info.plist常用 key 说明
Created April 13, 2020 03:32
Info.plist常用 key 说明
1. Application does not run in background
(键名:UIApplicationExistsOnSuspend)
自从iOS4.0之后,当你在应用程序执行的时候按下Home键,应用程序并不会中断目前的应用,而是放到后台去了。
因此希望使用者在按下Home键之后就要退出当前应用的请勾选这个选项。
@iHTCboy
iHTCboy / Python读取文件和保存内容到文件
Created March 18, 2020 08:42
Python读取文件和保存内容到文件
import re
dump_file_path = '/Users/iHTCboy/Downloads/file.txt'
# 读取 dump 文件内容
with open(dump_file_path, mode='r', encoding="utf8", errors="ignore" ) as flip:
dump = flip.read()
# 正则匹配
pattern = r'@interface (.+) :'