View steps.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
安裝環境: Ubuntu 20.04 LTS | |
確認CPU支援虛擬技術 (回傳非零結果) | |
grep -c -w "vmx\|svm" /proc/cpuinfo | |
sudo apt install -y git devscripts config-package-dev debhelper-compat golang | |
git clone https://github.com/google/android-cuttlefish | |
cd android-cuttlefish | |
debuild -i -us -uc -b -d | |
# 這邊注意不需要安裝全部編譯出的deb | |
dpkg -i ../cuttlefish-base_*_*64.deb |
View gist:2a8e369e0bdfa98f89ef04b361613547
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let splashVC = SplashViewController() | |
let nav = UINavigationController(rootViewController: splashVC) | |
nav.navigationBar.barStyle = .blackOpaque | |
nav.navigationBar.isTranslucent = false | |
// nav.isNavigationBarHidden = true | |
nav.navigationBar.tintColor = .white | |
let navBar = nav.navigationBar | |
if #available(iOS 13.0, *) { | |
let standardAppearance = UINavigationBarAppearance() | |
standardAppearance.configureWithOpaqueBackground() |
View extractSubchunks.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func extractSubchunks(data:Data) -> RiffFile? { | |
var data = data | |
var chunks = [SubChunk]() | |
let position = data.subdata(in: 8..<12) | |
let filelengthBytes = data.subdata(in: 4..<8).map { UInt32($0) } | |
let filelength: UInt32 = filelengthBytes[0] << 24 + filelengthBytes[1] << 16 + filelengthBytes[2] << 8 + filelengthBytes[3] | |
let wave = String(bytes: position, encoding: .utf8) ?? "NoName" | |
guard wave == "WAVE" else { | |
print("File is \(wave) not WAVE") | |
return nil |
View SwiftUser.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
class SwiftUser: UIViewController { | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
TestLib().myFunc() | |
} | |
} |
View stop-video.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Stop an iframe or HTML5 <video> from playing | |
* @param {Element} element The element that contains the video | |
*/ | |
var stopVideo = function ( element ) { | |
element.querySelectorAll('iframe').forEach(function(iframe) { | |
if ( iframe.contentWindow ) { /* send stop to content */ | |
stopVideo(iframe.contentWindow.document); | |
} | |
else { /* Cross Domain, resetting src is all we can do, and the iframe might fail loading same url */ |
View Storage.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
public class Storage { | |
fileprivate init() { } | |
enum Directory { | |
// Only documents and other data that is user-generated, or that cannot otherwise be recreated by your application, should be stored in the <Application_Home>/Documents directory and will be automatically backed up by iCloud. | |
case documents | |
View openBLESetting
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSURL *bluetoothURLOS8 = [NSURL URLWithString:@"prefs:root=General&path=Bluetooth"]; | |
NSURL *bluetoothURLOS9 = [NSURL URLWithString:@"prefs:root=Bluetooth"]; | |
NSURL *bluetoothURLOS10 = [NSURL URLWithString:@"Prefs:root=Bluetooth"]; | |
if ([[[UIDevice currentDevice] systemVersion] intValue] >= 10) { | |
Class<NSObject> workSpaceClass = NSClassFromString(@"LSApplicationWorkspace"); | |
if (workSpaceClass) { | |
#pragma clang diagnostic push | |
#pragma clang diagnostic ignored "-Warc-performSelector-leaks" | |
id workSpaceInstance = [workSpaceClass performSelector:NSSelectorFromString(@"defaultWorkspace")]; | |
SEL selector = NSSelectorFromString(@"openSensitiveURL:withOptions:"); |
View JHFacebookLogin.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// JHFacebookLogin.m | |
// | |
// Created by John Hsu on 2016/2/19. | |
// | |
#import "JHFacebookLogin.h" | |
@implementation JHFacebookLogin | |
@synthesize accountStore, facebookAccount, handler; |
View JHFacebookLogin.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// JHFacebookLogin.h | |
// | |
// Created by John Hsu on 2016/2/19. | |
// | |
#import <Foundation/Foundation.h> | |
#import <Accounts/Accounts.h> | |
#import <Social/Social.h> |
View rotation.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-(IBAction)startRotation:(id)sender | |
{ | |
if (rotateTimer) { | |
[rotateTimer invalidate]; | |
} | |
rotateTimer = [NSTimer scheduledTimerWithTimeInterval:0.01 target:self selector:@selector(rotate) userInfo:nil repeats:YES]; | |
} | |
-(IBAction)stopRotation:(id)sender | |
{ |
NewerOlder