Skip to content

Instantly share code, notes, and snippets.

View shuizhongyueming's full-sized avatar
🎯
Focusing

happy wang shuizhongyueming

🎯
Focusing
View GitHub Profile
@shuizhongyueming
shuizhongyueming / UIActionSheet.m
Created February 18, 2014 09:05
如何使用UIActionSheet
// 定义一个UIActionSheet
UIActionSheet *actionSheet = [[UIActionSheet alloc]
initWithTitle:@"Are you sure?"
delegate:self
cancelButtonTitle:@"No Way!"
destructiveButtonTitle:@"Yes, I'm Sure"
// 其他按钮,没有直接写nil
otherButtonTitles:@"Foo",@"Bar",nil];
// 放到View中显示
@shuizhongyueming
shuizhongyueming / UIButton+Stretchable.m
Created April 7, 2014 08:59
一个通用的给UIButton的background的图片做拉伸的委托
@implementation UIButton (StretchableUIButton)
/* Automatically set cap insets for the background image. This assumes that
the image is a standard slice size with a 1 px stretchable interior */
- (void)setBackgroundImageStretchableForState:(UIControlState)controlState
{
UIImage *image = [self backgroundImageForState:controlState];
if (image)
{
CGFloat capWidth = floorf(image.size.width / 2);
CGFloat capHeight = floorf(image.size.height / 2);
@shuizhongyueming
shuizhongyueming / reuseTableViewCell.m
Created April 23, 2014 09:12
cellForRowAtIndex时,使用到的可重用的cell
SomeCell * cell = [tableView dequeueReusableCellWithIdentifier:@"someIdentifier"];
if(cell == nil){
cell = [[SomeCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"someIdentifier"];
}
@shuizhongyueming
shuizhongyueming / md5.m
Created May 16, 2014 03:09
实现md5加密的方案
-(NSString *)md5:(NSString *)str {
//转换成utf-8
const char *cStr = [str UTF8String];
//开辟一个16字节(128位:md5加密出来就是128位/bit)的空间(一个字节=8字位=8个二进制数)
unsigned char result[16];
CC_MD5( cStr, strlen(cStr), result);
@shuizhongyueming
shuizhongyueming / datasource-tasks-results
Created November 23, 2015 11:27 — forked from serkanserttop/datasource-tasks-results
Loopback Model Discovery, bug?
//DataSource.prototype.discoverSchemas
//async.parallel(tasks, function (err, results) {
// console.log(results);
//https://github.com/strongloop/loopback-datasource-juggler/blob/master/lib/datasource.js#L1205
[
[
{ owner: 'chosendb',
tableName: 'chosentable',
columnName: 'id'
},
@shuizhongyueming
shuizhongyueming / parseURI.js
Created January 28, 2013 14:50
JavaScript: util parseURI
/**
* [parseURI 解析URI的内容,返回键值对的对象]
* @param {[string]} uri [要解析的URI值]
* @return {[obj]} [URI的键值对的对象]
* @author 水中月明(shuizhongyueming@gmail.com)
*/
function parseURI(uri){
var uri = uri || window.location.search; // 默认使用当前页面的uri值
try{
uri = uri.replace("?",""); // 去除?
@shuizhongyueming
shuizhongyueming / SlideMarkMark.js
Created May 10, 2013 16:51
JQuery: UI SlideMarkMark
/**
* [SlideMarkMark 滑动评分组件,目前仅支持横向]
* @require jQuery 1.7+
* @demo http://news.7k7k.com/webgame/astd/
* @param {[Object]} slideRegion [将参数打包成对象传入]
* @param {[Number]} slideRegion.maxMark [评分的最大值 默认:10]
* @param {[Number]} slideRegion.decimalPlace [小数的位数 默认:1]
* @param {[Number]} slideRegion.contWidth [滑动区域的宽度 默认:slideRegion.cont.width()]
* @param {[Number]} slideRegion.shortestLeft [滑块最小偏移值,考虑到滑块的宽度 一般会认为滑动的按钮的中线(非左右两边)到达两端时为滑动的极限 有默认值]
@shuizhongyueming
shuizhongyueming / CloudTag.js
Created May 10, 2013 16:48
JQuery: UI CloudTag
/**
* @name[CloudTag]
* @overview [一个UI组件,用于制作云标签,
* 依赖jQuery 做的很简单,只能简单的从下往上滚动,没有做到那种球状的旋转]
* @param {[Array]} arr [存放云标签内容的数组]
* @param {[Array]} fontSizeArr [存放文本大小可以随机的值]
* @param {[Array]} colorArr [存放文本颜色可以随机的值]
* @param {[Object]} option [传入相关参数]
* @param {[string]} option.cont [存放云标签的容器 query string]
* @param {[string]} option.tagConts [单个标签的各自的直接父元素 query string]
@shuizhongyueming
shuizhongyueming / getElementsByClassName.js
Created May 10, 2013 16:46
JavaScript: util getElementsByClassName
/*
 * @name [getElementsByClassName]
* @overview [根据元素clsssName得到元素集合]
 * @param {[string]} fatherId [父元素的ID,默认为document]
 * @param {[string]} tagName [子元素的标签名]
 * @param {[string]} className [用空格分开的className字符串]
*
* @author unknown
 */
function getElementsByClassName(fatherId,tagName,className){
@shuizhongyueming
shuizhongyueming / getRealStyle.js
Created May 10, 2013 16:49
JavaScript: Util getRealStyle
/**
* @name [getRealStyle]
* @overview [获取元素的CSS属性值]
* @param {[Object]} obj [要获取CSS属性值的DOM对象或者jQuery对象]
* @param {[string]} styleName [属性名]
* @return {[string]} [属性值]
* @author unknown
*/
function getRealStyle(obj,styleName){//访问CSS属性
var realStyle = null;