Steven Sun's Blog

A dream land of peace.

忧郁的心情

忧郁, 毫无斗志。怎么好像每周都有那么会儿啊!要自强不息啊!

Oop in PHP

1. define a class with function and parameters

1
2
3
4
5
6
7
8
9
class classname
    {
    function operation1()
    {
    }
    function operation2($param1, $param2)
    {
    }
}

2. constructor

1
2
3
4
5
6
7
8
9
10
11
12
13
<?php
class classname
{
  function __construct($param)
  {
    echo "Constructor called with parameter ".$param."<br />";
  }
}

$a = new classname("First");
$b = new classname("Second");
$c = new classname();
?>

3. class attribute

1
2
3
4
5
6
7
class classname
{
public $attribute;
}
$a = new classname();
$a->attribute = "value";
echo $a->attribute;

4.  When you use this keyword “final” in front of a function declaration, that function cannot be overridden in any subclasses

5.  PHP use “interface” to implement the function of “multi inheritance”

1
2
3
4
5
6
7
8
9
10
11
12
interface Displayable
{
    function display();
}

class webPage implements Displayable
{
    function display()
{
// ...
}
}

Some Random Notes About Life and Work

Spent a lot of time last night and this morning to midify the theme of my blog to make it looks better without success. What a shame!

Useful Vim Command Tips

ctrl+w+(w, h, j, k,l)

ctrl+b,

ctrl+w,

gg  移到整份文件的最上方

G  移到整份文件的最下方

H  移动到当前屏幕的最上方

L  移动到当前屏幕的最下方

ds”  删除周围的双引号

cst  删除周围的tag

yss”  把整行加上双引号

:new  建立水平视窗

:vnew  建立垂直视窗

怎样把 Github上 的 Octopress Clone 到本地以及发布博客

力求精简, 步骤如下: 1. git clone -b source https://github.com/shpeacelover/shpeacelover.github.com octopress 2. cd octopress 3. git clone https://github.com/shpeacelover/shpeacelover.github.com _deploy 4. sudo gem install bundler 5. bundle install 6. rake new_post[“The Title of Your Article”] 7. bundle exec rake generate 8. bundle exec rake preview 9. bundle exec rake deploy 10. git add . 11. git commit -m ‘your comment’ 12. git push origin source

反省

之前在学Django的时候, 觉得挺难的, 并不像网络上有的人所说的那样的简单。结果是没有坚持下来。

现在在学Ruby还有Ruby On Rails,觉得愈加的难了。 毕竟自己之前对于Python以及Django的了解要多于对Ruby和Rails的了解。

虽然如此, 但是自己也已经啃了这些硬骨头有段日子了。 虽然很多东西仍然不甚了解, 但是如果不坚持下去, 就会又是只知道个皮毛。 那就又等于浪费了很多宝贵的时间去做无用功了。

告诉自己,必须坚持下去, 多思考,多看书, 多编程。 会有结果的。

奋斗

偶尔的心灰意冷算得了什么?人生短短几十载,吃点苦, 受点累又怎样? 如果年轻时不努力奋进,难道等到进了天堂后再去忏悔?

Country Road

Almost heaven, my hometown

To me as a child

Boundless farmland

Smooth brook

Life is old there

Older than the trees

Younger than the mountains

Growin’ like a breeze

Country Roads, take me home

To the place I belong

Like I never go beyond

Being innocent and having fun

(This is one I modified from John Denver’s “Take Me Home, Country Roads” to reminisce my long passed childhood.)

Git常用命令

以下是自己常用到的git命令:

git init git add . git commit -a -m ‘comment’ git checkout . git stauts git remote add origin ssh://user@host/~/git/depot.git git push origin master git clone some-repository some-path git clone —depth 50 some-repository git add -u|—update git add -A|—all git commit -m “Some message” -a (****this will commit all modified files)

Unstage a modified file that’s been staged. For example, to undo changes to cache.py, use this: prompt> git reset HEAD — cache.py

Undo all uncommitted changes to a file. prompt> git checkout — cache.py

git config credential.helper ‘cache —timeout=3600’ (the above will cache our password)

git brach new git checkout new git checkout -b new

to view all local branches: git branch to iew all remote branches: git branch -r to view all branches: git branch -a to view all that are or are not merged into the current branch : git branch —merged git branch —no-merged

Merge changes from development to the master branch: git checkout master git merge development

Merge changes, but don’t commit: git merge —no-commit development

Add a one-line log message from each merged commit to the merge message: git merge —log development