Skip to content

Instantly share code, notes, and snippets.

Avatar

Realazy Xian-an CHEN cxa

View GitHub Profile
@cxa
cxa / dotnet.doc.md
Created Apr 19, 2021
.NET 文档书签
View dotnet.doc.md

创建一个新书签,将以下内容作为书签的 url:

javascript:(()=> { const ns = prompt('namespace and/or class (e.g. system.net.http)'); ns && (window.location=`https://docs.microsoft.com/en-us/dotnet/api/${ns}?view=net-5.0`)})()
@cxa
cxa / regexCheatsheet.js
Last active May 13, 2022 — forked from sarthology/regexCheatsheet.js
A regex cheatsheet 👩🏻‍💻 (by Catherine)
View regexCheatsheet.js
let regex;
/* 匹配特定的字符串 */
regex = /hello/; // 查找斜杠中的字符串(大小写敏感)……匹配 "hello", "hello123", "123hello123", "123hello",但不匹配 "hell0", "Hello"
regex = /hello/i; // 查找斜杠中的字符串(大小写不敏感)……匹配 "hello", "HelLo", "123HelLO"
regex = /hello/g; // 全局查找斜杠中的字符串……
/* 通配符 */
regex = /h.llo/; // "." 匹配除了换行外的任何一个字符……匹配 "hello", "hallo",但不匹配 "h\nllo"
regex = /h.*llo/; // "*" 匹配任何字符零次或多次,如 "hello", "heeeeeello", "hllo", "hwarwareallo"
View gist:fec67e92fe64d01a8c2d9f1e11a05c69
Process: Xcode [79975]
Path: /Applications/Xcode.app/Contents/MacOS/Xcode
Identifier: Xcode
Version: 9.0 (13247)
Code Type: X86-64 (Native)
Parent Process: ??? [1]
Responsible: Xcode [79975]
User ID: 501
Date/Time: 2017-09-14 20:28:22.458 +0800
View AVCamManualCameraViewController.m
if ( rawEnabled && self.photoOutput.availableRawPhotoPixelFormatTypes.count ) {
//photoSettings = [[AVCapturePhotoBracketSettings alloc] initWithFormat:nil rawPixelFormatType:(OSType)(((NSNumber *)self.photoOutput.availableRawPhotoPixelFormatTypes[0]).unsignedLongValue) bracketedSettings:bracketedSettings];
photoSettings = [AVCapturePhotoBracketSettings photoBracketSettingsWithRawPixelFormatType:(OSType)(((NSNumber *)self.photoOutput.availableRawPhotoPixelFormatTypes[0]).unsignedLongValue) processedFormat:nil bracketedSettings:bracketedSettings];
}
else {
//photoSettings = [[AVCapturePhotoBracketSettings alloc] initWithFormat:@{ AVVideoCodecKey : AVVideoCodecJPEG } rawPixelFormatType:0 bracketedSettings:bracketedSettings];
photoSettings = [AVCapturePhotoBracketSettings photoBracketSettingsWithRawPixelFormatType:0 processedFormat:@{ AVVideoCodecKey : AVVideoCodecJPEG } bracketedSettings:bracketedSettings];
}
@cxa
cxa / gist:48f1be2653fd35843d98
Created Feb 26, 2015
Convert an Integer to bytes
View gist:48f1be2653fd35843d98
func bytes<T: IntegerType>(i: T) -> [UInt8] {
let p = UnsafeMutablePointer<T>.alloc(1)
p.memory = i
let b = unsafeBitCast(p, UnsafePointer<UInt8>.self)
let bytes = reduce(0..<sizeof(T), []) { $0 + [b[$1]] }
p.destroy()
return bytes
}
@cxa
cxa / gist:226a07fa8aad9335c2fb
Last active Aug 29, 2015
Keyboard Layout Model with Swift
View gist:226a07fa8aad9335c2fb
enum ShiftKeyType {
case None
case Once
case Always
}
enum PunctuationSwitcherType {
case More
case Numeric
}
@cxa
cxa / gist:bb8708a8214fe6d02365
Last active Aug 29, 2015
Swift example: Interacting with C APIs
View gist:bb8708a8214fe6d02365
// BridgeHeader.h
#import <unicode/uchar.h>
// UnicodeBlock.swift
import Foundation
class UnicodeBlock {
class var blocks: UnicodeBlock[] {
@cxa
cxa / Prefix.pch
Last active Dec 11, 2015
Is there a one-step solution for line 10? Currently I must assign a compiler flag to a .m file with `-DCOMPILE_ONCE`.
View Prefix.pch
#ifdef __OBJC__
#import <Foundation/Foundation.h>
#define BUNDLE_NAME CXAFileManagerResourceBundle
extern NSBundle *BUNDLE_NAME;
#undef NSLocalizedString
#define NSLocalizedString(key, comment) [BUNDLE_NAME localizedStringForKey:(key) value:@"" table:nil]
#ifdef COMPILE_ONCE
View gist:4618561
int fiddle = open("DOCUMENT_DIRECTORY", O_EVTONLY);
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
dispatch_source_t source = dispatch_source_create(DISPATCH_SOURCE_TYPE_VNODE, fiddle, DISPATCH_VNODE_WRITE, queue);
dispatch_source_set_event_handler(source, ^{
// how to determine if a file has finished copying?
});
@cxa
cxa / gist:3936832
Created Oct 23, 2012 — forked from huacnlee/gist:3936299
Mac 清理 TextMate 2 不断升级带出一堆多余的打开方式
View gist:3936832
/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user