落园 |专注经济视角下的互联网

linux学习笔记:JDK, rJava以及RJDBC

出于某些原因,最近申请了一个虚拟服务器(虽然有现成的R服务器,但是没有sudo总是各种不爽...),然后开始自己折腾linux...(向着码农方向前进,前进,前...)以下为小白笔记,抄在这里防止自己日后翻回来重新折腾一遍。高手请无视~

服务器是公司C3云上的一片,我选的ubuntu 12.04开始折腾。由于是远程server,所以只能shell操作 T_T 看不到ubuntu华丽丽的界面了。

装R倒是不麻烦,把镜像加一下就好了。编辑/etc/apt/sources.list,然后加上这句(看了一下我的ubuntu是precise版本的)。不加这句的后果就是...装了个上个世纪版本的R?

然后就直接安...

然后就开始折腾RODBC,给teradata跪了,安个teradata ODBC Driver死活不成功,最后请教同事决定投保RJDBC的怀抱。

JDBC基于Java,自然需要装JDK。网上搜了一下,貌似有个open jdk可用。

然后保险起见,配一下java的路径。

如果看到下面这一段,那么就OK了。

然后就可以开始装R里面的那堆包了。R很神奇,必须sudo R之后install.packages()才有用...可怜我折腾了半天一直报错。
然后发现sudo的问题之后,顺利的装上了RJDBC.

然后就是Teradata JDBC Driver了。这厮比ODBC好装的多...基本就是解压...然后就没有然后了。

都弄好了之后,就可以在R里面测试着玩了。

然后就是JDBC的一些相关函数了。

然后就可以开始各种蹂躏了。

只是让我不爽的是,折腾了许久也没搞定发email...sendmail、mail什么的都不管用,莫非我SMTP没有配?继续google去了。

-----------------4.3更新----------------

原来C3和LDAP是直接集成的,所以别人的帐号也可以登入我的server。之后,一句命令可以加入sudo组:

----------------4.4更新----------------

今天在同事的帮助下搞定了Rstudio Server版,瞬间爽翻了...

以前是ubuntu 12.04下有个东西装不上: libssl0.9.8。因为默认装好了1.0版本的。但是Rstudio现在的版本必须调用0.9.8版本...于是强行装旧版:

然后再去装一下Rstudio Server版就好了。

然后为了调RJDBC,配置一下环境变量:

加入这么两行

然后刷新一下。

这样就搞定啦。Rstudio监听在服务器的8787端口。可以直接/server:8787 登入。


坑爹的RJDBC和Teradata

我实在是忍不住要抱怨了,哪有这样的半成品就给我们用的?RJDBC连TD是没有问题,可以读数据,但是dbWriteTable()写不回去!

[2016.1.12 更新]

亲爱的同事写了一个很方便用的r函数来解决这个问题,大家猛戳 -> github

[......]

Read more


Kindle PaperWhite 电源键失灵/无法唤醒/无法点亮屏幕

今天园主的kindle抽风了,除了连上电脑以外,一律无法唤醒(没变砖)。首先猜测电源键坏了,然后上网搜...有人云需要80元去电脑城修,呜啊!这个pw才入手不到一年啊!果断先拆机看看什么情况(好吧,这已经是我第三个kindle了,前两个的尸体都被我拆过,然后彻底的寿终正寝了)。我心里边拆边默念,这一定是我拆的最后一个kindle...

Pw比以前的kindle好拆,前面的壳纯属装饰,硬粘上去的,用瑞士军刀最薄的刀片撬开一角就好了。然后一圈螺丝拧下来,嗯,顺利地脱掉后盖。咦,怎么没问题啊,没有零件掉下来啊,怎么触电源触板还是不能唤醒。正当我打算拆电池的时候,又开始网上搜,这次居然搜到了kindle paperwhite的唤醒套。咦,这货居然可以有唤醒套?然后果断去拿ipad唤醒皮套试试。依然无效。

垂头丧气的,继续搜。有人再秀如何DIY皮套,看了一眼原理大概是磁铁感应。还是不死心的去测试,发现ipad的皮套可以唤醒ipad,应该是有磁性啊。难道是不够强?于是满屋子开始找磁铁。一开始想找个废耳机的磁铁,后来睁眼一看,这不是还有几个冰箱贴嘛!果断拿过来试试。一、二、三!绕了一圈,kindle居然亮了!然后电源键恢复如初!

这是什么原理....想不通也懒得再去想了,大家类似的情况可以先找个冰箱贴试试。大概是白天kindle和ipad、笔记本、耳机之类裸奔混在一起,有磁性干扰,触发了什么机制?后面强磁铁干扰回去就好了?噗。


英文写作笔记(二):避免废话太多

依旧从BerkeleyX: ColWri2.2x Principles of Written English 抄过来的。我真的对这门课是相见恨晚!呜呜,我写英文各种罗嗦(楼下群众:你中文更罗嗦好不好?你看落园多少废话?)

ps 中间有段讲写作语气的我没抄过来,这个感觉和语言就无关了,更多是用词的精准...

------------------------------------------------

what causes wordiness?

Wordiness is using more words than you need to in order to write what you mean.  Everyone has a tendency to be too wordy at times. Some of the causes of this wordiness are:

- Trying to sound too formal or academic. Unfortunately, in academic writing, there are a lot of examples of wordy writing. This doesn't mean you have to model your writing on bad examples. Your readers will always appreciate if you state your ideas clearly, and using no more words than needed.

