安装Cloud9 IDE

Heroin 发表于 2012-11-24

##安装nodejs

详细步骤请看

传送门

###安装sourcemint

cloud9 ide github的readme中说明需要通过sm来安装cloud9 ide

使用npm 安装sm

npm install -g sm

安装完毕后验证下

root@core ~# sm --version
0.2.11

##下载cloud9 IDE

https://github.com/ajaxorg/cloud9

git clone https://github.com/ajaxorg/cloud9.git cloud9
cd cloud9
sm install

接下来是漫长的等待了, sm安装完毕后给cloud9.sh授权下执行权限

chmod +x cloud9.sh

然后启动

./cloud9.sh

启动完毕后会输出监听端口3131

##配置cloud9 IDE

安装完毕后, 是使用localhost的方式绑定的3131端口

别人无法直接通过ip访问

修改配置, cloud9/configs/default.js

其中有一句是

var host = argv.l || process.env.IP || "localhost";

localhost替换成你的ip即可

###配置nginx

我的nginx配置文件如下

upstream cloud9 {
    server 127.0.0.1:3131;
    server 192.168.12.108:3131;
}

server {
    listen                      80;
    server_name                 cloud9.open-ns.org;

    charset                     utf-8;
    location / {
        proxy_pass              http://cloud9;
        proxy_set_header        Host             $host;
        proxy_set_header        X-Real-IP        $remote_addr;
        proxy_set_header        X-Forwarded-For  $proxy_add_x_forwarded_for;
    }
}

配置完毕后通过域名访问

最后效果如下

linux编译nodejs

Heroin 发表于 2012-10-26

##获取nodejs

下载地址

http://nodejs.org/dist/

本次使用的是32位版本的, 看系统什么样选择

http://nodejs.org/dist/v0.8.14/node-v0.8.14.tar.gz

##安装nodejs

我使用的是turnkey-core-11.3, 基于ubuntu-10.04, 因为安装快, 并且小

###安装依赖包

apt-get install g++ curl libssl-dev build-essential

###编译

./configure --prefix=/usr/local/nodejs
make
make install

###配置环境变量

NODE_HOME=/usr/local/nodejs
PATH=$PATH:$NODE_HOME/bin
export NODE_HOME PATH

. /etc/profiles

##验证

root@core ~# node -v
v0.8.14
root@core ~# npm -v
1.1.65

emacs 开发环境 lisp erlang golang

Heroin 发表于 2012-07-20

代码主题

;; ----------------------------- color theme ----------------------------- ;;
(add-to-list 'load-path "C:/Program Files/emacs/plugins/color theme/")
(require 'color-theme)
(color-theme-initialize)
(color-theme-oswald)

全局配置

;; ----------------------------- global config ----------------------------- ;;
(custom-set-variables '(tool-bar-mode nil))                             ;; -*- 删除工具栏 -*-
(custom-set-faces '(default ((t (:family "Monaco")))))                  ;; -*- 设置字体 -*-
(global-linum-mode t)                                                   ;; -*- 显示行号 -*-
(setq default-make-backup-files nil)                                    ;; -*- 不自动备份 -*-
(setq default-frame-alist '((width . 160) (height . 40)))               ;; -*- 设置窗体大小 -*-
(set-frame-parameter (selected-frame) 'alpha '(85 85))                  ;; -*- 设置透明度 -*-
(setq inhibit-startup-screen t)                                         ;; -*- 启动界面 -*-
(setq default-buffer-file-coding-system 'utf-8-unix)                    ;; -*- 设置文件编码 -*-
(set-terminal-coding-system 'utf-8-unix)                                ;; -*- 设置终端编码 -*-
(set-keyboard-coding-system 'utf-8-unix)                                ;; -*- 设置输入编码 -*-
(setq-default indent-tabs-mode nil tab-always-indent nil tab-width 4)   ;; -*- 使用空格代替缩进 -*-
(setq default-directory "~/Desktop")                                    ;; -*- 默认路径 -*-
(show-paren-mode t)                                                     ;; -*- 显示括号匹配, 而不是匹配后短暂的跳到另一个括号 -*-
(setq show-paren-style 'parentheses)                                    ;; -*- 显示括号匹配样式 -*-
(setq-default kill-whole-line t)                                        ;; -*- 使用 C-k 删除整行 -*-
(defalias 'yes-or-no-p 'y-or-n-p)                                       ;; -*- 不要问 yes-or-no,只问 y-or-n -*-
(setq frame-title-format "Emacs@%b %f")                                 ;; -*- 设置 emacs 的标题 -*-
(icomplete-mode t)                                                      ;; -*- 在minibuffer里启用自动补全函数和变量 -*-

(setq-default cursor-type 'bar)                                         ;; -*- 光标为竖线 -*-

(global-set-key [f2] 'undo)                                             ;; -*- 撤销 -*-
(global-set-key [f4] 'kill-this-buffer)                                 ;; -*- 关闭当前buffer -*-
(global-set-key [M-left] 'windmove-left)                                ;; -*- 移动到左边的buffer -*-
(global-set-key [M-right] 'windmove-right)                              ;; -*- 移动到右边的buffer -*-
(global-set-key [M-up] 'windmove-up)                                    ;; -*- 移动到上边的buffer -*-
(global-set-key [M-down] 'windmove-down)                                ;; -*- 移动到下边的buffer -*-
(global-set-key [C-tab] 'next-buffer)                                   ;; -*- 切换buffer -*-

自动提示

;; ----------------------------- auto-complete ----------------------------- ;;
(add-to-list 'load-path "C:/Program Files/emacs/plugins/auto-complete/")
(require 'auto-complete-config)
(add-to-list 'ac-dictionary-directories "C:/Program Files/emacs/plugins/auto-complete/ac-dict")
(ac-config-default)
(local-set-key (kbd "M-/") 'semantic-complete-analyze-inline)
(local-set-key "." 'semantic-complete-self-insert)
(local-set-key ">" 'semantic-complete-self-insert)

tab标签栏

;; ----------------------------- tabbar ----------------------------- ;;
(add-to-list 'load-path "C:/Program Files/emacs/plugins/one/")
(require 'tabbar)
(setq tabbar-ruler-global-tabbar 't) ; If you want tabbar 

(require 'tabbar-ruler)
(tabbar-mode 1)

ccl

;; ----------------------------- ccl lisp ----------------------------- ;;
(add-to-list 'load-path "C:/Program Files/ccl/")
(setq inferior-lisp-program "wx86cl")

slime

;; ----------------------------- slime ----------------------------- ;;
(add-to-list 'load-path "C:/Program Files/emacs/plugins/slime/")
(require 'slime-autoloads)
(slime-setup '(slime-fancy))
(slime-setup '(slime-repl))

(require 'ac-slime)
(add-hook 'slime-mode-hook 'set-up-slime-ac)
(add-hook 'slime-repl-mode-hook 'set-up-slime-ac)
(eval-after-load "auto-complete"
  '(add-to-list 'ac-modes 'slime-repl-mode))

erlang

;; ----------------------------- erlang ----------------------------- ;;
(setq load-path (cons "C:/Program Files/erl5.9.2/lib/tools-2.6.8/emacs" load-path))
(setq erlang-root-dir "C:/Program Files/erl5.9.2")
(setq exec-path (cons "C:/Program Files/erl5.9.2/bin" exec-path))
(require 'erlang-start)

golang

;; ----------------------------- golang ----------------------------- ;;
(setq load-path (cons "C:/Program Files/emacs/plugins/golang" load-path))
(require 'go-mode-load)
(require 'go-autocomplete)
;(speedbar 1)
;(speedbar-add-supported-extension ".go")

(add-hook
 'go-mode-hook
 '(lambda ()
   ;; gocode
   (auto-complete-mode 1)
   (setq ac-sources '(ac-source-go))
   ;; Imenu & Speedbar
   (setq imenu-generic-expression
    '(("type" "^type *\\([^ \t\n\r\f]*\\)" 1)
      ("func" "^func *\\(.*\\) {" 1)))
   (imenu-add-to-menubar "Index")
   ;; Outline mode
   (make-local-variable 'outline-regexp)
   (setq outline-regexp "//\\.\\|//[^\r\n\f][^\r\n\f]\\|pack\\|func\\|impo\\|cons\\|var.\\|type\\|\t\t*....")
   (outline-minor-mode 1)
   (local-set-key "\M-a" 'outline-previous-visible-heading)
   (local-set-key "\M-e" 'outline-next-visible-heading)
   ;; Menu bar
   (require 'easymenu)
   (defconst go-hooked-menu
     '("Go tools"
       ["Go run buffer" go t]
       ["Go reformat buffer" go-fmt-buffer t]
       ["Go check buffer" go-fix-buffer t]))
   (easy-menu-define
       go-added-menu
       (current-local-map)
     "Go tools"
     go-hooked-menu)
   ;; Other
   (setq show-trailing-whitespace t)))

;; helper function
(defun go () 
  "run current buffer"
  (interactive)
  (compile (concat "go run " (buffer-file-name))))

;; helper function
(defun go-fmt-buffer ()
  "run gofmt on current buffer"
  (interactive)
  (if buffer-read-only
      (progn
        (ding)
        (message "Buffer is read only"))
      (let ((p (line-number-at-pos))
            (filename (buffer-file-name))
            (old-max-mini-window-height max-mini-window-height))
        (show-all)
        (if (get-buffer "*Go Reformat Errors*")
            (progn
              (delete-windows-on "*Go Reformat Errors*")
              (kill-buffer "*Go Reformat Errors*")))
        (setq max-mini-window-height 1)
        (if (= 0 (shell-command-on-region (point-min) (point-max) "gofmt" "*Go Reformat Output*" nil "*Go Reformat Errors*" t))
            (progn
              (erase-buffer)
              (insert-buffer-substring "*Go Reformat Output*")
              (goto-char (point-min))
              (forward-line (1- p)))
            (with-current-buffer "*Go Reformat Errors*"
              (progn
                (goto-char (point-min))
                (while (re-search-forward "<standard input>" nil t)
                  (replace-match filename))
                (goto-char (point-min))
                (compilation-mode))))
        (setq max-mini-window-height old-max-mini-window-height)
        (delete-windows-on "*Go Reformat Output*")
        (kill-buffer "*Go Reformat Output*"))))

;; helper function
(defun go-fix-buffer ()
  "run gofix on current buffer"
  (interactive)
  (show-all)
  (shell-command-on-region (point-min) (point-max) "go tool fix -diff"))

cedet ecb

;; ----------------------------- cedet + ecb ----------------------------- ;;
(setq stack-trace-on-error t)
(require 'cedet)

(require 'semantic/analyze)
(provide 'semantic-analyze)
(provide 'semantic-ctxt)
(provide 'semanticdb)
(provide 'semanticdb-find)
(provide 'semanticdb-mode)
(provide 'semantic-load)

(add-to-list 'load-path "C:/Program Files/emacs/plugins/ecb/")
(setq ecb-options-version "2.40"
      ecb-auto-compatibility-check nil
      ecb-auto-activate t
      ecb-tip-of-the-day nil
      ecb-windows-witdh 0.1
      ecb-fix-window-size t
      ecb-primary-secondary-mouse-buttons (quote mouse-1--C-mouse-1)
      ecb-source-path '("D:/Code/"
                        "D:/Code/Erlang"
                        "D:/Code/Lisp"))
(require 'ecb)
(require 'ecb-autoloads)

yasnippet

;; ----------------------------- yasnippet ----------------------------- ;;
(add-to-list 'load-path "C:/Program Files/emacs/plugins/yasnippet/")
(require 'yasnippet)
(setq yas/snippet-dirs '("C:/Program Files/emacs/plugins/yasnippet/snippets"
                         "C:/Program Files/emacs/plugins/yasnippet/extras/imported"))
(yas/global-mode 1)

linux编译nginx

Heroin 发表于 2012-06-11

##安装依赖包

apt-get install libssl-dev openssl

##安装pcre

pcre下载地址

ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/

./configure –-prefix=/usr/local/pcre
make 
make install

##编译nginx

./configure --without-http_rewrite_module --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
make
make install

##配置环境变量

NGX_HOME=/usr/local/nginx
PATH=$PATH:$NGX_HOME/sbin
export NGX_HOME PATH

##验证

直接启动nginx 使用curl 验证即可

curl -I http://127.0.0.1

linux 安装 svn 服务

Heroin 发表于 2012-06-10

##安装subversion

linux下直接输入命令安装subversion

debian

apt-get install subversion

redhat

yum install subversion

##创建svn库

安装完subversion后使用svnadmin创建一个库

例如

svnadmin create /var/svn/repo

创建完毕后会生成几个目录 - conf - db - hooks - locks

还会创建2个文件 - README.txt - format

##配置svn

主要是修改conf下的几个配置文件 - authz - passwd - svnserve.conf

authz目录访问权限配置
passwd帐号配置
svnserve.conf基础配置, 指向用那些配置文件等

###修改passwd

passwd中的帐号是帐号=密码的方式存储, 直接写入就行

[users]
admin = admin

###修改authz

authz下主要是3种节点

  • aliases 配置别名, 这个不配置留空就行
  • groups 配置组, 也可以不用配置
[aliases]

[groups]
system = admin

[/]
@system = rw

[repos:/]
admin = rw

其中直接写的是代表配置的是帐号的权限, 带@代表的是配置组的权限

目录的配置还有更灵活的方式配置, 可以不用写的那么的死

###修改svnserve.conf

直接贴上配置, 具体配置方式注释文档上写的很清楚, 以下是我的配置

[general]
anon-access = none
auth-access = write
password-db = passwd
authz-db = authz

[sasl]

###启动svn服务

配置完毕后直接启动就行了, 通过svn客户端就能直接访问的

 svnserve -d -r /var/svn/repo/

其中svnserve 还有挺多个启动参数, 就不一一介绍了

###关闭svn服务

直接kill掉svnserve进程就行了

kill -9 `ps -ef | grep svnserve | grep -v grep | awk '{print $2}'`