Gih's Blog

片言只语

我的计算机史

2016-10-15 by gihnius, tagged as computer, programming, tech, web
  • 1999: DOS, 软盘, 金山, Win95/98, 五笔打字, 冷启动, 热启动…
  • 2004: 网吧, Internet, HTML, Windows Me/2000, 个人主页, BBS, QQ, 易趣, Tom, 雅虎…
  • 2005: QuickBasic, VisualBasic 6.0, Windows XP…
  • 2006–2008: 组装机, 微机原理, IBM80x86汇编, C语言, 操作系统, 数据库基础, 网络基础, 51单片机, ASP.NET, IIS, 3DsMax, 计算机图形学, PhotoShop…
  • 2009–2011: Ruby on Rails, MVC, Perl, CGI, Linux, FreeBSD, Solaris, AIX, IBM小型机, Web 2.0, LAMP, ThinkPad, System adminstrator…
  • 2012–2014: Ruby on Rails, Javascript, DevOps, BigData, Hadoop, AWS EC2, Cloud, Common Lisp, Go语言, 远程开发, Macbook pro…
  • 2015–2016: Ruby on Rails, OA, 光伏, Electric vehicle…
  • 2017: …

backup/export database from heroku

2015-04-27 by gihnius, tagged as database

escape from heroku

app="gallery"

backup db of app

heroku pgbackups:capture -a $app-staging
heroku pgbackups:capture -a $app-demo
heroku pgbackups:capture -a $app-production

download

curl -o staging.dump `heroku pgbackups:url -a $app-staging`
curl -o demo.dump `heroku pgbackups:url -a $app-demo`
curl -o prod.dump `heroku pgbackups:url -a $app-production`

upload to ec2

scp *.dump admin@EC2IP:

import db

pg_restore --verbose --clean --no-acl --no-owner -h localhost -U rails -d $app_dev staging.dump
pg_restore --verbose --clean --no-acl --no-owner -h localhost -U rails -d $app_demo demo.dump
pg_restore --verbose --clean --no-acl --no-owner -h localhost -U rails -d $app_production prod.dump

refer

https://devcenter.heroku.com/articles/pgbackups

整理了一下博客

2015-04-06 by gihnius, tagged as internet
今天更新了式样, 添加了 Disqus 评论系统, 欢迎评论. 链接也采用标题描述取代原来的日期方式.

关闭 padory.com

2015-04-02 by gihnius, tagged as web

https://www.padory.com/ 是一个用 Go 语言写的知识分享的社区网站, 运行已经有大半年, 今天把它给关了,因为我完全不懂也没有足够的时间去好好运营一个社区网站. 就像博客一样, 也是当年 (2011) 一时心血来潮搭起来的. 当时自己并没有想过怎样去写好博客, 就拿一些技术记录来充数, 到现在也一样, 只不过都运行这么几年了, 关闭了有点可惜.

睡觉了...明天回去过清明呢.

Thrush calls in Common Lisp

2014-09-19 by gihnius, tagged as lisp

Implement the "->" operator of Clojure: http://clojuredocs.org/clojure_core/clojure.core/-%3E in CL, that's funny.

->

Threads the expr through the forms. Inserts x as the second item in the first form, making a list of it if it is not a list already. If there are more forms, inserts the first form as the second item in second form, etc.

(defmacro -> (x &optional (form nil form-supplied-p) &rest more)
  (if form-supplied-p
      (if more
          `(-> (-> ,x ,form) ,@more)
          (if (listp form)
              `(,(car form) ,x ,@(cdr form))
              (list form x)))
      x))

How does it works?

CL-USER> (-> 1
             (+ 1)
             (+ 2)
             (+ 3))

7
CL-USER> 

=== (+ (+ (+ 1 1) 2) 3)

See another example:

CL-USER> (-> 10
             (- 5)
             (- 5)
             (- 5))
-5
CL-USER> 

=== (- (- (- 10 5) 5) 5)

How if I want (- 5 (- 5 (- 5 10)))?

There is ->> to do this. http://clojuredocs.org/clojure_core/clojure.core/-%3E%3E

->>

Threads the expr through the forms. Inserts x as the last item in the first form, making a list of it if it is not a list already. If there are more forms, inserts the first form as the last item in second form, etc.

(defmacro ->> (x &optional (form nil form-supplied-p) &rest more)
  (if form-supplied-p
      (if more
          `(->> (->> ,x ,form) ,@more)
          (if (listp form)
              `(,(car form) ,@(cdr form) ,x)
              (list form x)))
      x))

This one looks more useful sometimes.

CL-USER> (->> (list 1 2 3 4 5)
              (reduce '+)
              (* 2)
              (- 5))
-25
CL-USER> 

=== (- 5 (* 2 (reduce '+ '(1 2 3 4 5))))


Move from Sr-SpeedBar to NeoTree

2014-09-17 by gihnius, tagged as emacs

NeoTree is more lightweight and simple.

;; (require 'sr-speedbar)
;; (make-face 'speedbar-face)
;; (set-face-font 'speedbar-face "DejaVu Sans Mono-11")
;; (setq speedbar-use-images nil)
;; (setq sr-speedbar-delete-windows t)
;; (setq sr-speedbar-right-side nil)
;; (setq sr-speedbar-width-x 25)
;; (setq sr-speedbar-width-console 25)
;; (setq sr-speedbar-max-width 30)
;; (setq speedbar-verbosity-level 0)
;; (setq sr-speedbar-skip-other-window-p t)

;; install neotree by ELPA
;; use neotree instead
(require 'neotree)
(setq neo-window-width 28)

how they looks?

A complete brief notes on setting up 3 nodes HBase cluster.

2014-09-17 by gihnius, tagged as linux

Here is an experience on setting up a 3-nodes-hbase-cluster(1 name-node and 2 data-node)  on AWS EC2.

Read more »

Secure your cookies of Hunchentoot in Common Lisp.

2014-09-17 by gihnius, tagged as lisp

Encrypt and decrypt cookies in hunchentoot. What is COOKIE?

Hunchentoot - The Common Lisp web server formerly known as TBNL

Hunchentoot is a web server written in Common Lisp and at the same time a toolkit for building dynamic websites. As a stand-alone web server, Hunchentoot is capable of HTTP/1.1 chunking (both directions), persistent connections (keep-alive), and SSL.

By default, hunchentoot supports cookies, but all cookies will be exposed once a request was done from the client. And there is not a solution to secure the cookies transform by now in hunchentoot. So the temporary choice is using the hunchentoot session:

Read more »

create small emacs window

2014-09-08 by gihnius, tagged as emacs

create a small "mini pad" from emacs by make-frame function.

(defun make-mini-pad ()
  (interactive)
  (make-frame '(
                (name . "mini")
                (width . 72)
                (height . 39))))

M-x make-mini-pad


这么玩 lisp,实在让人蛋疼!

2014-09-08 by gihnius, tagged as lisp

取个环境变量都要这么折腾:

(defun getenv (var)
  #+cmu (cdr (assoc (if (symbolp var)
                        var
                        (intern var :keyword))
                    ext:*environment-list*))
  #+sbcl (sb-ext:posix-getenv (string var))
  #+lispworks (hcl:getenv var)
  #+clisp (ext:getenv (string var))
  #+allegro (sys:getenv (string var))
  #-(or cmu sbcl lispworks clisp allegro)
  (error "GETENV not implemented for your Lisp platform."))