Skip to content

Instantly share code, notes, and snippets.

@adison
adison / gist:9a93aa7b0935befd46e0
Created August 20, 2014 05:25
flash light test snippet
// 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 {
@adison
adison / .gitignore
Created August 20, 2014 10:19 — forked from adamgit/.gitignore
#########################
# 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"
#
@adison
adison / gist:dbd810ebcc71cd33bf5a
Created September 9, 2014 08:51
isJailBroken
+ (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;
@adison
adison / 0_reuse_code.js
Last active August 29, 2015 14:06
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@adison
adison / gist:0461b6637734f435df07
Created September 26, 2014 06:22
behavior instance class
/*
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
@adison
adison / routineBackup.py
Created May 29, 2015 09:12
git python SAMBA bakcup script
import sys
import os
import git
from git import Repo
from time import gmtime, strftime
import time
# 這是用來
# 1. 讓 MCS, EC 端檢查檔案是否有更新,有更新則提交
# 2. 讓本地 repo 進行檢查,然後push到 bit 上
@adison
adison / remove_comments.py
Last active August 4, 2017 17:34
remove comments in sublime text
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 + `
@adison
adison / gist:eea8c608112e175e45d9
Last active August 29, 2015 14:27
some useful bash alias for git
#!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;
@adison
adison / checksum.java
Last active August 29, 2015 14:28
java xor chemsum
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) {
@adison
adison / gist:47bf79fcc62685da3837
Created September 20, 2015 03:50
ios 常用 macro
//
// 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)