Ubuntu无法进入桌面报告 Could not update /home/$USER/.ICEauthority

使用Ubuntu和Fedora的用户经常会在进入GNOME时出现

这样的提示。然后就不能正常进入GNOME了(之前在GNOME上的配置都消失了)

解决办法:以root的用户执行

解决问题很简单,但为什么会出现这种情况呢?下面是我的一些个人理解

首先:先介绍下sudo和gksudo

sudo和gksudo都是使用root权限来执行应用,sudo执行程序时使用的是当前用户的配置和家目录,而gksudo使用的是root用户 的家目录和配置,一般情况下看不出什么区别,但是对于那些针对不同用户有不同的配置文件和表现形式的应用程序来说,这两种方式的结果区别就很明显了。比如 下面原文中举的firefox例子。在不通过终端运行程序时,sudo没有办法提供一个界面来输入管理员密码,比如在快捷方式中。还有些GUI程序只能用 gksudo。细心的朋友肯定发现了,在/root下并没有.ICEauthority。那么当用sudo运行程序之后,由于使用的是当前用户的配置和家 目录,

系统将整个家目录的所属者和所属组归属到root:root下,并将.ICEauthority的权限修改成600。故当再次以普通用户身份登入系统时,由于没有权限故无法读取用户的配置文件。根据上述分析,显然,当使用gksudo将能避免这种情况的发生。
一般情况下,可以这样,运行命令行程序时使用sudo,运行GUI程序时用gksudo。

下面是原文:

What’s the Issue?
Since most Ubuntu documentation asks you to use sudo even with graphical applications, I often get asked by Ubuntu users why I recommendgksudo or kdesu for graphical applications instead of sudo.

For example, a lot of guides (including the first book ever published about Ubuntu) will ask you to type this sort of command:

I will always recommend, however, that people use instead this sort of command:

And reserve sudo for command-line applications, like so:

Why is it an issue?
Well, to be perfectly honest, most of the time it isn’t. For a lot of applications, you can run them the improper way—using sudo for graphical applications and see no adverse side effects.

1. There are other times, though, when side effects can be as mild as Firefox extensions not sticking or as extreme as as not being able to log in any more because the permissions on your .ICEauthority changed. You can read a full discussion on the issue here.

These errors occur because sometimes when sudo launches an application, it launches with root privileges but uses the user’s configuration file.

5616035720110414233611022

For example, if you launch Firefox with the command

it uses root’s Firefox configuration file.
5616035720110414233935037
But if you launch Firefox with the command

Change a few settings while launched as root, and you'll see if you dig into your Firefox profile that certain files are now owned by root.

56160357201104142343300785616035720110414233611022 (1)

it runs with root privileges but uses the user’s configuration file (in this case, you can see the homepage and theme are different).
2. Running graphical applications with sudo also has the downside of always having to be run from the terminal. If you don’t use the proper command—gksudo or kdesu, you will not be able to use the command as an icon launcher or keyboard shortcut because there will be no graphical dialogue box to enter your sudo password in.

3. There are also some graphical applications that simply will not run with the sudo command. Kate, for example, can be run as

but cannot be run as

Why not make exceptions?
Bottom line: most of the time when you use sudo for graphical applications, it’s fine. Some of the time, though, it is not fine, and is, in fact, extremely bad.

If you made exceptions, you would have to give people a list of all the graphical applications that are okay to run as sudo and a list of all the graphical applications that must be run as gksudo or kdesu.

Why make a list that needs to be compiled and updated, that most people won’t refer to, and that is completely unnecessary? Just be consistent in suggesting good practice: gksudo and kdesu for graphical applications. sudo for command-line applications.

But gksudo sometimes gives me an error… even though it appears to work…

You may notice that even though gksudo is the proper way to launch graphical applications, if you launch a gksudo application it will sometimes give you what appears to be an error. This, for example:

or these

That is not a real error, and there’s already been a bug report filed on the message appearing. The developers have seen the bug and labeled it a low priority. In the meantime, just ignore the message and keep encouraging people to not use sudo for graphical applications so they won’t potentially mess up their ~/.ICEauthority and other user configuration files.

参考:http://czmmiao.iteye.com/blog/1003810

Linux下NDK:error trying to exec 'cc1': execvp: No such file or directory

android-ndk-r9c 下编译时候报告

修改

即可。

Ubuntu 中,有时候编译器安装的太多版本的情况下,如果只设置PATH 到 toolchains 目录,CC只写编译器名字,让系统根据PATH中的路径来自动寻找,有时候是无效的,此时需要直接指定CC的绝对路径就可以了。

参考链接

http://www.cnblogs.com/pengwang/archive/2013/03/06/2945720.html

arm-eabi-gcc: error trying to exec 'cc1': execvp: No such file or directory arm-eabi-gcc: error trying to exec 'cc1': execvp: No such file or directory

在使用ndk编译本地文件时出错,最后发现是交叉编译工具的权限问题,chmod +x 就可以了我的NDK版本是android-ndk-r5b,CC1在android-ndk-r5b/toolchains/arm- linux-androideabi-4.4.3/prebuilt/linux-x86/libexec/gcc/arm-linux- androideabi/4.4.3目录下面。

Eclipse check for update,出现“No repository found containing”错误

Eclipse 中点击更新可能会突然弹出一个类似“No repository found containing”的错误提示信息:

