Skip to content

Instantly share code, notes, and snippets.

@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 / 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: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 / .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: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 / commonMacro.h
Last active August 29, 2015 14:05
iOS dev useful macro
// 固定用的一些 macro 方法,不牵涉 app 变数定义
// 取角度, convert radius to angle
#define degreesToRadian(x) (M_PI * (x) / 180.0)
//取螢幕尺寸, screen resolution
#define kScreenWidth [[UIScreen mainScreen] bounds].size.width
#define kScreenHeight [[UIScreen mainScreen] bounds].size.height
//判斷是否 iPhone 5, this may need change after iphone6..
-- northwind for postgreSQl.. tell me if it works :p
--
-- PostgreSQL Northwind Database v1.0 from Ramiro Estigarribia Canese
-- you may contact him at email ramiro.estigarribia@rieder.com.py
--
SET statement_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
@adison
adison / SynthesizeSingleton.h
Last active August 29, 2015 14:05
Singleton Macro, with
/*
no need to copy this section.
ussge:
in CustomClass.h
+(instancetype)sharedManager;
in CustomClss.m
@implementation CustomClass
...
SYNTHESIZE_SINGLETON_FOR_CLASS(CustomClass)
@adison
adison / disable-lock.html
Created April 13, 2014 15:40
disable webpage lock
<!--
disable web page locks,
for chrome, get extesion: https://chrome.google.com/webstore/detail/personalized-web/plcnnpdmhobdfbponjpedobekiogmbco
and add code below
-->
<style type="text/css">
* {
-moz-user-select: text !important;
-webkit-user-select:auto !important;
@adison
adison / gist:9540842
Created March 14, 2014 01:58
全螢幕網頁,圖片置中
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, maximum=1.0, minimum-scale=1.0">
<!-- width:可設定數值,或者指定為 device-width
height:可設定數值,或者指定為 device-height
initial-scale:第一次進入頁面的初始比例
minimum-scale:允許縮小最小比例
maximum-scale:允許放大最大比例