Skip to content

Instantly share code, notes, and snippets.

View iShawnWang's full-sized avatar
🤗
2333

Shawn Wang iShawnWang

🤗
2333
View GitHub Profile
@iShawnWang
iShawnWang / README.md
Last active July 5, 2016 14:19
Mac :Setup Avatar for SourceTree App ,为 SourceTree App 设置 Commit 时的头像
  1. Close SourceTree App
  2. Launch Finder,
    Command + Shift + G go to ~/Library/Application Support/SourceTree/ SourceTree Preference and Cache Directory,
  3. Delete Directory ImageCache
  4. Go to Gavatar with your account the same as you login in the SourceTree App
  5. Setup Avatar
  6. Launch SourceTree ,it will fetch avatar from Gavatar with account you login
  7. Done :)

###Note Apple will reject apps that are using private url schemes (Ugh, Apple....) if they are pretty much obvius. Some apps are rejected and others are not, so, be aware of this issue before implementing any of those URL's in your app as a feature.

###[UPDATE : Not yet tested in iOS 10. It will fail because of policies changes in URL scheme handling.]

###[UPDATE 2:The openURL() method of UIApplication is now deprecated. You should use application(_:open:options:) instead]

##[UPDATE 3: For now you just can use url schemes to open your apps's settings with Swift 3.0 (Xcode 8). I'll keep you informed when OS preferences can be reached]

@iShawnWang
iShawnWang / LOL
Last active October 14, 2016 11:32
Detect Ad Hoc Build Configuration in code at runtime
//AdHoc detect with following 2 conditions :
//1.`embedded.mobileprovision` contains field `ProvisionedDevices` (Debug and Ad Hoc Build contains this field ,Release not)
//2.it is not DEBUG Build , we can use `#ifdef DEBUG` to decide it
NS_INLINE BOOL isAdHoc(){
BOOL isAdHoc = NO;
BOOL isDebug;
#ifdef DEBUG
isDebug=YES;
@iShawnWang
iShawnWang / Log+Extension.swift
Last active August 22, 2017 17:07
Custom CleanroomLogger Channel demo
Original issues : [CleanroomLogger/issues/37](https://github.com/emaloney/CleanroomLogger/issues/37)
extension Log {
static func setup() {
#if DEBUG
Log.enable(debugMode: true)
Log.sqlite = MyLogChannel(prefix: "Sqlite") // enable your channel or using Xcode console filter
#endif
}
}

Keybase proof

I hereby claim:

  • I am ishawnwang on github.
  • I am ishawnwang (https://keybase.io/ishawnwang) on keybase.
  • I have a public key ASCgW2WZPG5ADfgS4QaCjUoKqXYhhAXgfpWFXWEpO634hAo

To claim this, I am signing this object:

@iShawnWang
iShawnWang / useRouter.ts
Last active July 27, 2019 05:52
react-router backward hooks, support react-router 4.x | 5.x
import { __RouterContext as RouterContext, RouteComponentProps } from 'react-router'
import { useContext, useMemo, useCallback } from 'react'
import qs from 'qs'
import { Location } from 'history'
interface ParsedQuery {
[whatever: string]: any
}
export const useRouter = <T>(): RouteComponentProps<T> =>
@iShawnWang
iShawnWang / enum_demo.ts
Created November 25, 2019 01:57
Typescript 枚举 扩展
interface Enum {
[id: number]: string
}
const getEnumKeys = (e: Enum) => {
return Object.keys(e)
.map(key => e[key])
.filter(value => typeof value === 'string') as string[]
}
@iShawnWang
iShawnWang / analytics.js
Created August 5, 2021 06:27 — forked from zmmbreeze/analytics.js
GA的源码 analytics.js
(function() {
/**
* 记录方法使用情况的类
* @param {Array.<boolean>} umMap 初始的使用情况
*/
var UsageManager = function(umMap) {
this.umMap = umMap || [];
};
/**
* 记录新的使用情况
@iShawnWang
iShawnWang / Example.tsx
Last active October 31, 2021 05:19
Use Ant Design Modal in Imperative Mode
import {ModalProvider, ModalContext, Modalman} from './Modalman'
import {useContext} from 'react'
import {Modal} from 'antd'
// App.tsx
// export default () => {
// return <ModalProvider><App /><ModalProvider>
// }
export default () => {