Redmine Linux下 PDF 和 PNG 中文问题

Written by 某L. Posted in Rails

Redmine使用了RMagick来处理图片,fpdf处理PDF,并在调用时设定了字体

PDF中文字体

Redmine 中关于PDF字体设置的代码

          case pdf_encoding
          when 'UTF-8'   
            @font_for_content = 'FreeSans'  
            @font_for_footer  = 'FreeSans'  
          when 'CP949'   
            extend(PDF_Korean)              
            AddUHCFont() 
            @font_for_content = 'UHC'       
            @font_for_footer  = 'UHC'       
          when 'CP932', 'SJIS', 'SHIFT_JIS'
            extend(PDF_Japanese)            
            AddSJISFont()
            @font_for_content = 'SJIS'      
            @font_for_footer  = 'SJIS'      
          when 'GB18030' 
            extend(PDF_Chinese)             
            AddGBFont()  
            @font_for_content = 'GB'        
            @font_for_footer  = 'GB'        
          when 'BIG5'    
            extend(PDF_Chinese)             
            AddBig5Font()
            @font_for_content = 'Big5'      
            @font_for_footer  = 'Big5'      
          else
            @font_for_content = 'Arial'     
            @font_for_footer  = 'Helvetica' 
          end

在中文时,Redmine 使用了GB字体,在debian or Ubuntu系统中,可使用APT安装

apt-get install ttf-arphic-bkai00mp ttf-arphic-bsmi00lp ttf-arphic-gbsn00lp ttf-arphic-gbsn00lp

参考 Chinese Debian Mini Howto

图片中文问题(PNG)

图片中文也是类似的原理,下面是Redmine config/configuration.yml 中的内容

# This setting is not necessary in non CJK.                                                                                            
#
# Examples for Japanese: 
#   Windows:             
#     rmagick_font_path: C:\windows\fonts\msgothic.ttc                                                                                 
#   Linux:               
#     rmagick_font_path: /usr/share/fonts/ipa-mincho/ipam.ttf                                                                          
#
rmagick_font_path:  

修改这段代码,设定适当的中文字体路径即可,如:

rmagick_font_path: /usr/share/fonts/truetype/arphic/gbsn00lp.ttf

重新启动服务器,现在中文导出应当正常了。

本文使用的Redmine版本为 2.2.3

Xtext – eclipse DSL 编辑器

Written by 某L. Posted in Blogs

011513_2320_Xtexteclips6.png

如果只说是一个DSL(Domain Specific Language)编辑器,感觉是有点委屈它了,这基本上是个语言设计器。

包含了解析,链接,编译,解释等全套的语言工具,除此之外,还有如下特色功能:

  1. 语法高亮
  2. 上下文辅助
  3. 校验及快速更正建议
  4. 整合Java

N图胜千言

Familiar 朋友们的照片墙

Written by 某L. Posted in Blogs

unnamed

聚会想发照片?传到微博上?

不但很快就被别的微博刷没了,照片这种东西,还需要一点点隐私控制。

Familiar,对于国内用户来讲,套用妹纸的话,就是照片版的朋友圈。

配有iOS, Andorid, PC, Mac等全系列版本,对平板的支持也很好。

当然作为这个时代的应用,社交网络是不能少的,虽然必然主要是F和T两家……

各种屏保动画很完整,还可以互相评论,有兴趣就来尝试吧。

unnamed6a015436ecdafc970c017744518c8b970d-500wi

 

Hadoop Family Related Project

Written by 某L. Posted in Blogs

全文摘选自 Alex Holmes 《Hadoop in Practice》,关于 Flume, Sqoop, Oozie, Hive, HBase, Avro, Thrift, Pig, R, Mahout 等流行组件的概括描述。

A.2. Flume

Flume is a log collection and distribution system that can transport log files across a large number of hosts into HDFS. It’s an Apache project in incubator status, originally developed and currently maintained and supported by Cloudera.

A.3. Oozie

Oozie is an Apache project which started life inside Yahoo. It’s a Hadoop workflow engine that manages data processing activities.

A.4. Sqoop

Sqoop is a tool for importing data from relational databases into Hadoop, and vice versa. It can support any JDBC-compliant database, and also has native 

connectorsfor efficient data transport to and from mySQL and PostgreSQL.

A.5. HBase

HBase is a real-time key/value distributed column-based database modeled after Google’s BigTable.

A.6. Avro

Avro is a data serialization system that provides features such as compression, schema evolution, and code generation. It can be viewed as a more sophisticated version of a SequenceFile, with additional features such as schema evolution.

A.7. Protocol Buffers

Protocol Buffers is Google’s data serialization and Remote Procedure Call (RPC) library, which is used extensively at Google. In this book we’ll use it in conjunction with Elephant Bird and Rhipe. Elephant Bird requires version 2.3.0 of Protocol Buffers (and won’t work with any other version), and Rhipe only works with Protocol Buffers version 2.4.0 and newer.

A.8. Apache Thrift

Apache Thrift is essentially Facebook’s version of Protocol Buffers. It offers very similar data serialization and RPC capabilities. We’ll use it with Elephant Bird to support Thrift in MapReduce. Elephant Bird only works with Thrift version 0.5.

A.9. Snappy

Snappy is a native compression codec developed by Google, which offers fast compression and decompression times. It can’t be split (as opposed to LZOP compression). In the book code examples where we don’t need splittable compression, we’ll use Snappy because of its time efficiency. In this section we’ll cover how to build and set up your cluster to work with Snappy.

A.10. LZOP

LZOP is a compression codec that can be used to support splittable compression in MapReduce. Chapter 5 has a section dedicated to working with LZOP. In this section we’ll cover how to build and set up your cluster to work with LZOP.

A.11. Elephant Bird

Elephant Bird is a project that provides utilities for working with LZOP-compressed data. It also provides a container format that supports working with Protocol Buffers and Thrift in MapReduce.

A.12. Hoop

Hoop is an HTTP/S server which provides access to all the HDFS operations.

A.14. Hive

Apache Hive is a data warehouse project that provides a simplified and SQL-like abstraction on top of Hadoop.

A.15. Pig

Apache Pig is a MapReduce pipeline project that provides a simplified abstraction on top of Hadoop.

A.16. Crunch

Crunch is a pure Java library that lets you write code that’s executed in MapReduce without having to actually use MapReduce specific constructs.

A.17. R

R is an open source tool for statistical programming and graphics.

A.18. RHIPE

RHIPE is a library that improves the integration between R and Hadoop.

A.19. RHadoop

RHadoop is an open source tool developed by Revolution Analytics for integrating R with MapReduce.

A.20. Mahout

Mahout is a predictive analytics project that offers in-JVM as well as MapReduce implementations for some of its algorithms.

hadoop 1.0.4 + sqoop 1.4.2 ubuntu 安装笔记

Written by 某L. Posted in Blogs

这是一个流水帐,完成安装后,hadoop可以运行在single node模式,可以进行开发。

安装hadoop

下载并安装hadoop deb包

 wget -i http://labs.mop.com/apache-mirror/hadoop/common/hadoop-1.0.4/hadoop_1.0.4-1_i386.deb
 sudo dpkg -i hadoop_1.0.4-1_i386.deb

编辑hadoop环境变量,设置JAVA_HOME

 sudo vim /etc/hadoop/*env*

测试安装

 hadoop dfs -ls

如果能正确输出,则安装正常

安装sqoop 1.4.2

sqoop 1.4.2 和 1.99也就是2.0 有极大差异,下载要注意

下载适合hadoop的版本包

wget -i http://www.apache.org/dist/sqoop/1.4.2/sqoop-1.4.2.bin__hadoop-1.0.0.tar.gz

解压

tar xvf sqoop-1.4.2.bin__hadoop-1.0.0.tar.gz

设置运行用户的环境变量,编辑~/.bashrc , 在最后加入

export HADOOP_HOME=/usr/bin/hadoop
PATH="{path/to/sqoop}/bin:$PATH"  # 注意这里改成真实地址

source ~/.profile 后测试运行

sqoop version

补充:如果要连接mysql,请下载相应驱动的.jar放到sqoop目录的lib中.

蓝牙鼠标总丢失?亲,那是你不会用

Written by 某L. Posted in Blogs

111212_0517_3.png

前两天入手了一个罗技V470,看评论说不支持Win7,心想这不科学。果然又搜了一下,说更新驱动可解决,于是信心十足的买了。

买了没两天,发现这东西总是莫名其妙的失去响应了,不胜其烦。

症状说明,解释原因:Win7设备的电源管理,总是把蓝牙接收器自动关闭了。

解决办法,在设备管理器里面设置一下蓝牙接收器的电源管理即可。

参考下图,打开控制面板-硬件和声音:

点击设备管理器,找到你的蓝牙接收器之类的

查看属性,电源管理,去掉”允许计算机关闭此设备以节约电源”

确认,完成!

不得不说,这就是为什么蓝牙流行不起来的原因啊:看起来简单,用起来麻烦,没有规模,又很贵。

Shell, RVM, .bashrc, .bash_profile

Written by 某L. Posted in Blogs

这两天在应用RVM project .rvmrc 时发现,一个问题——终端的颜色显示没有了。

ubuntu下颜色显示是定义在 ~/.bashrc 中的,文件没有改过,为啥就不正常了呢?

研究了一下终端下几个配置文件的含义:

/etc/profile:此文件为系统的每个用户设置环境信息,当用户第一次登录时,该文件被执行.
并从/etc/profile.d目录的配置文件中搜集shell的设置.
/etc/bashrc:为每一个运行bash shell的用户执行此文件.当bash shell被打开时,该文件被读取.
~/.bash_profile:每个用户都可使用该文件输入专用于自己使用的shell信息,当用户登录时,该
文件仅仅执行一次!默认情况下,他设置一些环境变量,执行用户的.bashrc文件.
~/.bashrc:该文件包含专用于你的bash shell的bash信息,当登录时以及每次打开新的shell时,该
该文件被读取.
~/.bash_logout:当每次退出系统(退出bash shell)时,执行该文件.

另外,/etc/profile中设定的变量(全局)的可以作用于任何用户,而~/.bashrc等中设定的变量(局部)只能继承/etc/profile中的变量,他们是”父子”关系.

~/.bash_profile 是交互式、login 方式进入 bash 运行的
~/.bashrc 是交互式 non-login 方式进入 bash 运行的
通常二者设置大致相同,所以通常前者会调用后者。

发现原因了,因为rvm的命令是写在.bash_profile里的,为了让其生效,按照官方文档修改了终端的设置

以登录Shell方式运行终端

这样一来 .bashrc就被忽略了。

解决的办法就是,在 .bashrc最后中加入来.bash_profile的命令

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"

并且取消选中以登录Shell方式运行终端,以执行.bashrc文件。

ls ll 等命令都回来了,project .rvmrc也完美执行了