给Xcode增加复制行、删除行快捷键的方法

September 16th, 2014 by 施 常亮 | Permalink

适用于最新的Xcode 4.5.1

运行:

sudo chmod 666 /Applications/Xcode.app/Contents/Frameworks/IDEKit.framework/Resources/IDETextKeyBindingSet.plist

然后打开/Applications/Xcode.app/Contents/Frameworks/IDEKit.framework/Resources/IDETextKeyBindingSet.plist,在Deletions下面增加:Delete Current Line,值为:

deleteToBeginningOfLine:, moveToEndOfLine:, deleteToBeginningOfLine:, deleteBackward:, moveDown:, moveToBeginningOfLine:

在Insertions and Indentations下面增加:Duplicate Current Line,值为:

selectLine:, copy:, moveToEndOfLine:, insertNewline:, paste:, deleteBackward:

然后重启Xcode,打开设置,Key Bindings,找到“Delete Current Line”和”Duplicate Current Line”这两项,设置为自己想要的快捷键。

怎样查看“隐藏文件夹”?

April 20th, 2014 by 施 常亮 | Permalink

显示Mac隐藏文件的命令:defaults write com.apple.finder AppleShowAllFiles  YES
隐藏Mac隐藏文件的命令:defaults write com.apple.finder AppleShowAllFiles  NO

Mac 下安装64位SVN插件的过程

April 19th, 2014 by 施 常亮 | Permalink

1.打开HomeBrew的主页:http://brew.sh

2.将页面拖到最下边,看到下图:

上边白色的一行命令就是用来安装HomeBrew的,可以看到它是一条Ruby命令,说明HomeBrew是用Ruby来实现的。
因为Mac OS X 已经默认安装了Ruby,所以我们直接执行这条命令就可以了。不放心的可以在终端输入:ruby -v   来查看Ruby的版本。
在终端输入:ruby -e “$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)”
回车,接下来就开始在线安装HomeBrew了,安装时间可能较长,视网络状况而定。homebrew默认是被安装在usr/local下,bin就是它的主目录,并且bin目录的路径已被加入path,在任意目录可以直接执行brew命令。通过brew安装的包都存放在use/local下的Cellar目录中。
3.安装完成后,需要更新下homebrew,终端输入:brew update
4.Home Brew安装成功之后,接下来正式开始安装javaHL,终端输入:brew install –universal –java subversion

这个命令在javaHL的Wiki中可以找到)即可开始安装javaHL,安装完成后,它会提示你:You may need to link the Java bindings…….,然后执行下边的两个sudo命令:
终端输入:sudo mkdir -p /Library/Java/Extensions

sudo ln -s /usr/local/lib/libsvnjavahl-1.dylib /Library/Java/Extensions/libsvnjavahl-1.dylib

即可大功告成!
最后一行会显示JavaHL的版本。比如我的就是下边的这个样子:版本号是:1.8.0

SOAP向服务端提交datatable格式的数据解决方案

July 19th, 2013 by 施 常亮 | Permalink

import java.io.File;

import java.io.FileWriter;
import java.io.IOException;

import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.dom4j.io.XMLWriter;

