Nov 13, 2014

解决eclipse4.3.1 ctrl click不工作的问题

升级eclipse到Kepler(4.3.1)之后,发现ctrl+click函数声明追踪不好使了,股沟了一下,原来是dltk的数据库版本不向下兼容:

!ENTRY org.eclipse.dltk.core.index.sql 4 0 2013-10-14 16:45:28.670
!MESSAGE An exception has thrown while performing a search
!STACK 0
org.h2.jdbc.JdbcSQLException: 
Unsupported database file version or invalid file header in file "Old database: 
/home//workspace/.metadata/.plugins/org.eclipse.dltk.core.index.sql.h2/model.data.db 
- 
please convert the database to a SQL script and re-create it." [90048-168]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:329)

解决办法:

关闭eclipse,把workspace/.metadata/.plugins/org.eclipse.dltk.core.index.sql.h2/目录下的文件全部删除,再打开eclipse,它会自动重建声明索引数据库。

PS,期间遇到“workspace in use or cannot be created”的问题,到workspace/.metadat/目录下,删除.lock文件,轻松解决。

Sep 28, 2014

解决ubuntu 14.04下安装phpmyadmin失败

Problem:

Try to re-install phpmyadmin on ubuntu 14.04, got error:

  dpkg: error processing package phpmyadmin (--configure):
 子进程 已安装 post-installation 脚本 返回了错误号 1
在处理时有错误发生:
 phpmyadmin
E: Sub-process /usr/bin/dpkg returned an error code (1)

Root cause:

"该错误通常发生在以下情况,使用 dpkg -i安装deb包后,直接删除了程 序所有相关的目录和文件,但是 dpkg库中仍然保留了该程序的相关 信息。 因此,当执行apt命令时,dpkg自检 时便会发现相关文件丢失,于是报 出标题中的错误。"

Solution:

解决方法如下:

#检查当前 dpkg库中残留的文件安装信息
dpkg -l | grep phpmyadmin

 #手 动删除所有包,这一步可能仍然会 有相关错误信息报出
sudo dpkg -r phpmyadmin

#这一 步很重要,彻底清除任何****包相 关的信息
sudo dpkg -P phpmyadmin

dpkg -l | grep phpmyadmin

应该就没 有任何错误信息了,再执行其它安 装程序,也不会报错了。

now run:

sudo apt-get install phpmyadmin

success!

参考链接:

http://tiankonguse.com/record/record.php?id=272

Aug 7, 2014

How to set default env to develop for symfony project

After you created a symfony project, including frontend app, when visit the local site url of the project, you would do want it showing the symfony debug toolbar by default.

This means you don't need to append frontend_dev.php to visit the develop env.

Following tricks on site definition do help on this:

1. Edit your apache virtual host definition for the project website, add this line:

SetEnvIf Request_URI ".*" PROJECT_ENV=dev

So your virtual host configuration will look like:

<VirtualHost localhost:80>
  ServerName yoursite.localhost
  ServerAlias *.yoursite.localhost *.yoursite.local-site
  DocumentRoot "__your_symfony_project_doc_root__"
  DirectoryIndex index.php

  # Set the project environment mode: dev, prod
  # Note: This is a bit of hack because SetEnv won't let var values show up in rewrite conditions.
  SetEnvIf Request_URI ".*" PROJECT_ENV=dev

  <Directory "__your_symfony_project_doc_root__">
   AllowOverride All
   Allow from All
  </Directory>
  Alias /sf "__your_symfony_project_path__/lib/vendor/symfony/data/web/sf"
  <Directory "__your_symfony_project_path__/lib/vendor/symfony/data/web/sf">
   AllowOverride All
   Allow from All
  </Directory>
</VirtualHost>

2. Edit your project website .htaccess file as below, attention to bold lines:

# For security reasons, Option followsymlinks cannot be overridden.
#Options +FollowSymLinks +ExecCGI
Options +SymLinksIfOwnerMatch +ExecCGI

<IfModule mod_rewrite.c>
  RewriteEngine On

 # For testing setting the project env, uncomment next line.
#  SetEnvIf Request_URI ".*" PROJECT_ENV=prod


  SetEnvIf Host prod\..* PROJECT_ENV=prod

  # uncomment the following line, if you are having trouble
  # getting no_script_name to work
  #RewriteBase /

  # we skip all files with .something
  #RewriteCond %{REQUEST_URI} \..+$
  #RewriteCond %{REQUEST_URI} !\.html$
  #RewriteRule .* - [L]

  # we check if the .html version is here (caching)
  RewriteRule ^$ index.html [QSA]
  RewriteRule ^([^.]+)$ $1.html [QSA]
  RewriteCond %{REQUEST_FILENAME} !-f

  # no, so we redirect to our front web controller

  # Below we define conditional rules that will go controller based on env
  # The default will be dev.

  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{ENV:PROJECT_ENV} =prod [NC]
  RewriteRule ^(.*)$ index.php [QSA,L]

  #RewriteCond %{ENV:PROJECT_ENV} =dev [NC]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^(.*)$ frontend_dev.php [QSA,L]
</IfModule>

3. Restart apache service, enjoy your developing!

May 22, 2014

Ubuntu下解决Chrome升级后界面中文乱码问题

Ubuntu版本:12.04 LTS

昨天Chrome升级到35后,包括书签,Tab,地址框,以及右键菜单中的中文都变成乱码。

尝试用用以下方法解决:

sudo ln -s ../conf.avail/69-language-selector-zh-cn.conf /etc/fonts/conf.d/69-language-selector-zh-cn.conf

不起作用,查看了该文件的内容,与参考链接给的模板文件不太一样。

删除链接文件,下载编辑模板文件,重命名为69-language-selector-zh-cn.conf,拷贝覆盖原文件。

重启Chrome,依然不起作用。

注销重新登录,无变化,晕啊。

今天早上又股沟了一下,原来需要把系统的字体改一下:

Settings Manager > Appearance > Fonts > Default Font

改成 WenQuanYi Micro Hei

重启Chrome,问题解决, 耶!哈哈哈。

其实把系统的语言支持设置为中文(排到第一位),也能解决此问题,但系统整个变成中文化环境,不适合工作需要。


参考链接:
https://code.google.com/p/chromium/issues/detail?id=335651

May 19, 2014

Upgrade to Ubuntu 14.04 failed on my 2012 late iMac

I should not click 'Yes' while it prompted 'A new version found, do you want to upgrade.'

The whole upgrade process seemed ok, only except some compile errors about out of memory with fontconf....

But at the end of upgrade, it reported the upgrade failed, and it could not roll back to the old 13.04.

I reboot the machine into ubuntu anyway, it brought up everything, and seems a new version already installed, only that the desktop resolution abit low.

But i wouldn't bother myself to figure that out, since I don't know what other potential issues there. Don't want to take any risk and put myself into a even worse situation.

So, after googling a little, I decided to give it a fresh installation with 14.04, for sake of it's a LTS version.

And shame that couldn't find image for mac on ubuntu official download site, finally found it from a forum:

http://cdimage.ubuntu.com/releases/trusty/release/ubuntu-14.04-desktop-amd64+mac.iso
(MD5: 0bc7243aacd5f80f8110dcf3165dffd0)

Downloading now, and hope no other issues with the installation upcoming...

May 12, 2014

Linux bash history with Page up / Page down

n linux you can configure the pgup/pgdown keys to navigate through commands you typed that begin with the string you just typed. Type "mysql" and then hit "Page up", and you will see nothing but mysql-related commands.
Unfortunately this has to be configured anew on every machine or server/vm I work on, and I always forget where this is configured (and it takes a while to find it in google), so I thought I should write it down.
------------
In /etc/inputrc, uncomment:
# alternate mappings for "page up" and "page down" to search the history
"\e[5~": history-search-backward
"\e[6~": history-search-forward
Restart your shell or use Ctrl+X, Ctrl+R to tell it to re-read.
(thanks stackoverflow)
Yep, it's not ".bashrc" but "inputrc".
Not sure why this one is not hidden, but so it is.
You could try ~/.inputrc for a local, user-specific configuration.
Tried this in Ubuntu, and it works.

Add alias and color to git

edit your git config  /home/%youraccount%/.gitconfig as following

[alias]
   st = status
   ci = commit
   br = branch
   co = checkout
   df = diff
   lg = log -p
   lol = log --graph --decorate --pretty=oneline --abbrev-commit
   lola = log --graph --decorate --pretty=oneline --abbrev-commit --all
   ls = ls-files
   meld = !/usr/local/bin/git-meld.pl
[merge]
   tool = meld
[mergetool]
   keepBackup = false
[merge "ours"]
   driver = true
[mct "review"]
   command = git meld
[color]
   ui = true
[color "diff"]
   whitespace = red reverse
[core]
   whitespace=fix,-indent-with-non-tab,trailing-space,cr-at-eol
[color]
   ui = auto
[color "branch"]
   current = yellow reverse
   local = yellow
   remote = green
[color "diff"]
   meta = yellow bold
   frag = magenta bold
   old = red bold
   new = green bold
[color "status"]
   added = yellow
   changed = green
   untracked = cyan
[user]
   name = Fan Deng
   email = leondeng@gmail.com
[diff]
   tool = meld

May 2, 2014

Screen brightness setting with Xfce on iMac, iMac Xfce 屏幕亮度调节

1. 键盘亮度调节支持
默认安装xfce后没有安装(xfce4-power-manager-plugins)的插件,在ububtu下面 apt-get install xfce4-power-manager-plugins安装后启动一下power manager工具即可通过键盘调节亮度

2. 屏幕亮度记忆
屏幕亮度不能保存,每次开机都回恢复到最亮的状态。
请教了Google后,在一个外文博客上发现了解决的方法。
首先要写一个调节屏幕亮度的脚本,只有一句:
echo 3 > /sys/class/backlight/acpi_video0/brightness
里面的“3”可以替换为1-10中任意数字,越大越亮。
把这个脚本保存起来,比如保存为~/brightness
把这个脚本移动到/usr/local/sbin/brightness,并增加运行的权限
chmod +x /usr/local/sbin/brightrness
接着,配置允许不输入密码就sudo运行这个脚本,运行visudo,增加下面这行:
# User privilege specification
syndim        ALL=NOPASSWD: /usr/local/sbin/brightness
将上面的syndim替换为用户名。
最后,打开Applications  > Xfce Settings  > Session and startup,将
sudo /usr/local/sbin/brightness
添加进去,重新启动,enjoy~
参考链接: