Skip to content

Instantly share code, notes, and snippets.

View liushuaikobe's full-sized avatar

Shuai Liu liushuaikobe

  • Alibaba
  • Hangzhou, China
  • 13:14 (UTC +08:00)
View GitHub Profile
@mackuba
mackuba / wwdc16.md
Last active March 5, 2023 21:28
New stuff from WWDC 2016

Following the tradition from last year, here's my complete list of all interesting features and updates I could find in Apple's OSes, SDKs and developer tools that were announced at this year's WWDC. This is based on the keynotes, the "What's New In ..." presentations and some others, Apple's release notes, and blog posts and tweets that I came across in the last few weeks.

If for some reason you haven't watched the talks yet, I really recommend watching at least the "State of the Union" and the "What's New In" intros for the platforms you're interested in. The unofficial WWDC Mac app is great way to download the videos and keep track of what you've already watched.

If you're interested, here are my WWDC 2015 notes (might be useful if you're planning to drop support for iOS 8 now and start using some iOS 9 APIs).


OSX → macOS 10.12 Sierra

internal let DEFAULT_MIME_TYPE = "application/octet-stream"
internal let mimeTypes = [
"html": "text/html",
"htm": "text/html",
"shtml": "text/html",
"css": "text/css",
"xml": "text/xml",
"gif": "image/gif",
"jpeg": "image/jpeg",
@nickfrey
nickfrey / WFSimulate3DTouchPreview.m
Created September 22, 2015 20:13
Test 3D Touch peek/pop using private APIs
@interface UIPreviewForceInteractionProgress : NSObject
- (void)endInteraction:(BOOL)arg1;
@end
@interface UIPreviewInteractionController : NSObject
@property (nonatomic, readonly) UIPreviewForceInteractionProgress *interactionProgressForPresentation;
@haotian-liu
haotian-liu / express-company.js
Last active February 19, 2020 09:58
A javascript that can differentiate the express IDs of different express companies
var jsoncom = {
'company': [{
'companyname': '申通快递',
'shortname': '申通',
'tel': '95543',
'url': 'st',
'code': 'shentong',
'hasvali': 0,
'comurl': 'http://www.sto.cn',
'isavailable': '0',
@loganwright
loganwright / Shell.swift
Last active November 12, 2016 10:46
Call shell commands from Swift
func shell(input: String) -> (output: String, exitCode: Int32) {
let arguments = split(input, maxSplit: Int.max, allowEmptySlices: true) {
$0 == " "
}
let task = NSTask()
task.launchPath = "/usr/bin/env"
task.arguments = arguments
task.environment = [
"LC_ALL" : "en_US.UTF-8",
@jspahrsummers
jspahrsummers / GHRunLoopWatchdog.h
Created January 28, 2015 20:50
A class for logging excessive blocking on the main thread
/// Observes a run loop to detect any stalling or blocking that occurs.
///
/// This class is thread-safe.
@interface GHRunLoopWatchdog : NSObject
/// Initializes the receiver to watch the specified run loop, using a default
/// stalling threshold.
- (id)initWithRunLoop:(CFRunLoopRef)runLoop;
/// Initializes the receiver to detect when the specified run loop blocks for
@niksumeiko
niksumeiko / git.migrate
Last active April 30, 2024 12:54
Moving git repository and all its branches, tags to a new remote repository keeping commits history
#!/bin/bash
# Sometimes you need to move your existing git repository
# to a new remote repository (/new remote origin).
# Here are a simple and quick steps that does exactly this.
#
# Let's assume we call "old repo" the repository you wish
# to move, and "new repo" the one you wish to move to.
#
### Step 1. Make sure you have a local copy of all "old repo"
### branches and tags.
@dasdom
dasdom / DDHLanguageDetection.m
Last active August 23, 2018 14:39
Language detection in iOS. This code is used to add the language to a post in my ADN client hAppy. This is pubic domain. To with it what every you like!
NSString *languageGuessedString;
if (postString.length < 60) {
languageGuessedString = nil;
} else {
NSArray *componentsArray = [postString componentsSeparatedByString:@" "];
NSMutableString *mutablePostString = [NSMutableString string];
for (NSString *string in componentsArray) {
if ([string rangeOfString:@"@"].location != NSNotFound) {
continue;
@bufferx
bufferx / async_pipelined_requests_demo.py
Last active December 16, 2015 20:39
Async Pipelined HTTP Requests Based On Tornado.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright 2012 Zhang ZY<http://idupx.blogspot.com/>
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
@jboner
jboner / latency.txt
Last active May 6, 2024 07:06
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD