Skip to content

Instantly share code, notes, and snippets.

// Taken from the commercial iOS PDF framework http://pspdfkit.com.
// Copyright (c) 2013 Peter Steinberger. All rights reserved.
// Licensed under MIT (http://opensource.org/licenses/MIT)
//
// You should only use this in debug builds. It doesn't use private API, but I wouldn't ship it.
#import <objc/runtime.h>
#import <objc/message.h>
// Compile-time selector checks.
@lerosua
lerosua / notepad.html
Last active December 11, 2015 22:39 — forked from jdkanani/notepad.html
data:text/html, <style type="text/css">.e{position:absolute;top:0;right:0;bottom:0;left:0;}</style><div class="e" id="editor"></div><script src="http://d1n0x3qji82z53.cloudfront.net/src-min-noconflict/ace.js" type="text/javascript" charset="utf-8"></script><script>var e=ace.edit("editor");e.setTheme("ace/theme/monokai");e.getSession().setMode("ace/mode/c_cpp");</script>
<!--
For other language: Instead of `ace/mode/ruby`, Use
Python -> `ace/mode/python`
C/C++ -> `ace/mode/c_cpp`
Javscript -> `ace/mode/javascript`
Java -> `ace/mode/java`
@lerosua
lerosua / mysql-fix
Last active December 10, 2015 22:08
mysql 改数据命令
//打开数据库
$mysql -h localhost -u leros -p密码
//连接数据库表
mysql> connect statusnet
//根据条件查看数据值
mysql> select value from config where section="site" and setting="path";
//根据条件设置新值
@lerosua
lerosua / horizotal-tableview
Created January 6, 2013 06:28
创建一个横向的tableview
创建前先设定tableview的rowHeight,然后旋转。
每个row的高度即为旋转后的宽度。然后在cellWillDisplay里旋转一下cell就可以了。
- (UITableView *)payTableView {
if(!_payTableView){
_payTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 320, 320) style:UITableViewStylePlain];
_payTableView.backgroundColor = [UIColor clearColor];
_payTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
_payTableView.showsVerticalScrollIndicator = NO;
_payTableView.delegate = self;
@lerosua
lerosua / ARC-rule
Last active December 10, 2015 17:08
ARC中的一些规则
大意是说,在 ARC 中,一般outlet属性都推荐使用 weak,应该使用 strong 的 outlet 是 File's Owner连接到 nib 的顶层对象。
顺便提一下ARC其他属性的规则:
strong:等同于"retain",属性成为对象的拥有者
weak:属性是 weak pointer,当对象释放时会自动设置为 nil
unsafe_unretained:等同于之前的"assign",只有 iOS 4 才应该使用
copy:和之前的 copy 一样,复制一个对象并创建 strong 关联
assign:对象不能使用 assign,但原始类型(BOOL、int、float)仍然可以使用
@lerosua
lerosua / sqlite-insert
Last active December 9, 2015 19:18
sqlite插入数据示例
查看所有省
select * from Province;
根据省ID查看此省的所有城市
select * from City where ProID="610000";
根据城市ID查看此市所有区
select * from Zone where CityID="610100";
给Zone表插入一个新区,顺序一直按照着表的数据列来。
@lerosua
lerosua / qomoq-4.1-fix
Created November 26, 2012 02:19
fix qomo 4.1
装上这个faience-themes
还有 gnome-shell-theme-mixtured
lerosux: 你装好这2个主题, 删掉你的 .local/share/gnome-shell/extensions
再把 /etc/.skel/.config/user-first-run.sh 复制过来, 执行一下
@lerosua
lerosua / ust_atos_after_crash
Created November 9, 2012 05:55
使用atos查看crash后的地址
设置xcode使用环境
export DEVELOPER_DIR="/Applications/XCode.app/Contents/Developer"
查看当前xcode环境
xcode-select --print-path
~/Documents/work/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/PrivateFrameworks/DTDeviceKit.framework/Versions/A/Resources/symbolicatecrash -o output.txt me.crash YinBa.app.dSYM
~/Documents/work/Xcode.app/Contents/Developer/usr/bin/atos -arch armv7s -o 'YinBa.app'/'YinBa' $1
@lerosua
lerosua / uiview-animation
Created November 1, 2012 07:28
用于设置UIImageView图像时有个过渡渐变过程的动画代码
[UIView transitionWithView:self.buttonA duration:0.4f options:UIViewAnimationOptionTransitionCrossDissolve animations:^{
[self.buttonA setBackgroundImage:image forState:UIControlStateNormal];
}completion:NULL];