Excel VBA for Google Translation

January 10, 2011

Public Function translate(textToBeTranslated As String, resultLanguageCode As String, Optional sourceLanguageCode As String = “”) As String

‘Translates given text with Google Translate
‘Supported languages can be found here: http://code.google.com/intl/fi-FI/apis/ajaxlanguage/documentation/#SupportedLanguages
‘If source language is omitted, Google Translate tries to detect it automatically

‘Function created by Mikael Thuneberg. Code for non-ASCII character encoding picked from a procedure by alexspi (http://www.experts-exchange.com/M_4420197.html)

    Dim objhttp As Object
    Dim URL As String

    Dim i As Integer
    Dim iAsc As Long
    Dim sAsc As String
    Dim sTemp As String

    Dim objStream As Object
    Dim data() As Byte
    Dim ByteArrayToEncode() As Byte

    Set objStream = CreateObject(“ADODB.Stream”)
    objStream.Charset = “utf-8″
    objStream.Mode = 3
    objStream.Type = 2
    objStream.Open
    objStream.WriteText textToBeTranslated
    objStream.Flush
    objStream.Position = 0
    objStream.Type = 1
    objStream.Read 3
    data = objStream.Read()
    objStream.Close
    ByteArrayToEncode = data

    textToBeTranslated = “”

    For i = 0 To UBound(ByteArrayToEncode)
        iAsc = ByteArrayToEncode(i)
        Select Case iAsc
            Case 32    ‘space
                sTemp = “+”
            Case 48 To 57, 65 To 90, 97 To 122
                sTemp = Chr(ByteArrayToEncode(i))
            Case Else
                Debug.Print iAsc
                sTemp = “%” & Hex(iAsc)
        End Select
        textToBeTranslated = textToBeTranslated & sTemp
    Next

    Set objhttp = CreateObject(“MSXML2.ServerXMLHTTP”)
    URL = “http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q=” & textToBeTranslated & “&langpair=” & sourceLanguageCode & “%7C” & resultLanguageCode
    objhttp.Open “GET”, URL, False
    objhttp.setTimeouts 1000000, 1000000, 1000000, 1000000
    objhttp.send (“”)

    translate = objhttp.responseText
    translate = Right(translate, Len(translate) – InStr(1, translate, “translatedText”) – 16)
    translate = Left(Left(translate, InStr(1, translate, Chr(34)) – 1), 255)
    translate = Replace(translate, “quot;”, Chr(39))
    If translate = ” null, ” Then translate = “Language not found”

End Function

ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ (2)

April 15, 2010

1. Mysql has the error:
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ (2)

$sudo /etc/init.d/mysqld status
mysql dead subsys locked

Solution:

sudo yum list mysql

find that there are two version of mysqlinstalled
mysql.i386 official package
mysql.x86_64 remi unofficial package

then I delete the official package(which is new installed)
sudo yum erase mysql.i386

chkconfig add mysqld service
* chkconfig –add mysqld
* chkconfig –level 345 mysqld on

3. sudo yum update –enablerepo remi reinstall mysql-server

4. sudo /etc/init.d/mysqld start

then the problem has been solved.

brucelee

using Chkconfig configure drupal mysql

April 15, 2010

1.安装Apahce, PHP, Mysql,以及php连接mysql库组件。

yum -y install httpd php mysql mysql-server php-mysql

2.配置开机启动服务

/sbin/chkconfig httpd on [设置apache服务器httpd服务开机启动]
/sbin/chkconfig –add mysqld [在服务清单中添加mysql服务]
/sbin/chkconfig mysqld on [设置mysql服务开机启动]

/sbin/service httpd start [启动httpd服务,与开机启动无关]
/sbin/service mysqld start [启动mysql服务,与开机无关]

3.设置mysql数据库root帐号密码。

mysqladmin -u root password ‘newpassword’ [引号内填密码]

4.让mysql数据库更安全

mysql -u root -p

mysql> DROP DATABASE test; [删除test数据库]
mysql> DELETE FROM mysql.user WHERE user = ”; [删除匿名帐户]
mysql> FLUSH PRIVILEGES; [重载权限]

5.按照以上的安装方式,配置出来的默认站点目录为/var/www/html/
新建一个php脚本:

<?php
phpinfo();
?>

6.新建一个数据库﹐添加一个数据库用户﹐设置用户权限。写个php脚本测试一下数据库连接吧。

mysql> CREATE DATABASE my_db;
mysql> GRANT ALL PRIVILEGES ON my_db.* TO ‘user’@'localhost’
IDENTIFIED BY ‘password’;

//安装apache扩展
yum -y install httpd-manual mod_ssl mod_perl mod_auth_mysql
//安装php的扩展
yum install php-gd
yum -y install php-gd php-xml php-mbstring php-ldap php-pear php-xmlrpc
//安装mysql扩展
yum -y install mysql-connector-odbc mysql-devel libdbi-dbd-mysql

backup in Mac timemachine to a remote machine by SMB

April 11, 2010

REQUIREMENTS
Obviously you need to be running Leopard and you’ll need a network share which is larger or equal to your hard drive in your Mac. In my case these shares are in SMB and AFP.

1. Go into Applications / Utilities and open up terminal
2. Copy and paste this command into terminal (all on one line)

defaults write com.apple.systempreferences TMShowUnsupportedNetworkVolumes 1

3. Hit enter / return
4. Mount your network share, in my case my share is off our server called INAS1 and my share is called User-Backups
5. Go to System Preferences and open Time Machine

下载论文方法

April 9, 2010

Using google scholar to search papers, although I have used VPN to connect the university, but sometimes, I cannot download the pdf version paper.

Solution:
go to university library Neilli portal and input the DOI(Digital Object Indicator) which is found from Google Scholar.

写论文的方法

March 15, 2010

1. 先写大纲,就是目录表
2. 先写最核心的部分,就是key finding, discussion,最后写abstract, title
3. 可以用Windows office live, google docs来协作,用JIRA等来控制issue,subversion来控制版本。
4. 采用XP极限编程的原则,就是两个人同一台电脑写,讨论。
5. 采用SCRUM,Iterative improvement方法
6. 用Nvivo, Endnote, atlas.ti, Zotero管理文献
7. 用Mindmanager,Freemind管理思路

 

How to uninstall a word plugin

February 9, 2010

Manually Installing the Zotero Word Plugin for Windows

To install the plugin by hand, first download the plugin template file for your Zotero version:

Zotero 1.0

Once downloaded, open the ZIP file and move the Zotero.dot file into the Word Startup folder.

Zotero 2.0

Once the plugin (distributed as a Firefox extension) is installed into Firefox, you can find a copy of the Zotero.dot file in the extensions/zoteroWinWordIntegration@zotero.org/install directory within your Firefox profile. Be sure to copy (rather than move) the file to the Word Startup folder.

Locating your Word Startup folder

The correct folder can be found in the Options window of Word:

Word 2003: open the Tools menu and click Options. Under the ‘File Locations’ tab you will find the Startup directory.

Word 2007: click the Microsoft Office Button, and then click Word Options. Click Advanced. Under General, click File Locations. The Startup folder should be listed there.

The default startup folders of Word are:

Word 2000, 2002 (XP), 2003, 2007 under Windows 2000 or XP

  • C:\Documents and Settings\::username::\Application Data\Microsoft\Word\Startup (::username:: is the user name of the currently logged-in user)

Word 2000, 2002 (XP), 2003, 2007 under Windows Vista

  • C:\Users\::username::\AppData\Roaming\Microsoft\Word\Startup (::username:: is the user name of the currently logged-in user)

Once you have moved the Zotero.dot file into the Startup folder, start (or restart) Microsoft Word to begin using the plugin. Note that after you’ve installed the .dot file, you can delete the downloaded ZIP file.

In many cases you will need to change your macro security settings to use the plugin. These are generally found under the tools drop-down menu in Word. Change your macro security settings to allow macros in the document. Then save the document, close it and reopen it. When you reopen your document you should be able to use the plugin.

 
windows_word_plugin_manual_installation_instructions.txt · Last modified: 2009/09/16 05:17 by dstillman

 

Driven by DokuWiki <!– –>

SaS9.13破解方法

February 4, 2010


送一个9.1.3的sid和永久破解sashost,作为对本论坛和版主的感谢

1楼

njukjzl 发表于:2007-4-17 13:00:22

由于文件太大,不好上传,我把方法列示如下:

第一步:复制下列文件为文本文件进行安 装,注意调整时间,我是调到了2004年1月,不知道其他的调整会不会有影响,然后选择安装的时候选择英文版,中文版大家有兴趣可以试,我没有试验。

[_SID_]
Version=9.1
Revision=9.1.3
Platform=WINDOWS
Platform_long=Microsoft Windows Professional, Microsoft Windows Server, and Microsoft Windows Datacenter Server
Order=980173
SID_schema=2
SID_header=SAS 9.1.3 SAS AppDev Studio, SAS AppDev Studio
x64=0
[_Info_]
[_FileData_]
$_Filename=indexfile.txt
$_Path=.\\
$_Date=
$_Time=
$_Stream=——————– BEGIN ——————–
indexfile.txt
sas91_980173.txt

$_Stream=——————— END ———————
$_Filename=tletter.txt
$_Path=.\\
$_Date=
$_Time=
$_Stream=——————– BEGIN ——————–
Microsoft Windows Professional, Microsoft Windows Server, and Microsoft Windows Datacenter Server
Academic Analysis Suite May 29, 2006
Base SAS Software May 29, 2006
SAS AppDev Studio 
SAS/ACCESS Interface to ODBC Software 
SAS/ACCESS Interface to OLE DB Software 
SAS/ACCESS Interface to PC Files Software 
SAS/CONNECT Software 
SAS/ETS Software 
SAS/FSP Software 
SAS/GRAPH Software 
SAS/IML Software 
SAS/INSIGHT Software 
SAS/SHARE Software 
SAS/STAT Software 
Enterprise Miner Server Solution May 29, 2006
SAS AppDev Studio 
SAS/OR Software May 29, 2006
SAS/QC Software May 29, 2006

$_Stream=——————— END ———————
$_Filename=setinit.sss
$_Path=sas\\core\\sasinst\\
$_Date=
$_Time=
$_Stream=——————– BEGIN ——————–
PROC SETINIT RELEASE=\’9.1\’;
SITEINFO NAME=\’ICFAI BUSINESS SCHOOL\’
SITE=49647001 OSNAME=\’WIN_NTE\’ RECREATE WARN=15  GRACE=15
BIRTHDAY=\’23NOV1992\’D EXPIRE=\’29MAY2006\’D  PASSWORD=74994967;
ALIAS \’ACADEMIC ANALYSIS SUITE\’ \’PRODNUM000\’ \’PRODNUM001\’ \’PRODNUM002\’
       \’PRODNUM003\’ \’PRODNUM004\’ \’PRODNUM007\’ \’PRODNUM010\’ \’PRODNUM015\’
       \’PRODNUM018\’ \’PRODNUM096\’ \’PRODNUM208\’ \’PRODNUM209\’ \’PRODNUM215\’
       / PASSWORD=332658067 PRODNUM=253;
CPU  MODEL=\’ \’ MODNUM=\’ \’ SERIAL=\’ \’ NAME=CPU000;
EXPIRE \’PRODNUM006\’ \’PRODNUM005\’ \’PRODNUM008\’ \’PRODNUM102\’ \’PRODNUM103\’
       \’PRODNUM025\’ \’PRODNUM164\’ \’PRODNUM165\’ \’PRODNUM166\’ \’PRODNUM167\’
       \’PRODNUM035\’ \’PRODNUM054\’ \’PRODNUM050\’ \’PRODNUM070\’ \’PRODNUM075\’
       \’ACADEMIC ANALYSIS SUITE\’ \’29MAY2006\’D / CPU=CPU000;
SAVE; RUN;

$_Stream=——————— END ———————
$_Filename=compinfo.dat
$_Path=sas\\core\\sasinst\\reserved\\
$_Date=
$_Time=
$_Stream=——————– BEGIN ——————–
[SeparatelylicensedComponents]
Comp1=or
Comp2=qc
Comp3=sas
Comp4=base
Comp5=5O
Comp6=9D
Comp7=AU

$_Stream=——————— END ———————
$_Filename=misc.txt
$_Path=.\\
$_Date=
$_Time=
$_Stream=——————– BEGIN ——————–
[CDSetInfo]
CDSetVersion=0
StrictVerChk=0

$_Stream=——————— END ———————
$_Filename=sas.ini
$_Path=sas\\core\\sasinst\\data\\
$_Date=
$_Time=
$_Stream=——————– BEGIN ——————–
[Component]
Filter=SAS,SAW
Visible=1
Media=cd101.id
MediaLabel=Software Disk 1
Parent=ROOT
ProcessOrder=900
Component=sas:SAS 9.1:SAS 9.1 for Windows:0
Prereq1=base:REQUIRED|SHOW
Prereq2=abmadaptsap
Prereq3=af
Prereq4=assist
Prereq5=baan
Prereq6=bissupp
Prereq7=connect
Prereq8=creditscrnod
Prereq9=db2
Prereq10=delete:HIDE
Prereq11=delete_server:HIDE
Prereq12=di
Prereq13=dipcl
Prereq14=dippr
Prereq15=dquality
Prereq16=eis
Prereq17=ets
Prereq18=finance
Prereq19=fsp
Prereq20=gis
Prereq21=gismaps
Prereq22=graph
Prereq23=hpf
Prereq24=iml
Prereq25=insight
Prereq26=intrnet
Prereq27=inttech
Prereq28=irp
Prereq29=itmadaptsap
Prereq30=itslm
Prereq31=lab
Prereq32=lastdisk:REQUIRED
Prereq33=ma
Prereq34=maps
Prereq35=mddbserv
Prereq36=mktopt
Prereq37=mysql
Prereq38=odbc
Prereq39=oledb
Prereq40=or
Prereq41=oracle
Prereq42=pcfile
Prereq43=peosoft
Prereq44=procurement
Prereq45=qc
Prereq46=r3
Prereq47=reinstal:REQUIRED
Prereq48=reporter
Prereq49=sapbw
Prereq50=scorecard
Prereq51=share
Prereq52=shrbndls:REQUIRED
Prereq53=soladaptsap
Prereq54=soltnsdata
Prereq55=srmsrcdqual
Prereq56=stat
Prereq57=sview
Prereq58=sybase
Prereq59=teradata
Prereq60=tmine
Prereq61=toolkt
Prereq62=txtmindan
Prereq63=txtmindut
Prereq64=txtminfin
Prereq65=txtminfre
Prereq66=txtminger
Prereq67=txtminita
Prereq68=txtminpor
Prereq69=txtminspa
Prereq70=txtminswe
Prereq71=vca
Prereq72=weba
Prereq73=webdatasrv
Prereq74=whouse

[Icons]
Icon1=RunSAS
Icon2=RunSASIQ
Icon3=RunSASQDoc

[Icons]
Icon1=RunSAS
Icon2=RunSASIQ
Icon3=RunSASQDoc

[RunSAS]
FolderType=PROGRAMS
ProgramFolder=SAS
Name=SAS 9.1
CommandLine=”<TARGETDIR>\\sas.exe”
DefaultConfig=1
Args=
WorkingDir=%USERPROFILE%
IconFile=”<TARGETDIR>\\sas.exe”
IconIndex=
ShortCutKey=
GroupType=COMMON

[RunSASIQ]
FolderType=PROGRAMS
ProgramFolder=SAS\\SAS 9.1 Utilities
Name=SAS Installation Qualification Tool
CommandLine=”<SASROOT>\\sastest\\sasiq.exe”
DefaultConfig=0
Args=
WorkingDir=”<SASROOT>\\sastest”
IconFile=”<SASROOT>\\sastest\\sasiq.exe”
IconIndex=
ShortCutKey=
GroupType=COMMON

[RunSASQDoc]
FolderType=PROGRAMS
ProgramFolder=SAS\\SAS 9.1 Utilities
Name=SAS Qualification Tools User\’s Guide
CommandLine=”<SASROOT>\\doc09\\qualification_tools_guide.pdf”
DefaultConfig=0
Args=
WorkingDir=%USERPROFILE%
IconFile=”<SASROOT>\\doc09\\qualification_tools_guide.pdf”
IconIndex=
ShortCutKey=
GroupType=COMMON

$_Stream=——————— END ———————
$_Filename=media.txt
$_Path=ssncd\\
$_Date=
$_Time=
$_Stream=——————– BEGIN ——————–
sassetup1cd:SAS Setup Disk
sharedcomp1cd:SAS Shared Components
srvpakwin1cd:Service Pack 3 for SAS Foundation
srvpakall1cd:Service Pack 3 Installer
ssncd:SAS Software Navigator
config1cd:SAS Configuration and Management – Volume 1
srwizard1cd:System Requirements Wizard
server2cd:SAS AppDev Studio Server Components
mid1cd:SAS Mid-Tier Components
mid5cd:SAS OnlineDoc for the Web
apidoc1cd:SAS BI API Developer Documentation for Java
mid4cd:SAS Web Report Viewer
client1cd:SAS Client-Side Components Volume 1
client2cd:SAS Client-Side Components Volume 2
client21cd:SAS Client-Side Components Volume 3
client8cd:SAS Enterprise Guide
client10cd:SAS BI Metadata Management Clients
client11cd:SAS AppDev Studio Java Components
thirdpty1cd:Third Party Software Components – Volume 1
thirdpty2cd:Third Party Software Components – Volume 2
thirdpty3cd:Third Party Software Components – Volume 3

$_Stream=——————— END ———————
$_Filename=showit.txt
$_Path=ssncd\\
$_Date=
$_Time=
$_Stream=——————– BEGIN ——————–
overview
media
sasplatform
acadsuite
dminesol
appdevupdate

$_Stream=——————— END ———————
$_Filename=orderable12byte.txt
$_Path=.\\
$_Date=
$_Time=
$_Stream=——————– BEGIN ——————–
# Order of Variables: 12byte, orderable, installable, planEnabled, Orderables, isServer
ACADSUITE     1  1  0  0  0
BASE          1  1  0  0  0
APPDEVUPDATE  1  1  1  0  0
ODBC          1  1  0  0  0
OLEDB         1  1  0  0  0
PCFILE        1  1  0  0  0
CONNECT       1  1  0  0  0
ETS           1  1  0  0  0
FSP           1  1  0  0  0
GRAPH         1  1  0  0  0
IML           1  1  0  0  0
INSIGHT       1  1  0  0  0
SHARE         1  1  0  0  0
STAT          1  1  0  0  0
DMINESOL      1  1  1  0  0
APPDEVUPDATE  1  1  1  0  0
OR            1  1  0  0  0
QC            1  1  0  0  0
EGUIDE        1  1  0  0  0

$_Stream=——————— END ———————
$_Filename=au.ini
$_Path=sas\\core\\sasinst\\data\\
$_Date=
$_Time=
$_Stream=——————– BEGIN ——————–
[Component]
Filter=SAS,SAW
Media=cd101.id
MediaLabel=Software Disk 1
Parent=ROOT
ProcessOrder=901
Component=AU:SAS AppDev Studio:SAS AppDev:0
Prereq1=lastdisk:REQUIRED
Prereq2=reinstal:REQUIRED
Prereq3=shrbndls:REQUIRED
Prereq4=delete:HIDE
Prereq5=delete_server:HIDE
Prereq6=af:REQUIRED
Prereq7=connect:REQUIRED
Prereq8=eis:REQUIRED
Prereq9=fsp:REQUIRED
Prereq10=graph:REQUIRED
Prereq11=inttech:REQUIRED
Prereq12=share:REQUIRED
Prereq13=intrnet:REQUIRED
Prereq14=base:REQUIRED

[Icons]
Icon1=RunSAS

[RunSAS]
FolderType=PROGRAMS
ProgramFolder=SAS
Name=SAS 9.1
CommandLine=”<TARGETDIR>\\sas.exe”
DefaultConfig=1
Args=
WorkingDir=%USERPROFILE%
IconFile=”<TARGETDIR>\\sas.exe”
IconIndex=
ShortCutKey=
GroupType=COMMON
$_Stream=——————— END ———————
$_Filename=9d.ini
$_Path=sas\\core\\sasinst\\data\\
$_Date=
$_Time=
$_Stream=——————– BEGIN ——————–
[Component]
Filter=SAS,SAW
Media=cd101.id
MediaLabel=Software Disk 1
Parent=ROOT
ProcessOrder=901
Component=9D:Enterprise Miner Server Solution:Enterprise:0
Prereq1=lastdisk:REQUIRED
Prereq2=reinstal:REQUIRED
Prereq3=shrbndls:REQUIRED
Prereq4=delete:HIDE
Prereq5=delete_server:HIDE
Prereq6=dmine:REQUIRED
Prereq7=connect:REQUIRED
Prereq8=ets:REQUIRED
Prereq9=graph:REQUIRED
Prereq10=eis:REQUIRED
Prereq11=fsp:REQUIRED
Prereq12=insight:REQUIRED
Prereq13=mddbserv:REQUIRED
Prereq14=or:REQUIRED
Prereq15=inttech:REQUIRED
Prereq16=base:REQUIRED

[Icons]
Icon1=RunSAS

[RunSAS]
FolderType=PROGRAMS
ProgramFolder=SAS
Name=SAS 9.1
CommandLine=”<TARGETDIR>\\sas.exe”
DefaultConfig=1
Args=
WorkingDir=%USERPROFILE%
IconFile=”<TARGETDIR>\\sas.exe”
IconIndex=
ShortCutKey=
GroupType=COMMON
$_Stream=——————— END ———————
$_Filename=5o.ini
$_Path=sas\\core\\sasinst\\data\\
$_Date=
$_Time=
$_Stream=——————– BEGIN ——————–
[Component]
Filter=SAS,SAW
Media=cd101.id
MediaLabel=Software Disk 1
Parent=ROOT
ProcessOrder=901
Component=5O:Academic Analysis Suite:Academic A:0
Prereq1=lastdisk:REQUIRED
Prereq2=reinstal:REQUIRED
Prereq3=shrbndls:REQUIRED
Prereq4=delete:HIDE
Prereq5=delete_server:HIDE
Prereq6=graph:REQUIRED
Prereq7=ets:REQUIRED
Prereq8=fsp:REQUIRED
Prereq9=iml:REQUIRED
Prereq10=share:REQUIRED
Prereq11=stat:REQUIRED
Prereq12=insight:REQUIRED
Prereq13=connect:REQUIRED
Prereq14=oledb:REQUIRED
Prereq15=pcfile:REQUIRED
Prereq16=odbc:REQUIRED
Prereq17=base:REQUIRED

[Icons]
Icon1=RunSAS

[RunSAS]
FolderType=PROGRAMS
ProgramFolder=SAS
Name=SAS 9.1
CommandLine=”<TARGETDIR>\\sas.exe”
DefaultConfig=1
Args=
WorkingDir=%USERPROFILE%
IconFile=”<TARGETDIR>\\sas.exe”
IconIndex=
ShortCutKey=
GroupType=COMMON
$_Stream=——————— END ———————
[_EOF_]

第 二步:用十六进制编辑器(例如ULTRAEDIT) 打开sashost.dll
搜索:31C9668B4DE8
换 成:31C966B92C00

然后将这个新生成的sashost复制到SAS安装目录下面覆盖原先的SASHOST就可以了。

这 样就可以调整过来了

不是想侵犯知识产权,只是想让更多的人都能用上SAS,感受一下最新的9.1.3,对了,我一直在找有ADD-IN OFFICE模块的SID,不知道有没有高手可以邮一份给我

ubuntu java 中文乱码

January 1, 2010

1,中文乱码问题

  在linux下安装完后,有中文乱码问题,经查找原因发现,Visual Paradigm自己带了JRE,关于在linux下java环境的中文乱码问题,在网上有很多解决的文章,这里就略过。如果当前的java环境中文是正 常的,只要将你的系统内的jre环境下的fontconfig.properties 文件复制一份到 Visual Paradigm软件安装目录下的 jre/lib目录。这样重新打开启动这个软件,你会发现中文正常使用了。

  不过发现菜单及窗口内有些还是英文的,汉化不是很完整。

How to run IntelliJ IDEA from Ubuntu Menu

December 31, 2009

After you had installed IntelliJ IDEA onto your PC with Ubuntu you probably want to add to it to Main Menu. But shortcut to
idea.sh
doesn’t work as expected, you need command like this:
sh -c "export JDK_HOME=/usr/lib/jvm/java-6-sun && /path/to/idea/bin/idea.sh"
and all will be ok.


Follow

Get every new post delivered to your Inbox.