public class DataTableUtil {
public static void main(String[] args) {
getDataTableXML(“Tabel1”, new String[] { “dh”, “rwmc”, “rwks_date”, “rwjs_date”, “rwbz”, “rwzt”, “opt_user”, “opt_time”, “scbj”, “zt_bm”, “ztmc”, “yw_bm”, “ztmc1”, }, new String[][] { new String[] { “P20130719-001”, “test”, “19.07.13 9:44:53”, “19.07.13 9:44:53”, “”, “zcpd-03”, “系统管理员”, “19.07.13 9:45:55”, “0”, “zcpd-03”, “盘点中”, “zcpd”, “盘点中”, }, new String[] { “P20130719-001”, “test”, “19.07.13 9:44:53”, “19.07.13 9:44:53”, “”, “zcpd-03”, “系统管理员”, “19.07.13 9:45:55”, “0”, “zcpd-03”, “盘点中”, “zcpd”, “盘点中”, }, new String[] { “P20130719-001”, “test”, “19.07.13 9:44:53”, “19.07.13 9:44:53”, “”, “zcpd-03”, “系统管理员”, “19.07.13 9:45:55”, “0”, “zcpd-03”, “盘点中”, “zcpd”, “盘点中”, } });
}

public static String getDataTableXML(String tableName, String[] columnNames, String[][] datas) {
Document document = DocumentHelper.createDocument();
Element dataTable = document.addElement(“DataTable”);

// =====================================
// 开始封装数据库结构
// =====================================
// 组装schema
Element schema = DocumentHelper.createElement(“xs:schema”);
schema.addNamespace(“xs”, “http://www.w3.org/2001/XMLSchema”);
schema.addNamespace(“msdata”, “urn:schemas-microsoft-com:xml-msdata”);
schema.addAttribute(“id”, “NewDataSet”);
dataTable.add(schema);
// 组装scheme_element
// <xs:element name=”NewDataSet” msdata:IsDataSet=”true”
// msdata:MainDataTable=”testDT” msdata:UseCurrentLocale=”true”>
Element schemeElement = schema.addElement(“xs:element”);
schemeElement.addAttribute(“name”, “NewDataSet”);
schemeElement.addAttribute(“msdata:IsDataSet”, “true”);
schemeElement.addAttribute(“msdata:MainDataTable”, tableName);// TODO:
schemeElement.addAttribute(“msdata:UseCurrentLocale”, “true”);

Element schemeElementComplexType = schemeElement.addElement(“xs:complexType”);

// <xs:choice minOccurs=”0″ maxOccurs=”unbounded”>
Element schemeElementComplexTypeChoice = schemeElementComplexType.addElement(“xs:choice”);
schemeElementComplexTypeChoice.addAttribute(“minOccurs”, “0”);
schemeElementComplexTypeChoice.addAttribute(“maxOccurs”, “unbounded”);

// <xs:element name=”testDT”>
Element schemeElementComplexTypeChoiceElement = schemeElementComplexTypeChoice.addElement(“xs:element”);
schemeElementComplexTypeChoiceElement.addAttribute(“name”, tableName);// TODO:

// <xs:complexType>
Element schemeElementComplexTypeChoiceElementComplexType = schemeElementComplexTypeChoiceElement.addElement(“xs:complexType”);
// <xs:sequence>
Element schemeElementComplexTypeChoiceElementComplexTypeSequence = schemeElementComplexTypeChoiceElementComplexType.addElement(“xs:sequence”);
// <xs:element name=”dh” type=”xs:string” minOccurs=”0″/>
for (String string : columnNames) {
Element schemeElementComplexTypeChoiceElementComplexTypeSequenceElement = schemeElementComplexTypeChoiceElementComplexTypeSequence.addElement(“xs:element”);
schemeElementComplexTypeChoiceElementComplexTypeSequenceElement.addAttribute(“name”, string);// TODO:
schemeElementComplexTypeChoiceElementComplexTypeSequenceElement.addAttribute(“type”, “xs:string”);// TODO:
schemeElementComplexTypeChoiceElementComplexTypeSequenceElement.addAttribute(“minOccurs”, “0”);// TODO:
}

// =====================================
// 开始封装数据内容
// =====================================
// <diffgr:diffgram
// xmlns:diffgr=”urn:schemas-microsoft-com:xml-diffgram-v1″
// xmlns:msdata=”urn:schemas-microsoft-com:xml-msdata”>
Element diffgram = DocumentHelper.createElement(“diffgr:diffgram”);
diffgram.addNamespace(“diffgr”, “urn:schemas-microsoft-com:xml-diffgram-v1”);
diffgram.addNamespace(“msdata”, “urn:schemas-microsoft-com:xml-msdata”);
dataTable.add(diffgram);
// <DocumentElement>
Element documentElement = diffgram.addElement(“DocumentElement”);
for (int j = 0; j < datas.length; j++) {
Element tableNameNode = documentElement.addElement(tableName);
tableNameNode.addAttribute(“diffgr:id”, tableName);
tableNameNode.addAttribute(“msdata:rowOrder”, “0”);
for (int i = 0; i < datas[j].length; i++) {
Element dataNode = tableNameNode.addElement(columnNames[i]);
dataNode.addText(datas[j][i]);
}
}
// =====================================
// 输出XML内容
// =====================================
try {
XMLWriter output = new XMLWriter(new FileWriter(new File(“C:/Users/Administrator/Desktop/catalog.xml”)));
output.write(document);
output.close();
} catch (IOException e) {
System.out.println(e.getMessage());
}
return document.asXML();
}
}

Centos6.2 系统一键搭建PPTP VPN方法介绍

June 27th, 2013 by 施 常亮 | Permalink

第一步: 下载vpn(CentOS6专用)一键安装包
#wget http://www.hi-vps.com/shell/vpn_centos6.sh
#chmod a+x vpn_centos6.sh
第二部: 运行一键安装包
#bash vpn_centos6.sh

会有三个选择:

1. 安装VPN服务
2. 修复VPN
3. 添加VPN用户

首先输入1,回车,VPS开始安装VPN服务(VPN服务安装完毕后会默认生成一个用户名为vpn,密码为随机数的用户来。)

此外需要添加新的VPN用户时,作如下操作,
#bash vpn_centos6.sh
然后选择3,然后输入用户名和密码,OK

4. 修复VPN服务
如果VPN拨号发生错误,可以试着修复VPN,然后重启VPS
#bash vpn_centos6.sh
选择2,然后reboot

Linux下Glassfish MySQL的配置

June 15th, 2013 by 施 常亮 | Permalink

  1. 卸载旧版本的mysqllib yum remove mysql-libs;
  2. 安装rpm命令rpm -ivh
  3. 设置新密码SET PASSWORD = PASSWORD(‘xxxxxx’);
  4. 授权远程访问 grant all privileges on *.* to root@’%’ identified by “xxxxxx”;
  5. 添加新用户并授权CREATE USER ‘chaly’@’%’ IDENTIFIED BY ‘xxxxxx’;
    GRANT ALL ON *.* TO ‘chaly’@’%’; flush privileges;
  6. 修改glassfish控制台密码./asadmin change-admin-password.
  7. 启用远程控制管理./asadmin enable-secure-admin
  8. 启动glassfish服务器asadmin start-domain
  9. 关闭服务器./asadmin stop-domain

IOS开发将两个库文件合并为一个库文件的命令

October 30th, 2012 by 施 常亮 | Permalink

lipo -create lib1.a lib2.a -output lib.a

解决“Google Play更新应用出现:服务器无法处理您的apk, 请重试”

October 28th, 2012 by 施 常亮 | Permalink

aapt dump badging path_to_exported_.apk

Myeclipse修改配置文件切换到英文界面

August 31st, 2012 by 施 常亮 | Permalink

Hello world!

Mongodb 学习记录

August 31st, 2012 by 施 常亮 | Permalink

1)查询字段不为null的数据
//查询systemVersion存在切不为null的所有数据
{“systemVersion”:{$exists:true, $nin:[null]}}
2)数据导出
//导出ucenter库下的device表数据到dev.dat文件中
mongoexport -d ucenter -c device -o dev.dat
3)数据导入
mongoimport -d ucenter -c device –file dev.dat