Ruby环境安装过程

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
$ sudo su
Password:
sh-3.2# rvm -v
Can't find rvm install!
sh-3.2# curl -L get.rvm.io | bash -s stable
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   184  100   184    0     0    358      0 --:--:-- --:--:-- --:--:--  1082
100 13409  100 13409    0     0   7791      0  0:00:01  0:00:01 --:--:-- 51972
Downloading RVM from wayneeseguin branch stable
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   124  100   124    0     0    116      0  0:00:01  0:00:01 --:--:--   148
100 3263k  100 3263k    0     0   173k      0  0:00:18  0:00:18 --:--:--  362k

Installing RVM to /usr/local/rvm/
    Group 'rvm' already exists
usage: mktemp [-d] [-q] [-t prefix] [-u] template ...
       mktemp [-d] [-q] [-u] -t prefix
/usr/local/rvm/src/rvm/scripts/functions/installer: line 990: : No such file or directory

 RVM:  Shell scripts enabling management of multiple ruby environments.
 RTFM: https://rvm.io/
 HELP: http://webchat.freenode.net/?channels=rvm (#rvm on irc.freenode.net)
 Cheatsheet: http://cheat.errtheblog.com/s/rvm
 Screencast: http://screencasts.org/episodes/how-to-use-rvm

 In case of any issues run 'rvm requirements' or read 'rvm notes'

Installation of RVM in /usr/local/rvm/ is almost complete:

  * First you need to add all users that will be using rvm to 'rvm' group,
    and logout - login again, anyone using rvm will be operating with `umask u=rwx,g=rwx,o=rx`.

  * To start using RVM you need to run `source /etc/profile.d/rvm.sh`
    in all your open shell windows, in rare cases you need to reopen all shell windows.

 xujingbao,

   Thank you for using RVM!
   I sincerely hope that RVM helps to make your life easier and
   more enjoyable!!!

 ~Wayne

sh-3.2# rvm -v

rvm 1.19.6 (stable) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]

sh-3.2# [ -r ~/.profile ] && source ~/.profile
sh-3.2# rvm requirements
Installing requirements for osx, might require sudo password.
Skipping `brew update` make sure your formulas are up to date.
RVM autolibs is now configured with mode '2' => 'check and stop if missing',
please run `rvm autolibs enable` to let RVM do its job or run and read `rvm autolibs [help]`
or visit https://rvm.io/rvm/autolibs for more information.
Missing required packages: libtool, libxml2, libxslt, libksba, openssl, sqlite.
RVM autolibs is now configured with mode '2' => 'check and stop if missing',
please run `rvm autolibs enable` to let RVM do its job or run and read `rvm autolibs [help]`
or visit https://rvm.io/rvm/autolibs for more information.
There were package installation errors, make sure to read the log.
Check Homebrew requirements https://github.com/mxcl/homebrew/wiki/Installation
sh-3.2# rvm autolibs enable
sh-3.2# rvm requirements
Installing requirements for osx, might require sudo password.
Updated Homebrew from acf99493 to b43d20d2.
==> Updated Formulae
antiword
Installing required packages: libtool, libxml2, libxslt, libksba, openssl, sqlite..............................................................................................................
Updating certificates in '/usr/local/etc/openssl/cert.pem'.
sh-3.2# rvm list

rvm rubies


 No rvm rubies installed yet. Try 'rvm help install'.

sh-3.2#
sh-3.2# rvm list

rvm rubies


 No rvm rubies installed yet. Try 'rvm help install'.

sh-3.2# rvm install 2.0.0
Searching for binary rubies, this might take some time.
No binary rubies available for: osx/10.8/x86_64/ruby-2.0.0-p0.
Continuing with compilation. Please read 'rvm mount' to get more information on binary rubies.
Installing requirements for osx, might require sudo password.
Already up-to-date.
Certificates in '/usr/local/etc/openssl/cert.pem' already are up to date.
Installing Ruby from source to: /usr/local/rvm/rubies/ruby-2.0.0-p0, this may take a while depending on your cpu(s)...
ruby-2.0.0-p0 - #downloading ruby-2.0.0-p0, this may take a while depending on your connection...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 10.3M  100 10.3M    0     0   150k      0  0:01:10  0:01:10 --:--:--  218k
ruby-2.0.0-p0 - #extracting ruby-2.0.0-p0 to /usr/local/rvm/src/ruby-2.0.0-p0
ruby-2.0.0-p0 - #extracted to /usr/local/rvm/src/ruby-2.0.0-p0
ruby-2.0.0-p0 - #configuring......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
ruby-2.0.0-p0 - #compiling......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
ruby-2.0.0-p0 - #installing .................................................................................................................................
Retrieving rubygems-2.0.3
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  326k  100  326k    0     0  93417      0  0:00:03  0:00:03 --:--:--  107k
Extracting rubygems-2.0.3 ...
Removing old Rubygems files...
Installing rubygems-2.0.3 for ruby-2.0.0-p0...........................................................................................................................................................................................................................................................................................................................................................................................................
Installation of rubygems completed successfully.
Saving wrappers to '/usr/local/rvm/wrappers/ruby-2.0.0-p0'........

ruby-2.0.0-p0 - #adjusting #shebangs for (gem irb erb ri rdoc testrb rake).
ruby-2.0.0-p0 - #importing default gemsets, this may take time.......................
Install of ruby-2.0.0-p0 - #complete