- Not knowing more precise vocabulary.  For example, saying, She ran quickly to the store can be made somewhat less wordy, and more precise, by saying: She raced to the store (race=run quickly). Finding the right vocabulary can help you cut down the number of words you use. Every reduction helps, even if it's only a word or two.

- Using too many unnecessary and vague modifiers.  Typically, modifiers like really, very, quite, and similar words add no meaning to your writing. If you need to modify a word, find precise modifiers. For example, instead of There's a really tall building near my house, write: There's a 50-story building near my house. 

- Using too many prepositional phrases or possessives. These types of phrases can add length to your sentences, often unnecessarily. So, instead of The car belonging to Mr. Wang is in the garage [10 words], write: Mr. Wang's car is in the garage [7 words].

--------------------------------------------------

Writing less wordy prose

[......]

Read more


英文写作笔记(一):常见写作方向性错误

下面是抄过来的...来自:BerkeleyX: ColWri2.2x Principles of Written English。读完觉得我的英文写作真的是没受过正规教育...哎。

-------------------

There are two main sources of error in diction:

1. Choosing the wrong word. This can happen because of confusion between homonyms (words that sound alike but are spelled differently), or because the meaning of the word isn't fully understood.

2. Choosing colloquial, or less formal spoken language when standard or more formal language is called for (or vice versa). In academic writing, formal diction is generally expected.

Here are 21 common errors made in writing formal diction. How many of these usage errors have you made?

1. A lot/lots of

Colloquial: Diana likes her apartment a lot.
Formal: Diana likes her apartment very much.

Colloquial: There are lots of books in our library.
Formal: There are many books in our library.

2. Among/between
(Tip: Among involves more than two; between involves only two)

Colloquial: Discussions between our group members were often very lively.

Discussions Formal: Discussions among our group members were often very lively.

3. Around/ about
(Tip:  Don't use around to indicate time, distance, or other quantity.)

Colloquial: The class usually begins around nine.
Formal: The class usually begins at about nine.

4. Badly
(Tip: "Badly" is not a substitute for "very much.")

Colloquial: The team wanted to win really badly.
Formal: The team wanted desperately to win.

5. Based off of

Colloquial: Based off of that information,  we can move ahead with the plan.
Formal: Based on that information, we can move ahead with the plan.

6. Because
(Tip: Don't use "because" after " reason.")

Colloquial: The reason for our flight delay is because of bad weather.
Formal: The reason for our flight delay is the bad weather.

7. A bunch/bunches
(Tip: Use bunch or bunches only for things that are bound or grow together, like bananas and grapes; it is not used for other countable nouns.)

Colloquial: A bunch of us are going to the movies tonight.
Formal: A group of us are going to the movies tonight.
Formal: There are three bunches of bananas on the counter.

8. Each other/one other
(Tip: Each other refers to two, one another refers to more than two.)

Colloquial: Everyone at the party wished each other a happy new year.
Formal: Everyone at the party wished one another a happy new year.
Formal: My sister and I wished each other a happy new year.

9. Guys

Colloquial: I hope you guys can join me at the restaurant.
Formal: I hope all of you can join me at the restaurant.

10. In / Into
(Tip:  "In" means "within" or "inside", while "into" refers to the motion of going from outside to inside.)

Colloquial: Bill went in the bus station to buy a ticket.
Formal: Bill went into the bus station to buy a ticket.

11. Infer/imply
(Tip: To infer is an act of thinking, to imply is an act of saying something.)

Incorrect:  I saw your memo about a noon meeting. Are you inferring that we should have lunch together?
Correct: I saw your memo about a noon meeting. Are you implying that we should have lunch together?

12. It's/its

 

Incorrect: The committee has reached it's goals this year.
Correct: The committee has reached its goals this year.

13. Kind of / sort of
(Tip: Don't use "kind of" or "sort of" when you mean "very" , "rather," or "somewhat." )

Colloquial: Jim was sort of angry when he learned we went to the park without him.
Formal: Jim was somewhat upset when he learned we went to the park without him.

14. Less than/fewer than
(Tip: Use less than only with uncountable nouns.)

Colloquial: There are less people in the store today than yesterday.
Formal: There are fewer people in the store today than yesterday.

15. Like / as
(Tip: Use "as" when comparing actions, "like" when comparing things.)

Colloquial: Alan wants to write a new essay, just like Sarah does.
Formal: Alan wants to write a new essay just as Sarah does.

16. Like / maybe
(Tip: Avoid using "like" and "maybe" when estimating; use "approximately", "perhaps" or "about" instead.)

Colloquial: There were like thirty people at my birthday party.
Formal: There were approximately thirty people at my birthday party.

17. Meantime

Colloquial: Meantime, the rain continued to pour.
Formal: In the meantime, the rain continued to pour.
Formal: Meanwhile, the rain continued to pour.

18. On account of

Colloquial: On the account of the weather, our plane was late.
Formal: Because of the weather, our plane was late.

19. Plenty

Colloquial: It has been plenty warm all week.
Formal: It has been very warm all week.

20. So
(Tip: Don't use "so" as a synonym for "therefore".)

Colloquial: Dmitry knew that I missed class, so he shared his notes.
Formal: Dmitry knew that I missed class; therefore, he shared his notes.

Colloquial: This week's homework is so difficult.
Formal: This week's homework is very difficult.

21. They're/their/there

 

Incorrect: Do you know if their going to the party?
Correct: Do you know if they're going to the party?

Incorrect: What is there address?
Correct: What is their address?