Skip to content

Instantly share code, notes, and snippets.

@1901
1901 / getTickCount
Created January 5, 2013 14:55
类似于Windows下的GetTickCount函数(但得到的时间不是开机后的时间)。
#include <iostream>
#include <sys/time.h>
//#include <time.h>
long getTickCount()
{
struct timeval tv;
gettimeofday(&tv, NULL);
@1901
1901 / com.apple.mobile.installation.plist
Created October 31, 2012 09:20
iOS安装信息文件
/Private/var/mobile/Library/Caches/com.apple.mobile.installation.plist
@1901
1901 / block.m
Created May 25, 2012 08:27
Objective-C中block的使用
int i = 5;
int (^test1)() = ^() {
return i * i;
};
int (^test2)(int);
test2 = ^(int a) {
return a * a;
};
@1901
1901 / ac.html
Created April 25, 2012 03:48
使用JS+Html动态修改显示内容
<html>
<SCRIPT LANGUAGE='JavaScript'>
function addline(text, textColor) {
var newDiv = document.createElement('DIV');
newDiv.style.color = textColor;
newDiv.innerHTML = text;
document.getElementById('contentDiv').appendChild(newDiv);
window.scroll(0,window.document.body.scrollHeight);
}
@1901
1901 / sublimeText2_packageControl.py
Last active October 3, 2015 05:58
SublimeText2安装“Package Control”
# 1、打开 Sublime Text 2,按下 Control + ` 调出 Console
# 2、将以下代码粘贴进命令行中并回车
import urllib2,os;pf='Package Control.sublime-package';ipp=sublime.installed_packages_path();os.makedirs(ipp) if not os.path.exists(ipp) else None;open(os.path.join(ipp,pf),'wb').write(urllib2.urlopen('http://sublime.wbond.net/'+pf.replace(' ','%20')).read())
# 3、重启 Sublime Text 2,如果在 Preferences -> Package Settings中见到Package Control这一项,就说明安装成功了
# Sublime Text 2 和 Sublime Text 3中Package Control安装方法及下载地址:
# https://sublime.wbond.net/installation
# Mac系统下长按重复按键
@1901
1901 / UITapGestureRecognizer.m
Created April 17, 2012 08:39
Objective-c手势设置(单击双击事件)
{
GridTileItem* tileItem = something;
UITapGestureRecognizer *singleFingerOne = [[UITapGestureRecognizer alloc] initWithTarget:self
action:@selector(onGridTileItemTouched:)];
singleFingerOne.numberOfTouchesRequired = 1; //手指数
singleFingerOne.numberOfTapsRequired = 1; //tap次数
singleFingerOne.delegate = self;
UITapGestureRecognizer *singleFingerTwo = [[UITapGestureRecognizer alloc] initWithTarget:self
action:@selector(onGridTileItemTouched:)];