This file contains hidden or 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
| // from http://stackoverflow.com/questions/11726543/how-to-turn-flashlight-on-off-using-one-button | |
| AVCaptureDevice *flashLight = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo]; | |
| if ([flashLight isTorchAvailable] && [flashLight isTorchModeSupported:AVCaptureTorchModeOn]) | |
| { | |
| BOOL success = [flashLight lockForConfiguration:nil]; | |
| if (success) | |
| { | |
| if ([flashLight isTorchActive]) { | |
| [flashLight setTorchMode:AVCaptureTorchModeOff]; | |
| } else { |
This file contains hidden or 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
| ######################### | |
| # https://gist.github.com/adamgit/3786883 | |
| # .gitignore file for Xcode4 / OS X Source projects | |
| # | |
| # Version 2.0 | |
| # For latest version, see: http://stackoverflow.com/questions/49478/git-ignore-file-for-xcode-projects | |
| # | |
| # 2013 updates: | |
| # - fixed the broken "save personal Schemes" | |
| # |
This file contains hidden or 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
| + (BOOL)isJailbroken { | |
| FILE *f = fopen("/bin/bash", "r"); | |
| BOOL isJailbroken = NO; | |
| if (f != NULL) | |
| // Device is jailbroken | |
| isJailbroken = YES; | |
| else | |
| // Device isn't jailbroken | |
| isJailbroken = NO; | |
This file contains hidden or 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
| // Use Gists to store code you would like to remember later on | |
| console.log(window); // log the "window" object to the console |
This file contains hidden or 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
| /* | |
| http://www.objc.io/issue-13/behaviors.html | |
| behavior instance basic | |
| */ | |
| @interface KZBehavior : UIControl | |
| //! object that this controller life will be bound to | |
| @property(nonatomic, weak) IBOutlet id owner; | |
| @end |
This file contains hidden or 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 sys | |
| import os | |
| import git | |
| from git import Repo | |
| from time import gmtime, strftime | |
| import time | |
| # 這是用來 | |
| # 1. 讓 MCS, EC 端檢查檔案是否有更新,有更新則提交 | |
| # 2. 讓本地 repo 進行檢查,然後push到 bit 上 |
This file contains hidden or 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 sublime_plugin | |
| import sublime | |
| # code from http://stackoverflow.com/questions/26286879/can-we-make-use-of-syntax-highlighting-feature-to-remove-all-comments-from-a-sou | |
| # how to use | |
| # save as remove_commands in sublime text package/user folder, | |
| # open foloder from [Preferences] > [Browser Packages], and you will find [User] folder | |
| # save this file in [User] foler. | |
| # | |
| # after file saved, open command panel in sublime text, aka ctrl + ` |
This file contains hidden or 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
| #!bash | |
| # command for pretty log in x days, ex, for logs within 180 days: gitlog 180 | |
| gitlogfunction (){ | |
| git log --since=$1.days --date='local' --pretty=format:'%an %ad %s'; | |
| } | |
| alias gitlog=gitlogfunction; |
This file contains hidden or 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 java.util.*; | |
| import java.util.Random; | |
| import java.util.Date; | |
| import java.text.DateFormat; | |
| import java.text.SimpleDateFormat; | |
| import java.util.Calendar; | |
| class Untitled { | |
| public static void main(String[] args) { |
This file contains hidden or 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
| // | |
| // Macro.h | |
| // mobile-life | |
| // | |
| // Created by Adison Wu on 14/2/14. // 情人節耶!! | |
| // Copyright (c) 2013年 senao. All rights reserved. | |
| // 固定用的一些 macro 方法,不牵涉 app 变数定义 | |
| // 取角度 | |
| #define degreesToRadian(x) (M_PI * (x) / 180.0) |