Hello World


  • Home

  • About

  • Archives

心情日记2019-12-03

Posted on 2019-12-03

披星戴月的想你



告五人乐队
顺其自然的借口
像森林般围绕着你我
消极的笑痛快的哭
生命真的很难形容

心情日记2019/11/29

Posted on 2019-11-29

没有人是一座孤岛



[英]约翰.多恩

没有人是一座孤岛

可以自全。

每个人都是大陆的一片,

整体的一部分。

如果海水冲掉一片,

欧洲就减少,

如同一个海岬失掉一角,

如果你的朋友或者你自己的领地失掉一块:

任何人的死亡都是我的损失,

因为我是人类的一员,

因此

不要问丧钟为谁而鸣,

它就为你而鸣。

scrapy learning

Posted on 2017-11-10

Crawling comics

Recently, I was reading bleach comics from the internet.

bleach

But when I read those comics, I realise the image loading is relatively slow due to the internet connectivity. So I was considering if I can write any scripts to save images locally for quick reading.

For this task, I applied scrapy python spider framework for crawling automation. However, most of comics are using lazy loading technology, which utilizes JavaScript code to load images. For lazy loading, the images can not be loaded only from html static context. There are two potential solutions to handle this trouble:

  1. Call python library to run browser to activate javascript code functionality.
  2. Use some javascript libraries to load page and then run crawling.

emacs configuration file

Posted on 2017-10-26

In this post, we start to explore the magic of emacs: customized configuration files for emacs. The magic feature of emacs is the extensibility. Comparing to Vim, which is the specialist as a editor. Emacs is more like an single thread operating system which runs as an editor. In order to explore the magic, we start from the basic extended configurations for the emacs.

Normally, emacs configuration files locate in directory ~/.emacs.d or ~/.emacs. The help information for Minor mode and Major mode can be explored by pressing key C-h m.

M-x package-list-packages lists all the packages can be installed.

Sevearl packages I installed in my personal emacs configuration file: auto-complete

