Skip to content

Instantly share code, notes, and snippets.

@xiangyuan
xiangyuan / gist:5433605
Created April 22, 2013 09:45
get the douban music address
sudo tcpdump -i en0 -nn -s0 -A -l|grep --line-buffered "Host: \|GET "
# 1. Make sure you have nginx sub module compiled in
# nginx -V 2>&1 | grep --color=always '\-\-with\-http_sub_module'
# 2. add two directives below at HTTP level
# nginx.conf
http {
# ......
sub_filter '</head>' '<style type="text/css">html{ filter:progid:DXImageTransform.Microsoft.BasicImage(grayscale=1); -webkit-filter: grayscale(100%); filter: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'><filter id=\'grayscale\'><feColorMatrix type=\'matrix\' values=\'0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0\'/></filter></svg>#grayscale"); /* Firefox 10+, Firefox on Android */
" General Settings
set expandtab
set tabstop=4
set shiftwidth=4
set softtabstop=4
set nocompatible " We're running Vim, not Vi!
set noswapfile " No swap files
set visualbell t_vb= " No visual bell
set ai " auto indenting
set history=100 " keep 100 lines of history
@xiangyuan
xiangyuan / gist:5289489
Created April 2, 2013 02:25
iphone流量统计
通过读取系统网络接口信息,获取当前iphone设备的流量相关信息,统计的是上次开机至今的流量信息. 2
倒入库:
[html] view plaincopy
SystemConfiguration.framework
加入头文件:
[html] view plaincopy
#include <ifaddrs.h>
#include <sys/socket.h>
#include <net/if.h>
@xiangyuan
xiangyuan / gist:5283671
Created April 1, 2013 07:33
tablview single line remove
一.问题
使用UITableViewStylePlain类型的tableView时,如果将separatorStyle设置为UITableViewCellSeparatorStyleSingleLine,就会在每行的下边自动显示一条线,即使是空行也会显示,这样在tableView中无数据时就只会显示一条一条的线,这样可能不是我们想要的效果,如图所示:
空表:
有数据的表:
二.解决方法
有一个简单的方法可以将空行的线去除,即在tableView中添加一个tableFooterView,如果不需要tableFooterView显示什么数据,可以直接添加个空view。
tableView.tableFooterView = [[UIView alloc]init];
三. 结果
@xiangyuan
xiangyuan / gist:5219626
Last active December 15, 2015 06:58
关于image mask
1、关于使用 CGImageCreateWithMask(<#CGImageRef image#>, <#CGImageRef mask#>)来进行掩码时。
情况一:第二个参数是用CGImageMaskCreate创建生成的 image mask。
那么就会是黑色部分出现,白色部分消失。
CGImageRef topRef = mask.CGImage;
CGImageRef maskImage = CGImageMaskCreate(CGImageGetWidth(topRef), CGImageGetHeight(topRef), CGImageGetBitsPerComponent(topRef), CGImageGetBitsPerPixel(topRef), CGImageGetBytesPerRow(topRef), CGImageGetDataProvider(topRef), CGImageGetDecode(topRef), false);
// CGImageRef target = CGImageCreateWithMask(origin.CGImage, maskImage);
// UIImage * image = [UIImage imageWithCGImage:target];
//release
@xiangyuan
xiangyuan / xcode4.6 indexing
Last active December 14, 2015 22:39
disable the xcode 4.6 indexing
defaults write com.apple.dt.xcode IDEIndexDisable 1
#define ApplicationDelegate ((AppDelegate *)[[UIApplication sharedApplication] delegate])
#define UserDefaults [NSUserDefaults standardUserDefaults]
#define NotificationCenter [NSNotificationCenter defaultCenter]
#define SharedApplication [UIApplication sharedApplication]
#define Bundle [NSBundle mainBundle]
#define MainScreen [UIScreen mainScreen]
#define ShowNetworkActivityIndicator() [UIApplication sharedApplication].networkActivityIndicatorVisible = YES
#define HideNetworkActivityIndicator() [UIApplication sharedApplication].networkActivityIndicatorVisible = NO
#define NetworkActivityIndicatorVisible(x) [UIApplication sharedApplication].networkActivityIndicatorVisible = x
#define NavBar self.navigationController.navigationBar
@xiangyuan
xiangyuan / gist:4377039
Created December 26, 2012 01:34
apple app icon glossy effects enable
<key>CFBundleIcons</key>
<dict>
<key>CFBundlePrimaryIcon</key>
<dict>
<key>CFBundleIconFiles</key>
<array>
<string>myIcon.png</string>
</array>
<key>UIPrerenderedIcon</key>
<true/>
@xiangyuan
xiangyuan / gist:4143441
Created November 25, 2012 13:15
github建立个人站点
markdown语法快速成文,git与github实时保存,jekyll或octopress实时成书或者showoff实时成ppt。入门略有门槛,但是习惯了,写作效率会好很多。以下以octopress为例,进行说明。
配置个人github账号
登陆github,创建一个个人账号。假设叫做:rubyonchina。
然后回到ubuntu或者Mac里面,仍然是在终端里面,输入:
[[ -f ~/.ssh/id_rsa.pub ]] || ssh-keygen -t rsa
按照默认提示一路确认,生成密钥之后,将生成的信息复制到github页面中,如下所示: