Skip to content

Instantly share code, notes, and snippets.

View lanqy's full-sized avatar
🎯
Focusing

Lan Qingyong lanqy

🎯
Focusing
  • Shenzhen,China
View GitHub Profile
@lanqy
lanqy / gist:8523817
Last active January 3, 2016 21:48
通过索引选中table cell
//select first row of first section
// from http://stackoverflow.com/questions/5918309/how-to-programmatically-tap-a-uitableview-cell
// from http://stackoverflow.com/questions/6118071/how-to-set-row-selected-by-default-in-uitableview
NSIndexPath* selectedCellIndexPath= [NSIndexPath indexPathForRow:0 inSection:0];
[self.tableView selectRowAtIndexPath:selectedCellIndexPath animated:false scrollPosition:UITableViewScrollPositionMiddle];
@lanqy
lanqy / gist:8514345
Created January 20, 2014 03:16
How to detect Safari, Chrome, IE, Firefox and Opera browser?
//from http://stackoverflow.com/questions/9847580/how-to-detect-safari-chrome-ie-firefox-and-opera-browser
var isOpera = !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0;
// Opera 8.0+ (UA detection to detect Blink/v8-powered Opera)
var isFirefox = typeof InstallTrigger !== 'undefined'; // Firefox 1.0+
var isSafari = Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0;
// At least Safari 3+: "[object HTMLElementConstructor]"
var isChrome = !!window.chrome && !isOpera; // Chrome 1+
var isIE = /*@cc_on!@*/false || !!document.documentMode; // At least IE6
//
// UIView+frameAdjust.h
// fenbi
//
// Created by Tang Qiao on 12-5-31.
// Copyright (c) 2012年 Fenbi.com . All rights reserved.
//
#import <Foundation/Foundation.h>
//
// CoreTextLabel.h
// Frost
//
// Created by David Kasper on 10/1/12.
//
#import <UIKit/UIKit.h>
#import <CoreText/CoreText.h>
/*
File: Reachability.h
Abstract: Basic demonstration of how to use the SystemConfiguration Reachablity APIs.
Version: 2.2 - ARCified
Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Inc.
("Apple") in consideration of your agreement to the following terms, and your
use, installation, modification or redistribution of this Apple software
@interface UILabel (dynamicSizeMe)
-(float)resizeToFit;
-(float)expectedHeight;
@end
@lanqy
lanqy / api.js
Created October 19, 2013 05:06 — forked from fwielstra/api.js
/* The API controller
Exports 3 methods:
* post - Creates a new thread
* list - Returns a list of threads
* show - Displays a thread and its posts
*/
var Thread = require('../models/thread.js');
var Post = require('../models/post.js');
// from http://qiita.com/Oakbow/items/3374175d76d82792134d
(function () {
if (!("indexOf" in Array.prototype)) {
Array.prototype.indexOf = function (find, i) {
var n;
if (i === undefined) i = 0;
if (i < 0) i += this.length;
if (i < 0) i = 0;
n = this.length;
@lanqy
lanqy / gist:6067881
Created July 24, 2013 03:31
Lazy Function Definition Pattern
//Lazy Function Definition Pattern
// form http://michaux.ca/articles/lazy-function-definition-pattern
var getScrollY = function () {
if (typeof window.pageYOffset == 'number') {
getScrollY = function () {
return window.pageYOffset;
};
} else if ((typeof document.compatMode == 'string') && (document.compatMode.indexOf('CSS') >= 0) && (document.documentElement) && (typeof document.documentElement.scrollTop == 'number')) {
getScrollY = function () {
@lanqy
lanqy / gist:5982869
Created July 12, 2013 08:42
判断浏览器及版本
// form http://stackoverflow.com/questions/5916900/detect-version-of-browser
navigator.userBrowser = (function(){
var N= navigator.appName, ua= navigator.userAgent, tem;
var M= ua.match(/(opera|chrome|safari|firefox|msie)\/?\s*(\.?\d+(\.\d+)*)/i);
if(M && (tem= ua.match(/version\/([\.\d]+)/i))!= null) M[2]= tem[1];
M= M? [M[1], M[2]]: [N, navigator.appVersion,'-?'];
return M;
})();