Here is my initial configuration file for emacs:

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
;;----------------------------------------
;; Disable & Enable modes
;;----------------------------------------
;; Added by Package.el. This must come before configurations of
;; installed packages. Don't delete this line. If you don't want it,
;; just comment it out by adding a semicolon to the start of the line.
;; You may delete these explanatory comments.
(require 'package)
(add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/"))
(package-initialize)
(global-linum-mode 1)
(tool-bar-mode -1)
;;----------------------------------------
;; Emacs theme
;;----------------------------------------
(load-theme 'dracula t)
;;----------------------------------------
;; Personal UI Setting
;;----------------------------------------
(setq cursor-type 'bar)
(setq inhibit-splash-screen 1)
;;----------------------------------------
;; Font
;;----------------------------------------
(set-default-font "Monaco 16")
;;----------------------------------------
;; New key binding
;;----------------------------------------
;; open init file
;;----------------------------------------
(defun open-init-file ()
(interactive)
(find-file "~/.emacs.d/init.el"))
(global-set-key (kbd "<f1>") 'open-init-file)
;;----------------------------------------
;; auto-complete
;;----------------------------------------
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(package-selected-packages (quote (dracula-theme auto-complete))))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)
(require 'auto-complete)
(require 'auto-complete-config)
(ac-config-default)

This will be extended in the future study.

emacs-learning-2

Posted on 2017-10-23

Emacs lisp

Emacs lisp is a dialect of Lisp language family used for script language in Emacs. For the pragraming process, it has similar machanism with lisp or mit-scheme (another dialect of Lisp). Since emacs lisp (Elisp for short) functions as a script language inside Emacs, it is necessary to learn Elisp for deeper understanding of Emacs and further hacking purpose.

Inside the emacs, the lisp repl can be invoked by switching to *scratch* buffer. (C-x b searches for the specific buffer. Default buffer will be *scratch*)

While interacting with Elisp, we can use C-x C-e or C-j to compile our procedure.

A useful reference provides more details and basic knowledge about Elisp.

Reverse polish notation is used for number calculations in Elisp:

1
2
3
4
(+ 2 2)
4
(+ 2 (* 3 4))
14

setq is used to create a new variable. insert is able to insert the string.

1
2
3
(setq my-name "Yang")
"Yang"
(insert "Hello " my-name)

Here, when we input C-x C-e, the lisp will insert string Hello Yang in the following of the insertcommand.

1
(insert "Hello " my-name)Hello Yang

defun can define a new function in the Elisp.

1
2
(defun func () (insert "Hello"))
(func)

switch-to-buffer-other-window is used to create a new window with specific buffer.

1
(switch-to-buffer-other-window "*test*") ;; switch to a buffer called *test*

progn combines multiple expressions into one expression.

1
2
3
4
(progn
(switch-to-buffer-other-window "*test*")
(hello)
(other-window 1))

let binds a value to a local variable.

1
2
(let ((local-name "yang"))
(hello local-name))

format is able to format a string with given format formula:

1
(format "hello %s!\n" "visitor")

Of course, there are some interative commands like read-from-minibuffer:

1
2
3
4
5
6
7
8
9
10
11
(read-from-minibuffer "Enter your name:")
;;; you can get variable name from prompt, such as
(defun greeting (from-name)
(let ((your-name (read-from-minibuffer "Enter your name: ")))
(insert (format "Hello!\n\nI am %s and you are %s."
from-name ; the argument of the function
your-name ; the let-bound var, entered at prompt
))))
;;; evaluate this command
(greeting "Jack")

In this post, it just summaries the basic opeartions from the link mentioned in the first paragraph. More functions or data-structure operations can be discovered in the future code reading.

emacs-learning-1

Posted on 2017-10-20

Emacas

I used to be a vim user for terminal coding. Not really a heavy user since I utilise Intellij for java development. But recently, I read the book called Structure and Interpretation of Computer Programs which explains the program in the deep level with Lisp. The path of Lisp learning arouses my interest Emacs, which provides EmacsLisp for functionality extension. As all we know, the Emacs is characterized by its extensibility.

Emacs stands for “the extensible, customizable, self-documenting, real-time display editor”. In order to try its special magic, the first step is to get familiar with its shortcuts.

Here is the summary for the common shortcuts listed in the emacs tutorial in Emacs (can be invoked by C-h t). A useful command is called C-h c + command to console the usage of the specific command. (For more detailed information, please use C-h k instead of C-h c)

C: stands for Control key. M: stands for Esc key.
Note, my development environment is based on mac laptop. M is replaced for Alt key on Windows computer.

Motion commands:

Key Description
C-v Move forward one screenful
M-v Move backward one screenful
C-l Clear screen and redisplay all the text, moving the text around the cursor to the centre of the screen
C-p Move to previous line
C-n Move to next line
C-b Move backward
C-f Move forward
M-b Move backward a word
M-f Move forward a word
C-a Move to the beginning of the line
C-e Move to the tail of the line
M-a Move to the beginnning of the sentence
M-e Move to the tail of the sentence
M-< Move to the beginning of the file
M-> Move to the end of the file
C-u + number + Operation Move forward/backward with specific number of lines/words/letters

C-u is valid for any opeartions. Even for character inputs. i.e. C-u 8 will insert 8 in the editor.

Frame Operations:

Many opeartons starts with C-x. Most of them are related with windows, files, buffers opeartions.

The bottom line is called minibuffer.

Key Description
C-g Discard commands
C-x + C-c Exit Emacs
C-x <number> Create some windows (i.e. kill all other windows)
C-x C-f Find a file
C-x C-s Save the file
M-x make-frame Create a new frame
M-x delete-frame Delete the selected frame

Buffer Operations:

Emacs stores all file text into a object called buffer

Key Description
C-x C-b List buffers
C-x b <BufferName> Switch to specific buffer with buffer name
C-x s Save some buffers
C-z Suspend Emacs temporarily
C-x o Switch to the other windows
C-x k Kill the current buffer
M-C-v Scroll the window in the other buffer

Editor Operations:

Key Description
<Delback> Delete the character before the cursor
C-d Delete the character afte rthe cursor
M-<Delback> Delete the word befor the cursor
M-d Delete next word after the c
C-k Kill from the cursor position to the end of the line
M-k Kill to the end of current sentence
C-@/C-<SPC> C-w Kill the context between the two positions
C-y Yank back the killed text. Reinset last killed text
M-y Yank the previous killed text.
C-/ / C-x u Undo previous with one/several command(s)
M-x repl s<TAB> Replace one string with another in the buffer
M-x recover-file Recover files from crashed computer
M-x fundamental-mode Switch back to fundamental mode
C-x f Set the width of margin
C-s Search forward
C-r Search backward

In increment search mode, use C-s and <DEL> to move back / forward for matched results.

My blog construction

Posted on 2016-11-09

Welcome to My personal blog! This is literally my first post on my first blog. I am going to introduce how I build this blog.

Two major tools are used:

  1. Hexo: a fast and simple blog framework. Very easy to develop and deploy personal blog, and it support markdown posts, which is my favorite note tool. Typora is recommended as a simple and clean markdown post editor.
  2. NexT theme: personal preference, an elegant and clean Hexo theme.

Requirement

  • Pre-downloaded Hexo repository

Construction

  1. In your site/Hexo repo directory, download NexT theme.

    1
    2
    $ cd your-hexo-site
    $ git clone https://github.com/iissnan/hexo-theme-next themes/next
  2. Configure NexT theme in Hexo directory. Apply NexT theme in _config.xml configuration file in root directory.

    1
    2
    3
    4
    5
    # Extensions
    ## Plugins: http://hexo.io/plugins/
    ## Themes: http://hexo.io/themes/
    # theme: landscape
    theme: next

    You can change different schemes based on your personal perference in _config.xml in theme directory. For example, scheme: Pisces can be applied in _config.xml file if you want to apply pisces scheme.

  3. Learn how to develop and publish Github Pages in Github.

  4. Generate static files and deploy your blog website to Github page.

    Configure deploy options in configuration file in root directory and use the following command.

    1
    $ hexo deploy
  5. Some other things like tag page or 404 page can also be set manually by following the official hexo guide.

Yangyang Liu

Yangyang Liu

The empty vessels make the greatest sound.

7 posts
5 tags
© 2019 Yangyang Liu
Powered by Hexo
Theme - NexT.Muse