Skip to content

Instantly share code, notes, and snippets.


liang wang hite

View GitHub Profile
dsabanin /
Last active Dec 13, 2020
Enable internal Xcode debug menu in Xcode 11
defaults write ShowDVTDebugMenu -bool YES
sudo mkdir -p /Applications/
sudo touch /Applications/
# Don't forget to restart Xcode
tclementdev /
Last active Jan 25, 2021
Making efficient use of the libdispatch (GCD)

libdispatch efficiency tips

The libdispatch is one of the most misused API due to the way it was presented to us when it was introduced and for many years after that, and due to the confusing documentation and API. This page is a compilation of important things to know if you're going to use this library. Many references are available at the end of this document pointing to comments from Apple's very own libdispatch maintainer (Pierre Habouzit).

My take-aways are:

  • You should create very few, long-lived, well-defined queues. These queues should be seen as execution contexts in your program (gui, background work, ...) that benefit from executing in parallel. An important thing to note is that if these queues are all active at once, you will get as many threads running. In most apps, you probably do not need to create more than 3 or 4 queues.

  • Go serial first, and as you find performance bottle necks, measure why, and if concurrency helps, apply with care, always validating under system pressure. Reuse

dusanmarsa / clipboard-paste-image.js
Created Oct 29, 2017
JavaScript - Clipboard API - Paste image handler
View clipboard-paste-image.js
var IMAGE_MIME_REGEX = /^image\/(p?jpeg|gif|png)$/i;
var loadImage = function (file) {
var reader = new FileReader();
reader.onload = function(e){
var img = document.createElement('img');
img.src =;
var range = window.getSelection().getRangeAt(0);
View DispatchToData-Swift3.swift
import Foundation
#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS)
extension Data {
init(referencing data: DispatchData) {
self = (data as AnyObject) as! Data
zachwaugh /
Last active Aug 19, 2019
iOS device compatibility

A hopefully accurate list of iOS compatibility per device

iOS 13


iOS 12


iOS 11


View CURL常用命令.md
View UIImage+ImageEffects.h
#import <UIKit/UIKit.h>
@interface UIImage (ImageEffects)
- (UIImage *)applyLightEffect;
- (UIImage *)applyExtraLightEffect;
- (UIImage *)applyDarkEffect;
- (UIImage *)applyTintEffectWithColor:(UIColor *)tintColor;
- (UIImage *)applyBlurWithRadius:(CGFloat)blurRadius tintColor:(UIColor *)tintColor saturationDeltaFactor:(CGFloat)saturationDeltaFactor maskImage:(UIImage *)maskImage;
bobslaede / modernizr.positionfixed.js
Created Sep 16, 2011
Modernizr position fixed check
View modernizr.positionfixed.js
;(function(Modernizr, window) {
Modernizr.addTest('positionfixed', function () {
var test = document.createElement('div'),
control = test.cloneNode(false),
fake = false,
root = document.body || (function () {
fake = true;
return document.documentElement.appendChild(document.createElement('body'));