Skip to content

Instantly share code, notes, and snippets.

@PhilCai1993
PhilCai1993 / CALayer_With_ResizableImage.m
Last active October 1, 2017 02:33
CALayer and [UIImage resizableImageWithCapInsets:resizingMode]
static CGRect CGRectCenterRectForResizableImage(UIImage* image) {
return CGRectMake(image.capInsets.left / image.size.width,
image.capInsets.top / image.size.height,
(image.size.width - image.capInsets.right - image.capInsets.left) / image.size.width,
(image.size.height - image.capInsets.bottom - image.capInsets.top) / image.size.height);
}
...
// 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.
#import <objc/runtime.h>
#import <objc/message.h>
// Compile-time selector checks.
@PhilCai1993
PhilCai1993 / FileEnum.swift
Created January 5, 2016 10:52
Swift查找项目图片
//
// FileEnum.swift
//
//
// Created by PhilCai on 1/5/16.
//
//
import Foundation
// MARK: Usage
@PhilCai1993
PhilCai1993 / CoolieForObjectMapper.playground
Created February 25, 2016 09:48
CoolieForObjectMapper.playground
//
// Coolie.swift
// Coolie
//
// Created by NIX on 16/1/23.
// Copyright © 2016年 nixWork. All rights reserved.
//
import Foundation
@PhilCai1993
PhilCai1993 / brightness.m
Last active October 18, 2017 09:46
detect brightness using ios camera
- (AVCaptureDevice *)frontCamera {
NSArray *devices = [AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo];
for (AVCaptureDevice *device in devices) {
if ([device position] == AVCaptureDevicePositionFront) {
return device;
}
}
return nil;
}
@PhilCai1993
PhilCai1993 / build_config.rb
Created May 29, 2018 05:13 — forked from dorentus/build_config.rb
Put build_config.rb into mruby root dir, make, and put build_framework.rb into build dir and run it to get a MRuby.framework, run collect_mrb_gem_archive.rb <gem_name> in build dir to get a seperate <gem_name>.framework
MRuby::Build.new do |conf|
toolchain :clang
conf.gembox 'default'
end
def crossbuild_for(name, platform, sysroot, cc_defines = [])
MRuby::CrossBuild.new(name) do |conf|
toolchain :clang
conf.gembox 'default'

UITesing Utilities

Contents

How to use

  • add the contents to your UITesting target
  • import XCTest-Private.h into your UITesting target bridging header
  • in your XCTestCase tearDown() method use the Springboard utility to delete the app and/or reset Location and Privacy Settings
@PhilCai1993
PhilCai1993 / idevicesyslog.go
Last active September 9, 2019 05:55
idevicesyslog unicode support
package main
import (
"bufio"
"fmt"
"io"
"os/exec"
"strings"
)
@PhilCai1993
PhilCai1993 / safari_jsbox.js
Created November 25, 2019 12:00
safari_jsbox.js
/* ©2019, Bionic Reading® */
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.BionicReader = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
(function (process){
"use strict";
var isNode = false;
try {
isNode
@PhilCai1993
PhilCai1993 / save_space.rb
Created December 12, 2019 12:56
Save disk space for victims of CocoaPods
gem 'cocoapods', '1.7.4'# only 1.7.4 tested.
require 'cocoapods'
module Pod
class Installer
def clean_pod_sources
UI.message "prevent default clean_pod_sources"
end