我们可以这样处理:
点击“Available Software Sites”(Work with下面),就会弹出一个配置站点信息列表,选中全部列表,再点击“Export”导出,保存为“bookmarks.xml”,回到配置站点信息列表,选中全部,点击“Remove”移除,然后又回到配置站点信息列表,点击“Import”把“bookmarks.xml”文件导入

20140126215312

Mac OS X 10.9 Android NDK r9c 编译 FFTW 3.3.3

在Mac OS X 10.9 上使用 NDK  r9c 编译 FFTW 3.3.3

1.下载FFTW源代码

2.建立一个Android 工程,并且添加 NDK 支持

3.解压缩FFTW的源代码到刚刚建立的Android 目录下面 文件夹名字为 fftw-3.3.3

4.建立编译脚本 build.sh 并在命令行下执行

  • INSTALL_DIR tells make to install the compiled library in our project's jni directory
  • PATH tells make to look for our tool chain in the NDK directory. Note that you might have to change this value - explore your NDK directory to make sure that the path exists
  • SYS_ROOT tells make where to look for system libraries and header files
  • ./configure --host=arm-eabi  tells make that we are cross-compiling a ARM architecture.

5.修改Android.mk 文件

Ubuntu apt-get upgrade 时候忽略某些安装包

最近使用Squid3 做代理服务器,但是Ubuntu 默认的Squid3 是不包含HTTPS支持功能的,因此只能自己重新编译(参见 Ubuntu 12.04 上使用 squid 架设Http正向代理服务器),但是,在执行

的时候遇到一个问题,那就是 Squid3 总是被默认还原成原来的包,每次程序升级完成之后都要重新编译设置 ,非常麻烦,网上查找了一下,找到可以忽略某些特定包升级的命令。

这样就不担心在升级时候误升级 Squid3 了。

如果需要恢复原来的设定的话,执行如下命令即可

华为Android手机在MAC系统下ADB识别

使用MACOS发现在Android开发环境完整的情况下,接入小米,SAMSUNG,HTC,ZTE等手机都可以自动识别,如果暂时不能识别,只需要在 adb_usb.ini 中设置之后也可以识别,并可以在DDMS中查看LOGCAT,唯独华为的手机不可识别。USB开发调试也设置了,但是在Windows下却可以识别,为什么呢?别急,有工程模式:

在拨号界面输入:

找到->"ProjectMenu"->“后台设置”->“USB端口设置” 改成 "GOOGLE模式"

注意,此时手机提示要重启,但是不要重启。重启之后会还原为正常模式的。

如果还是不能识别,则切换成其他模式,反复切换一下,最后设置成"GOOGLE模式" ,或者重新插拔一下数据线,就可以识别到了。

Struts2 中读取静态资源文件

If it is placed in the webapp's classpath, then just use:

If it is placed in the global classpath, then use:

If it is placed in the webcontent, then just use:

The examples assumes that they're placed in the root. You can of course use relative path as opposed to the classpath root or webcontent root, e.g. path/to/file.txt. You can get the ServletContextin Struts by ServletActionContext#getServletContext().

Eclipse Kepler Tomcat 7 调试时候 Server Tomcat v7.0 Server at localhost failed to start

Eclipse 调试 Tomcat7 下的项目,中间手工删除了某些文件,然后继续调试就报告如下错误

删除Server,重建之后,问题依旧,重启机器,问题仍然不能解决。看来是在Eclipse 的配置文件中记录了之前的文件,而这些文件又已经被我手工删除过了,导致删除失败 。因此,只要删除这些记录文件就可以了。

删除如下文件

重启 eclipse 重建Server,一切正常。

Tomcat7 JSP Ajax 提交中文乱码

在JS文件中存在中文,在调用 Ajax 提交数据的时候,中文总是乱码,在调用 JS的时候也已经指定了JS的编码为

但是仍然不奏效。最后打开Tomcat的server.xml文件发现默认的配置是这样的

因为要一切都统一为UTF-8所以修改为

问题就解决了。

Android性能测试工具 Emmagee

Emmagee是监控指定被测应用在使用过程中占用机器的CPU、内存、流量资源的性能测试小工具。

支持SDK:Android2.2以及以上版本

Emmagee功能介绍

1、检测当前时间被测应用占用的CPU使用率以及总体CPU使用量

2、检测当前时间被测应用占用的内存量,以及占用的总体内存百分比,剩余内存量

3、检测应用从启动开始到当前时间消耗的流量数

4、测试数据写入到CSV文件中,同时存储在手机中

5、可以选择开启浮窗功能,浮窗中实时显示被测应用占用性能数据信息

6、在浮窗中可以快速启动或者关闭手机的wifi网络

Emmagee如何使用

1、安装Emmagee应用

apk下载地址:http://code.google.com/p/emmagee/downloads/list

2、启动Emmagee,列表中会默认加载手机安装的所有应用

3、选择你需要测试的应用,点击“开始测试”,被测应用会被启动

224554_FHBY_1041545

4、开始你的功能测试吧,测试过程中会自动记录相关性能参数

5、测试完成后回到Emmagee界面,点击“结束测试”,测试结果会保存在手机指定目录的CSV文件中

生成的CSV文件内容见图:
224609_54so_1041545

6、使用Excel打开CSV文件,使用自带的统计图标功能生成统计图:

224618_Ptgl_1041545