星期二, 十一月 22, 2011
星期六, 十月 29, 2011
How to fix problem of incompatibility between GCC 4.6 and Android 2.3
http://buildall.wordpress.com/2011/05/27/how-to-fix-problem-of-incompatibility-between-gcc-4-6-and-android-2-3-gingerbread/
Hello everybody. Let's see how we can fix one problem that can happen when you try to compile the Android 2.3 after you already have installed GCC 4.6.
During Android compilation you can receive the following error message:
host Executable: acp (out/host/linux-x86/obj/EXECUTABLES/acp_intermediates/acp)
host SharedLib: libneo_cs (out/host/linux-x86/obj/lib/libneo_cs.so)
host C++: libutils <= frameworks/base/libs/utils/RefBase.cpp
frameworks/base/libs/utils/RefBase.cpp: In member function 'void android::RefBase::weakref_type::trackMe(bool, bool)':
frameworks/base/libs/utils/RefBase.cpp:483:67: error: passing 'const android::RefBase::weakref_impl' as 'this' argument of 'void android::RefBase::weakref_impl::trackMe(bool, bool)' discards qualifiers [-fpermissive]
make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/libutils_intermediates/RefBase.o] Error 1
make: *** Waiting for unfinished jobs....
To fix that, open a terminal and run (assuming you are in the folder android):
gedit frameworks/base/libs/utils/Android.mk
Change the line:
LOCAL_CFLAGS += -DLIBUTILS_NATIVE=1 $(TOOL_CFLAGS)
To:
LOCAL_CFLAGS += -DLIBUTILS_NATIVE=1 $(TOOL_CFLAGS) -fpermissive
After that, save the file and recompile the Android again.
That's it. See you next time.
星期二, 十月 25, 2011
如何安装Guest Addtions 在VirtualBox 和utunbu 11.10。
You can follow the steps below to install the guest additions program on your ubuntu 11.10:
1) Create a temp directory in your home directory
2) Copy the whole file into the temp directory from /media/VBo..
3) Sudo apt-get install linux-headers-3.0.0-12-generic-pae
*Actually you get to make sure what kernel version on your machine
*After that, make sure your get "linux-headers-3.0.0-12-generic-pae" tree in "usr/src"
4) Install the guest additions utility.
具体编译log可以查看/var/log/vboxadd-install.log
/usr/bin/VBoxClient× 系列软件,可以运行。
启动桌面后,即可粘帖了
星期一, 五月 23, 2011
星期五, 五月 06, 2011
Java WebStart和可执行jar文件如何读取外部jar文件包含的资源。
网络运行的Java Webstart的JNLP的写法里和可执行的jar文件里,都包含了对外部jar文件的依赖的语法
比如JNLP 语法:
<jar href="lib/hsqldb.jar"/>
可执行jar文件MANIFEST.MF里包含的语句:
Class-Path:
lib/appframework-1.0.3.jar
lib/swing-worker-1.1.jar
常见的是把图片等其他非class文件组织打包成一个jar文件,方便程序中使用。
在可执行的jar文件中,只需要一行代码就可以得到这些资源。
比如在lib/appframework-1.0.3.jar包含一个打印格式文件jrxml
都放在report/目录下,一个工作单打印文件WorkOrder.jrxml.
必须使用Thread.currentThread().getContextClassLoader()定制的ClassLoader来调用
或this.getClass().getClassLoader()
注意this的意思必须是个运行时的类实例,而不能是静态类的.class.getClass()的方法。
InputStream test=null;
try
{
test = Thread.currentThread().getContextClassLoader().getResourceAsStream("report/WorkOrder.jrxml");
或者:
test =new YouCurrentClassName().getClass().getClassLoader().getResourceAsStream("report/WorkOrder.jrxml");
if(test!=null)
{
InputStreamReader inr=new InputStreamReader(test,"UTF-8");
BufferedReader br=new BufferedReader(inr);
String line="";
while( (line=br.readLine())!=null)
{
System.out.println(line);
}
另外不在classpath里的jar包的资源调用。
可以使用java.net.URL("jar:file://d:/temp/test.jar!");的语法来读取。
public JarFile tJar = null;
public JarURLConnection uc = null;
String resourcepath="image/log.jpg";
URL u = new URL("jar:file:lib/ReportResource_jrxml.jar!/");
uc = (JarURLConnection)u.openConnection();
tJar = uc.getJarFile();
// Enumeration entries = tJar.entries();
// while (entries.hasMoreElements()) {
// ZipEntry entry = (ZipEntry) entries.nextElement();
// System.out.println(entry.getName());
//
// }
input = tJar.getInputStream(tJar.getEntry(resourcepath));
星期四, 五月 05, 2011
判断内部IP地址和外部IP地址(private IP address or public IP Address)
* Judge IP Address is private or public address
*/
public static boolean isInnerIP(String ipAddress){
boolean isInnerIp = false;
long ipNum = getIpNum(ipAddress);
/**
私有IP:A类 10.0.0.0-10.255.255.255
B类 172.16.0.0-172.31.255.255
C类 192.168.0.0-192.168.255.255
当然,还有127这个网段是环回地址
**/
long aBegin = getIpNum("10.0.0.0");
long aEnd = getIpNum("10.255.255.255");
long bBegin = getIpNum("172.16.0.0");
long bEnd = getIpNum("172.31.255.255");
long cBegin = getIpNum("192.168.0.0");
long cEnd = getIpNum("192.168.255.255");
isInnerIp = isInner(ipNum,aBegin,aEnd) || isInner(ipNum,bBegin,bEnd) || isInner(ipNum,cBegin,cEnd) || ipAddress.equals("127.0.0.1");
return isInnerIp;
}
private static long getIpNum(String ipAddress) {
String [] ip = ipAddress.split("\\.");
long a = Integer.parseInt(ip[0]);
long b = Integer.parseInt(ip[1]);
long c = Integer.parseInt(ip[2]);
long d = Integer.parseInt(ip[3]);
long ipNum = a * 256 * 256 * 256 + b * 256 * 256 + c * 256 + d;
return ipNum;
}
private static boolean isInner(long userIp,long begin,long end){
return (userIp>=begin) && (userIp<=end);
}
星期五, 四月 15, 2011
改变JDE(julian)日期为标准ISO 格式(年-月-日)
WASTRT 是Order StartDate,都是6个长度的numberic 的字段。
通过下列表达式可以将其转换为标准的 yyyy-MM-dd格式。
TIMESTAMP(DATE(DIGITS(DEC(WATRDJ + 1900000,7,0))),TIME('00:00:00')) as t1 ,
char(DATE(CHAR(DEC(WASTRT + 1900000,7,0))),iso)
星期五, 三月 25, 2011
如何删除JDialog右上角的X 关闭按钮
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
class Testing
{
public void buildGUI()
{
JDialog.setDefaultLookAndFeelDecorated(true);
JDialog d = new MyDialog();
d.setModal(true);
d.getRootPane().setDefaultButton(null);
JPanel p = new JPanel(new GridBagLayout());
JButton btn = new JButton("Exit");
p.add(btn,new GridBagConstraints());
d.getContentPane().add(p);
d.setSize(400,300);
d.setLocationRelativeTo(null);
btn.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ae){
System.exit(0);
}
});
d.setVisible(true);
}
public static void main(String[] args)
{
SwingUtilities.invokeLater(new Runnable()
{
public void run(){
new Testing().buildGUI();
}
});
}
}
class MyDialog extends JDialog
{
public MyDialog()
{
System.out.println("....");
removeX(this);
}
public void removeX(Component comp)
{
if (comp instanceof JButton)
{
System.out.println("..."+comp);
Icon i=((JButton)comp).getIcon();
System.out.println("..2."+i.getClass());
//System.out.println("...2"+(AbstractButton)comp.getDefaultIcon());
comp.getParent().remove(comp);
}
if (comp instanceof Container)
{
Component[] comps = ((Container)comp).getComponents();
for(int x = 0, y = comps.length; x < y; x++)
{
removeX(comps[x]);
}
}
}
}
</code>
星期三, 二月 16, 2011
星期一, 二月 07, 2011
VIM 大小写不敏感搜索.
:set ic (:set ignorecase) 忽略大小写
:set noic (:set noignorecase) 大小写敏感
或者使用:
/\cword.用前置模式来搜索,也可以
星期三, 一月 12, 2011
ECL 10.7.1 如何才能正确打印出汉字
foo.lsp文件内容
;foo.lsp
(ext::stream-external-format-set *standard-input* :CP936)
(ext::stream-external-format-set *standard-output* :CP936)
(print (length "好吧"))
(print "TEST" *standard-output*)
(princ "好吧" *standard-output*)
(format t "~%汉字来也")
这个代码只能在文件中执行,如果在ecl console里逐行敲入这些代码,反而出现错误:
ECL (Embeddable Common-Lisp) 10.7.1
Copyright (C) 1984 Taiichi Yuasa and Masami Hagiya
Copyright (C) 1993 Giuseppe Attardi
Copyright (C) 2000 Juan J. Garcia-Ripoll
ECL is free software, and you are welcome to redistribute it
under certain conditions; see file 'Copyright' for details.
Type :h for Help.
Top level in: #<process TOP-LEVEL>.
> (ext::stream-external-format-set *standard-input* :CP936)
> (ext::stream-external-format-set *standard-output* :CP936)
> (format t "汉字来也")
鹤酪
NIL
> (format t "汉字来也")
鹤酪
NIL
>
星期四, 一月 06, 2011
LISP在package如何访问TOPLEVEL定义的全局变量(Global Variable)?
如果在一个main.lisp中分别(load "*....lisp"),载入定义的package或者一些全局的数据.
往往会出现如下场景类似的问题:
CL-USER> (defvar foo 108) FOO CL-USER> foo 108 CL-USER>
CL-USER> (in-package :asdf) #<PACKAGE "ASDF"> ASDF>
The variable FOO is unbound. [Condition of type UNBOUND-VARIABLE]
避免这个情况,就是用如下引用方式:
ASDF> cl-user::foo 108 ASDF>
星期三, 十二月 29, 2010
ECL 10.4.1 在window 用 mingw 3.4.5 编译
first download gc 7.2
http://www.hpl.hp.com/personal/Hans_Boehm/gc/gc_source/gc-7.2alpha4.tar.gz
展开。
然后进入msys
cd d:/gc-7.2alpha4
敲入命令:
1.首先配置
./configure --enable-shared=no --enable-static=yes --enable-cplusplus --enable-large-config --enable-parallel-mark --enable-threads=win32;make
2.开始编译
make
3.安装到/usr/local目录下,实际的msys local目录下
success then.
cd d:/ecl-10.4.1
//./configure --prefix=/usr/local --enable-boehm=system --enable-longdouble --enable-gengc --enable-precisegc --enable-threads --enable-unicode CPPFLAGS=-ID:\\gc-7.2alpha4\\include LDFLAGS=-LD:\\gc-7.2alpha4\\.libsmake clean;./configure --prefix=/usr/local --enable-threads -enable-boehm --enable-unicode ;make
MSVC:
nmake ECL_UNICODE=1 ECL_DEBUG=0
#include <ecl/ecl.h>
# include <unistd.h>
# include <pthread.h>
int main(int argc, char **argv) {
cl_boot(argc, argv);
cl_object obj=c_string_to_object("\"Hello world\"");
cl_pprint(1,obj);
cl_shutdown();
}
(ext::stream-external-format-set *standard-input* :utf-8)
(ext::stream-external-format-set *standard-output* :utf-8)
--build=pentium4-pc-mingw32如何使用ecl.dll
使用
ecl-config --cflags 及 ecl-config --ldflags 得到你需要传递给你的编译器的变量
发布使用ecl.dll的程序。
必须包含ecl.dll 和ucd.dat 两个文件同执行文件在同一个目录下
ucd.dat
显示汉字:
cl_object obj=c_string_to_object("\"Hello world你好\"");
wxMessageBox(wxString(ecl_base_string_pointer_safe(obj),wxConvUTF8));
ECL生成独立的可执行文件.
1.新建hello.lisp文件,包含如下代码
(princ "Hello world!")
(terpri)
(quit)
2.生成object文件
(compile-file "hello.lisp" :system-p t)
3.link成可执行文件
(c:build-program "hello" :lisp-files '("hello.o"))
4../hello.exe
星期四, 十二月 23, 2010
如何用一个字符串作为Lisp Hashtable的key?
(setq table (make-hash-table)) => #<HASH-TABLE EQL 0/120 46142754>
(setf (gethash "one" table) 1) => 1
(gethash "one" table) => NIL, false
(setq table (make-hash-table :test 'equal)) => #<HASH-TABLE EQUAL 0/139 46145547>
(setf (gethash "one" table) 1) => 1
(gethash "one" table) => 1, T
(make-hash-table :rehash-size 1.5 :rehash-threshold 0.7)
Lisp 如何得到函数返回的多个值?
比如parse-integer 返回2个值。
如果想的到第二个返回值,可以用(nth-value (parse-integer "20") 1)
得到2,字符串索引。
还有其他函数可以得到所有返回值。
nth-value [already mentioned and only pertaining to multiple-vals]
multiple-value-bind [no such thing as multiple-value-let]
multiple-value-call
multiple-value-setq
(multiple-value-list (floor 5 2))
得到:(2 1)
星期一, 十二月 20, 2010
Lisp打开跟踪,输出到log文件
(dribble) ;关闭跟踪输出。
星期二, 十二月 14, 2010
健身一次负重的重量如何计算?(比如哑铃,杠铃)
Repetition Maximum
有两个公式可以计算得出1RM的重量:
Brzycki's 公式
- 重量÷ ( 1.0278 - ( 0.0278 × 重复次数 ) )
另外一个系数的公式
- 重量 × ( 1 + ( 0.033 × 重复次数 ) )
这样一个体重80公斤的人计划一组重复锻炼动作16次计算得出的1RM是:
Brzycki结果:137公斤
另外:122公斤
然后利用另外一张 负重和重复 关系表。
14 to 20RM = 60% of 1RM
11 to 14RM = 70% of 1RM
6 to 11RM = 80% of 1RM
3 to 6RM = 90% of 1RM
得到重复16次相当于60%的 1RM 及137 × 0.6 =82.2 公斤或122* 0.6 = 73.2 公斤
这样就得出每次重复需要举起的实际总量为:82.2/16=5.1375公斤 或73.2/16=4.575公斤
所以锻炼的次数越多,每次需要举起的重量越少。
如果你是哑铃锻炼的话,一个体重80KG的人需要准备一个单只 2.5KG的哑铃或杠铃来举重。
| % 重量 | 重复次数 | % 重量 | 重复次数 | % 重量 | 重复次数 |
| 60 | 17 | 75 | 10 | 90 | 5 |
| 65 | 14 | 80 | 8 | 95 | 3 |
| 70 | 12 | 85 | 6 | 100 | 1 |
实际锻炼中往往根据自己的目的来调整实际重复的次数或RM,这个同锻炼的目的有关系。
下面的表是肌肉锻炼目的和RM的关系,可以自己选择,然后确定实际的重量
1RM的到3RM - 最大刺激神经肌肉力量
4RM以6RM - 最大强度的刺激肌肉肥大
6RM到12RM - 肌肉(肥大)力量锻炼合适
12RM到20RM - 肌肉体积良好和获得良好的耐力
一个比较好的LISP IDE 工具 lispIDE
这个同居可以同SBCL Download - Steel Bank Common Lisp 配合一起使用
如图:
星期五, 十二月 10, 2010
动态扩展的数组
(defvar foo (make-array 1 :fill-pointer 0))
(vector-push-extend (vector 1 2 3) foo)
(vector-push-extend (vector 1 2 3) foo)
星期三, 十一月 24, 2010
如何遍历一个LIST 数组。
简单代码如下,构造一个List数组,然后遍历之。
(defvar alls)
(setf alls (vector '(10 12 14 20 22 26) '(03 05 06 07 11 12)))
(loop for i from 1 to (array-total-size alls)
do(loop for h from 1 to (list-length (svref alls (1- i)))
do(format t "~d," (nth (1- h) (svref alls (1- i))))
)
(format t "~%")
)