Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View ourui's full-sized avatar

Ourui ourui

  • iQIYI
  • ShangHai. China
View GitHub Profile
@Einstrasse
Einstrasse / bits-stdc++.h
Created December 3, 2019 14:52
bits/stdc++.h header file
// C++ includes used for precompiling -*- C++ -*-
// Copyright (C) 2003-2015 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
@tclementdev
tclementdev / libdispatch-efficiency-tips.md
Last active April 16, 2024 01:02
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

@agentsim
agentsim / highsierra_bootable.sh
Created June 10, 2017 02:23
Create bootable ISO from HighSierra Installer
# Generate a BaseSystem.dmg with 10.13 Install Packages
hdiutil attach /Applications/Install\ macOS\ 10.13\ Beta.app/Contents/SharedSupport/InstallESD.dmg -noverify -mountpoint /Volumes/highsierra
hdiutil create -o /tmp/HighSierraBase.cdr -size 7316m -layout SPUD -fs HFS+J
hdiutil attach /tmp/HighSierraBase.cdr.dmg -noverify -mountpoint /Volumes/install_build
asr restore -source /Applications/Install\ macOS\ 10.13\ Beta.app/Contents/SharedSupport/BaseSystem.dmg -target /Volumes/install_build -noprompt -noverify -erase
cp -R /Volumes/highsierra/Packages /Volumes/OS\ X\ Base\ System/System/Installation
hdiutil detach /Volumes/OS\ X\ Base\ System/
hdiutil detach /Volumes/highsierra/
mv /tmp/HighSierraBase.cdr.dmg /tmp/BaseSystem.dmg
@maxcampolo
maxcampolo / NativeWebView.swift
Created July 28, 2016 13:58
WKWebView setup to make a web page adopt native behavior.
import WebKit
class NativeWebViewController: UIViewController {
let viewportScriptString = "var meta = document.createElement('meta'); meta.setAttribute('name', 'viewport'); meta.setAttribute('content', 'width=device-width'); meta.setAttribute('initial-scale', '1.0'); meta.setAttribute('maximum-scale', '1.0'); meta.setAttribute('minimum-scale', '1.0'); meta.setAttribute('user-scalable', 'no'); document.getElementsByTagName('head')[0].appendChild(meta);"
let disableSelectionScriptString = "document.documentElement.style.webkitUserSelect='none';"
let disableCalloutScriptString = "document.documentElement.style.webkitTouchCallout='none';"
override func viewDidLoad() {
// 1 - Make user scripts for injection
@hfossli
hfossli / UIScrollView+ScrollsToTop.h
Last active December 27, 2016 22:17
A simple way to make sure there is only one scrollview which is able to scroll to top at a time
#import <UIKit/UIKit.h>
@interface UIScrollView (ScrollsToTop)
+ (void)forceNewViewsDefaultValueForScrollsToTop;
+ (void)makeOnlyThisScrollViewScrollToTopOnStatusBarTap:(UIScrollView *)scrollView;
- (void)makeOnlyThisScrollViewScrollToTopOnStatusBarTap;
@end
expr -- (void)printf("[%s %s]\n",(char *) object_getClassName(*(long*)($rdi)), (char *)($rsi))
@krzysztofzablocki
krzysztofzablocki / gist:4396302
Last active November 24, 2021 19:17
Set symbol breakpoint on objc_msgSend then setup this debug command to log all methods called in iOS Simulator. If you want to do device debugging change esp+4 register to r0, esp+8 to r1 Found long ago somewhere on stackoverflow.
expr -- (void)printf("[%s, %s]\n",(char *) object_getClassName(*(long*)($esp+4)), (char *) *(long *)($esp+8) )
0 = Success
1 = Operation not permitted
2 = No such file or directory
3 = No such process
4 = Interrupted system call
5 = Input/output error
6 = No such device or address
7 = Argument list too long
8 = Exec format error