Skip to content

Instantly share code, notes, and snippets.

@xiangyuan
xiangyuan / gist:4006579
Created November 3, 2012 08:26
python接收系统参数时
python接收系统参数时第0个参数是指当前指定的文件名
而实际上的参数列表是从1开始的
@xiangyuan
xiangyuan / gist:3999851
Created November 2, 2012 09:53
mac下一个处理plist文件的工具
mac下一个处理plist文件的工具位于
/usr/libexec/PlistBuddy 工具
查看plist文件中的某一项内容时就可以
/usr/libexec/PlistBuddy -c print:CFBundleShortVersionString plistname
就可以打印出相印工程的版本号
@xiangyuan
xiangyuan / gist:3998230
Created November 2, 2012 02:07
vim ide
Vim as a PHP IDE
This Vim configuration is meant to be used to make Vim act more like an IDE. I use it mostly under MacVIM, so some things may be weird in different environments. For now, I'm just planning on using github to make managing my VIM configuraiton more easy, especially with deploying it to different environments. I'm not sure if I will make this a community projects.
I do use this configuration on Linux while running plain vim, and it works fine for the most part.
上面的一稿文章。
2、python的安装pydiction
https://github.com/fsouza/Pydiction.git
@xiangyuan
xiangyuan / gist:3968687
Created October 28, 2012 14:05
python pay attention
只有模板变量,字符串,整数和小数可以作为 {% ifequal %} 标签的参数。下面是合法参数的例子:
{% ifequal variable 1 %}
{% ifequal variable 1.23 %}
{% ifequal variable 'foo' %}
{% ifequal variable "foo" %}
其他任何类型,例如Python的字典类型、列表类型、布尔类型,不能用在 {% ifequal %} 中。 下面是些错误的例子:
{% ifequal variable True %}
@xiangyuan
xiangyuan / gist:3953222
Created October 25, 2012 15:10
django请求原理流程
总结一下:
进来的请求转入/hello/.
Django通过在ROOT_URLCONF配置来决定根URLconf.
Django在URLconf中的所有URL模式中,查找第一个匹配/hello/的条目。
如果找到匹配,将调用相应的视图函数
@xiangyuan
xiangyuan / gist:3871223
Created October 11, 2012 09:25
uinavigatiorbar title view
CGRect frame = CGRectMake(0, 0, 400, 44);
UILabel *label = [[[UILabel alloc] initWithFrame:frame] autorelease];
label.backgroundColor = [UIColor clearColor];
label.font = [FontHelper fontFor:FontTargetForNavigationHeadings];
label.textAlignment = UITextAlignmentCenter;
label.textColor = [UIColor whiteColor];
label.text = self.navigationItem.title;
// emboss in the same way as the native title
[label setShadowColor:[UIColor darkGrayColor]];
[label setShadowOffset:CGSizeMake(0, -0.5)];
@xiangyuan
xiangyuan / gist:3871210
Created October 11, 2012 09:19
uinavigatiorbar title view
CGRect frame = CGRectMake(0, 0, 400, 44);
UILabel *label = [[[UILabel alloc] initWithFrame:frame] autorelease];
label.backgroundColor = [UIColor clearColor];
label.font = [FontHelper fontFor:FontTargetForNavigationHeadings];
label.textAlignment = UITextAlignmentCenter;
label.textColor = [UIColor whiteColor];
label.text = self.navigationItem.title;
// emboss in the same way as the native title
[label setShadowColor:[UIColor darkGrayColor]];
[label setShadowOffset:CGSizeMake(0, -0.5)];
@xiangyuan
xiangyuan / gist:3806303
Created September 30, 2012 09:14
object 去掉尾部符号
NSString * str = @"今天你还,好吗@?¥#¥";
// NSString *nStr = @"~`!@#$%^&*;:\"',.?";
NSMutableCharacterSet *set = [[NSMutableCharacterSet alloc] init];
[set formUnionWithCharacterSet:[NSCharacterSet lowercaseLetterCharacterSet]];//小写字母
NSLog(@"1 %@",[str stringByTrimmingCharactersInSet:set]);
[set formUnionWithCharacterSet:[NSCharacterSet uppercaseLetterCharacterSet]];//大写字母
NSLog(@"2 %@",[str stringByTrimmingCharactersInSet:set]);
[set formUnionWithCharacterSet:[NSCharacterSet symbolCharacterSet]];//符号
NSLog(@"3 %@",[str stringByTrimmingCharactersInSet:set]);
[set formUnionWithCharacterSet:[NSCharacterSet punctuationCharacterSet]];//标点
@xiangyuan
xiangyuan / gist:3793092
Created September 27, 2012 09:25
jwfolder列表展开时问题修正
UITableViewCell * cell = [tableView cellForRowAtIndexPath:indexPath];
CGFloat y = cell.frame.origin.y;
CGFloat varY = abs(y - tableView.contentOffset.y);
if (varY > 316.f) {
CGPoint point = CGPointMake(tableView.contentOffset.x, tableView.contentOffset.y + 80.f);
[tableView setContentOffset:point animated:NO];
}
CGFloat y1 = cell.center.y;
CGFloat offset = tableView.contentOffset.y;
CGFloat deltaY = y1 - offset;
@xiangyuan
xiangyuan / gist:3792999
Created September 27, 2012 09:01
sliderview
//左右轨的图片
UIImage *stetchLeftTrack= [UIImage imageNamed:@"brightness_bar.png"];
UIImage *stetchRightTrack = [UIImage imageNamed:@"brightness_bar.png"];
//滑块图片
UIImage *thumbImage = [UIImage imageNamed:@"mark.png"];
UISlider *sliderA=[[UISlider alloc]initWithFrame:CGRectMake(30, 320, 257, 7)];
sliderA.backgroundColor = [UIColor clearColor];
sliderA.value=1.0;
sliderA.minimumValue=0.7;