Skip to content

Instantly share code, notes, and snippets.

John johnny77221

  • Taipei, Taiwan
Block or report user

Report or block johnny77221

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@johnny77221
johnny77221 / stop-video.js
Last active Jun 3, 2019 — forked from cferdinandi/stop-video.js
A simple method to stop YouTube, Vimeo, and HTML5 videos from playing.
View stop-video.js
/**
* 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(item) {
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 */
@johnny77221
johnny77221 / Storage.swift
Last active Jun 15, 2018 — forked from saoudrizwan/Storage.swift
Helper class to easily store and retrieve Codable structs from/to disk. https://medium.com/@sdrzn/swift-4-codable-lets-make-things-even-easier-c793b6cf29e1
View Storage.swift
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
@johnny77221
johnny77221 / openBLESetting
Created Oct 24, 2016
opening iOS BLE setting from app
View openBLESetting
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:");
@johnny77221
johnny77221 / JHFacebookLogin.m
Created Feb 19, 2016
Facebook Login Helper
View JHFacebookLogin.m
//
// JHFacebookLogin.m
//
// Created by John Hsu on 2016/2/19.
//
#import "JHFacebookLogin.h"
@implementation JHFacebookLogin
@synthesize accountStore, facebookAccount, handler;
@johnny77221
johnny77221 / JHFacebookLogin.h
Created Feb 19, 2016
Facebook Login Helper
View JHFacebookLogin.h
//
// 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
-(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
{
View drawing.m
NSArray *food = @[
@{
@"name" : @"滄州燒臘",
@"score" : @"50"
},
@{
@"name" : @"Subway",
@"score" : @"80"
},
@{
You can’t perform that action at this time.