Skip to content

Instantly share code, notes, and snippets.

@bumaociyuan
bumaociyuan / common.cy
Last active September 30, 2018 08:29 — forked from susnmos/common.cy
A script for cycript
(function(exports) {
// 打印按钮的action及其target
zxactionWithTargets = function actionWithTargets(button) {
var allTargets = [button allTargets].allObjects();
if (!allTargets) {
return "is not a uicontrol"
}
var allShow = [];
for (var i = 0; i < allTargets.length; i++) {
var target = allTargets[i];
@bumaociyuan
bumaociyuan / UIImage+gif.swift
Created May 4, 2018 08:37
Get first frame of gif
extension UIImage {
// first frame of gif
class func firstFrame(gif url: URL) -> UIImage? {
guard let data = try? Data(contentsOf: url) as CFData else {
return nil
}
guard let source = CGImageSourceCreateWithData(data, nil) else {
return nil
}
guard let cgimage = CGImageSourceCreateImageAtIndex(source, 0, nil) else {
@bumaociyuan
bumaociyuan / NSObject+hook.m
Created January 29, 2018 07:52
swizzle function
@interface NSObject (hook)
+ (void)switchClassFuction:(NSString *)originalSelectorName swizzledSelector:(NSString *)swizzledSelectorName;
+ (void)switchInstanceFuction:(NSString *)originalSelectorName sel2:(NSString *)swizzledSelectorName;
@end
@implementation NSObject (hook)
+ (void)switchClassFuction:(NSString *)originalSelectorName swizzledSelector:(NSString *)swizzledSelectorName {
Class class = object_getClass((id)self);
SEL originalSelector = NSSelectorFromString(originalSelectorName);
@bumaociyuan
bumaociyuan / Podfile
Created June 29, 2017 07:41
单独配置podfile macro
# Uncomment the next line to define a global platform for your project
platform :ios, '9.0'
target 'demo' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
end
post_install do |installer|
installer.pods_project.targets.each do |target|
@bumaociyuan
bumaociyuan / zhihu-fuli.js
Last active June 25, 2017 08:06
知乎图片浏览
(function() {
var imageUrls = [],
totals = 0,
offset = 0,
qId = location.href.split('/').pop();
$(".App-main").innerHTML = '';
var style = " background: rgba(0,0,0,0.8); display: -webkit-flex; /* Safari */ -webkit-flex-wrap: wrap; /* Safari 6.1+ */ display: flex; flex-wrap: wrap; "
$("body").insertAdjacentHTML('beforeend', '<div id="img-fuli" style="' + style + '"><h1 style="color:#fff;">加载中,请稍后...</h1></div>');
loadImg();
function getAllUrlParams(url) {
// get query string from url (optional) or window
var queryString = url ? url.split('?')[1] : window.location.search.slice(1);
// we'll store the parameters here
var obj = {};
// if query string exists
if (queryString) {
@bumaociyuan
bumaociyuan / hehe.swift
Last active January 4, 2024 17:52
ios 听筒和扬声器切换
let session = AVAudioSession.sharedInstance()
try? session.setActive(true)
if !isSpeakerMode {
// NSLog(@"Device is close to user");
do {
try AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayAndRecord)
try AVAudioSession.sharedInstance().overrideOutputAudioPort(.none)
} catch _ {}
} else {
// NSLog(@"Device is not close to user");
@bumaociyuan
bumaociyuan / 拼图.bat
Last active January 18, 2021 15:18
需要 https://www.imagemagick.org/script/binary-releases.php#windows 把拼图.bat 放到 C:\Users\zx\AppData\Roaming\Microsoft\Windows\SendTo\ 里面就可以用右键 发送到 拼图.bat 调用脚本
@echo off
title Concat images vertically
echo Begin
set datetimef=%date:~0,2%-%date:~3,2%_%time:~0,2%-%time:~3,2%-%time:~6,2%
echo %datetimef%
setlocal enabledelayedexpansion
set argCount=0
@bumaociyuan
bumaociyuan / info.plist
Last active August 30, 2016 02:50
Copy the content and paste into info.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
</plist>
@bumaociyuan
bumaociyuan / universal-framework.sh
Created July 28, 2016 09:37 — forked from cromandini/universal-framework.sh
This run script will build the iphoneos and iphonesimulator schemes and then combine them into a single framework using the lipo tool (including all the Swift module architectures).
#!/bin/sh
UNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/${CONFIGURATION}-universal
# make sure the output directory exists
mkdir -p "${UNIVERSAL_OUTPUTFOLDER}"
# Step 1. Build Device and Simulator versions
xcodebuild -target "${PROJECT_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${CONFIGURATION} -sdk iphoneos BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" clean build
xcodebuild -target "${PROJECT_NAME}" -configuration ${CONFIGURATION} -sdk iphonesimulator ONLY_ACTIVE_ARCH=NO BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" clean build