$echo $PATH
/usr/local/Cellar/ruby/2.0.0-p0/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/Users/xujingbao/.rvm/bin:/Applications/android-sdk-macosx/platform-tools/
$ ruby -v
ruby 2.0.0p0 (2013-02-24 revision 39474) [x86_64-darwin12.3.0]

MacPorts和Homebrew

Mac OS X是基于Unix的操作系统,可以安装大部分为Unix/Linux开发的软件。然而,如果只是以使用为目的,对每个软件都进行手工编译不是很方便,也不利于管理已安装的软件,于是出现了类似于Linux中APT、Yum等类似的软件包管理系统,其中最著名的有MacPorts、Fink、Homebrew等。

Java虚拟机、内存溢出、垃圾回收相关

一、java虚拟机

运行一个java程序,就会生成一个虚拟机实例,程序关闭,实例消亡。过main方法启动程序。 虚拟机内部有两种线程:守护线程和非守护线程。守护由虚拟机自己使用,例如执行垃圾回收的任务。main是非守护线程。

二、java虚拟机体系结构

类装载系统:装载类或借口

执行引擎:

运行时数据区:装载进来的class信息,程序对象,方法参数,返回值,局部变量。

 方法区和堆是所有线程共享。虚拟机装在一个class文件时,从二进制文件中解析类型信息,把类型信息放到方法区中,程序运行时,把创建的对象放到堆中。

当一个线程创建时,会得到一个程序计数器,和java栈,计数器指向下一条将要执行的指令。栈保存了局部变量,参数,返回值,运算中间结果。栈由栈枕组成,一个栈帧是一个java方法调用的状态,线程调用一个方法,虚拟机就往栈中压入一个栈帧,方法返回时,栈帧弹出并抛弃。栈和计数器不能共享。

三、垃圾回收

Java堆中存放着程序创建的所有对象,GC可以自动释放堆中不再使用的对象

四、内存溢出

堆溢出:对象太多

栈溢出:函数调用太多

permgen space溢出:class太多

Google日历与iCal合并

最早是适用Google日历的,后来用了iCal的日历,为了把原先的Google的数据也增加进来,就把Google账号添加进来,这样就出现了Google日历和iCal日志共存,发现很混乱啊。而且Google的产品现在很坑,时不时的中断连接,遂决定除了Gmail,把所有东西都转移到iCloud。

为了删除Google日历账号后,仍然让其数据同步到iCal上。需要进行一个导入操作:

1.首先进入Google日历网页版,在日历设置里找到【导出日历】这个连接,点击可以得到扩展名为ics的日历数据。

2.直接双击这个文件,会提示导入iCal的哪个分组。这样数据就都合并到iCal了。

3.现在可以把Google日历关掉了,同时把iCal配置的Google账户也删除。以后就和Google没关系拉。

iPhone维修记

前几天,iPhone的解锁键突然发软,弹不起来了!一冲动就给拆了,看了一下可能是开机排线的问题。要换件的,就又装上了,凑合了几天。有次,在商场一个手机维修的地方,给那维修人员看了,说要150块,我去踏马的。一想还不如自己换!去淘宝找了找,果然有iPhone的零部件卖!于是买了一个排线,全套螺丝,一个后壳。今天拆装4次,终于给换上了!

另外总结了一下iPhone的几个硬件常见故障!

1、解锁键失效,按下去弹不起来,这90%是开机排线的问题。就是下面这个东西。20多块钱。

屏幕快照 2013-02-01 下午8.46.40

2、wifi信号变弱,这是那个半圆形的铁环的地方,有一个长螺丝,漏上或不紧信号就会很弱。

240_601872_310d5f0d38aa1df

3、sim卡能弹起,但取不出来,应该是被主板卡住了,可以打开后盖,把主板的螺丝松一下。

2012年个人总结

迟到的总结。

这么多年,每到年末年始都会有一些想法和计划,但是总是不能付出与行动。所以打算从现在开始,没到这个时候就做一下总价和规划,并记录下来。

域名过期了

域名11月份过期了,没有续费,上个月再想续费,已经过了续费期,只能等到现在才续上。

原来是用的EW代理新网的域名服务,觉得他们的服务不好,现在用万网的了。

这算是2013年第一个博客~ fighting!

nodejs+mongodb错误throw arguments[1]

[js]node app.js
Express server listening on port

events.js:68
throw arguments[1]; // Unhandled ‘error’ event
^
Error: listen EADDRINUSE
at errnoException (net.js:769:11)
at HTTPServer.Server._listen2 (net.js:909:14)
at listen (net.js:936:10)
at HTTPServer.Server.listen (net.js:985:5)
at Object. (/Users/xujingbao/Desktop/microblog/app.js:58:5)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.runMain (module.js:492:10)[/js]

这种情况八成是app.listen(3001);这个端口被占用了,换一个!

在一个网页安装多个Google Analytics代码

[javascript][/javascript]

_gaq 是一个全局对象数组,定义在ga.js中,获取实例后,通过 _gaq.push()将请求发送到Google,如果安装多个分析账户,是从队列中依次发送。

grub rescue

grub rescue >set root=(hd0,8) #设置文件路径

grub rescue >set prefix=(hd0,8)/boot/grub #同上

grub rescue> insmod normal

回车以后便是另外一个界面

rescue grub >

继续;

rescue grub> normal