Wednesday, March 29, 2017

Emacs Web Server


Emacs Web Server

http://nullprogram.com/blog/2009/05/17/
     May 17, 2009

 The server log is lisp itself. Here is an example log starting the server, serving one request, and halting,
'(log
  (start "Wed May 13 23:33:34 2009")
  (connection
   (date "Wed May 13 23:36:25 2009")
   (address "192.168.0.3")
   (get "/0001.html")
   (req
    ("Referer" "http://192.168.0.2:8080/")
    ("Connection" "keep-alive")
    ("Keep-Alive" "300")
    ("Accept-Charset" "ISO-8859-1,utf-8;q=0.7,*;q=0.7")
    ("Accept-Encoding" "gzip,deflate")
    ("Accept-Language" "en-us,en;q=0.5")
    ("Accept" "image/png,image/*;q=0.8,*/*;q=0.5")
    ("User-Agent" "Mozilla/5.0 [...] Iceweasel/3.0.9 (Debian-3.0.9-1)")
    ("Host" "192.168.0.2:8080")
    ("GET" "/0001.html" "HTTP/1.1"))
   (path "~/public_html/0001.html")
   (status 200))
  (stop "Wed May 13 23:38:17 2009"))

--

simple-httpd and impatient-mode

Thursday, March 23, 2017

Cinnamon shortcut

* Cinnamon shortcut

The Complete List Of Linux Mint 18 Keyboard Shortcuts For Cinnamon by Gary Newell 
Updated March 23, 2017

1. Toggle Scale - List All Applications On Current Workspace (CTRL, ALT, DOWN)
2. Toggle Expo - List All Applications On All Workspaces (CTRL, ALT, UP)
3. Cycle Through Open Windows (ALT, TAB) (SHIFT, ALT, TAB)
4. Open The Run Dialog (ALT, F2)
5. Troubleshooting Cinnamon (SUPER, L)
6. Maximise A Window (ALT, F10)
7. UnMaximise A Window (ALT, F5)
8. Close A Window (ALT, F4)
9. Move A Window (ALT, F7)
10. Show The Desktop (SUPER, D)
11. Show The Window Menu (ALT, SPACE)
12. Resize A Window (ALT, F8)
13. Tile A Window To The Left (SUPER, LEFT) (CTRL, SUPER, LEFT)
14. Tile A Window To The Right (SUPER, RIGHT) (CTRL, SUPER, RIGHT)
15. Tile A Window To The Top (Super, UP) (CTRL, SUPER, UP)
16. Tile A Window To The Bottom (SUPER, DOWN) (CTRL, SUPER, DOWN)
17. Move A Window To A Workspace To The Left (SHIFT, CTRL, ALT, LEFT)
18. Move A Window To A Worksapce To The Right (SHIFT, CTRL, ALT, RIGHT)
19. Move A Window To The Left Monitor (SHIFT, SUPER, LEFT)
20. Move A Window To The Right (SHIFT, SUPER, RIGHT)
21. Move A Window To The Top Monitor (SHIFT, SUPER, UP)
22. Move A Window To The Bottom Monitor (SHIFT, SUPER, DOWN)
23. Move To The Workspace To The Left (CTRL ALT, LEFT)
24. Move To The Workspace To The Right (CTRL, ALT, RIGHT)
25. Log Out (CTRL, ALT, DELETE)
26. Shut Down The System (CTRL, ALT, END)
27. Lock The Screen (CTRL, ALT, L)
28. Restart The Cinnamon Desktop (CTRL, ALT, ESCAPE)
29. Take A Screenshot Of Part Of The Screen (SHIFT, PRTSC) (CTRL, SHIFT, PRTSC)
30. Take A Screenshot (PRTSC) (CTRL, PRTSC)
31. Take A Screenshot Of A Window (ALT, PRTSC) (CTRL, ALT, PRTSC)
32. Record The Desktop (SHIFT, CTRL, ALT, R)
33. Open A Terminal Window (CTRL, ALT, T)
34. Open The File Explorer At Your Home Folder (SUPER, E)

Thursday, March 16, 2017

fcitx language, xim setting, Gnome Key change

* fcitx language, xim setting, Gnome Key change
   [[file:img/fcitx_lang.png]]

 리눅스 우분투 키 시퀀스 변경은은 2곳에서 설정하는 데,

1. 주메뉴 [시스템 설정] > Hardware [Keyboard] > [Shortcuts] 탭 > "Typing" [List Menu)
   ( [시스템 설정] > Hardware [Keyboard] > [Typing] 탭의 "Text Entry" 을 선택해도 된다 )
   - Switch to next source: Super+Space
   - Siwtch to previous source: Shift + Super +Space
   [[file:img/fcitx_system_key.png]]

2. fcitx 설정에서 변경
   Fcitx [Icon] 실행 혹은 Configure Fcitx [mouse light popup menu]
     -> Input Method [tab]
        -> Pinyin [list select]
            -> Global Config [Tab]
                -> Trigger Input Method [item]
                   change from: "Ctrl+Space" --> to "Shift+Space"
                -> Scroll between Input Method: Ctrl_Shift
    [[file:img/fcitx_config.png]]

3. Emacs key sequence 변경
   (만약 emacs 에서 사용하는 키가 시스템에서 정의한 키와 중복될 경우 먼저 제거한다)

#+name: dot emacs
#+begin_src elisp
;; <leim> 을 사용할 경우 require (required korea-util.el and hangul.el)
;; <S-Hangul> --> toggle-korean-input-method from korea-util.el
;; [한자]키 --> toggle-korean-input-method hangul-to-hanja-conversion from hangul.el

;; <fcitx> 를 사용할 경우 --> fcitx -> change fcitx and system key sequence
;; 1. in [fcitx config]
;;    a. [Trigger Input Method] from [Control-SPACE] to [Shift-Space]
;;    b. Scroll between Input Method: Control+Sift
;;
;; 2. in [system kebyaord sequence setting]
;;    Next source (fcitx): [Super-Space]
;;    Switch to previous source (fcitx): [Super+Space+Space]

;(global-set-key (kbd "S-SPC") 'toggle-input-method)
;(global-set-key (kbd "S-SPC") 'toggle-korean-input-method)
(global-unset-key (kbd "S-SPC")) ; leave it to fcitx [Trigger Input Method]
(global-set-key (kbd "C-SPC") 'set-mark-command) ; constomize

;(define-key global-map [(control meta ?r)] 'remember)

(global-set-key [(shift meta q)] 'rebox-cycle)
;(global-set-key (kbd "C-c r r")  'my-put-file-name-on-clipboard)
(global-set-key (kbd "C-x C-f")  'find-file) ; ido-find-file

;(global-set-key [?\M-j] 'ido-display-buffer)
;(global-set-key (kbd "C-x x f") 'ido-find-file)
(global-set-key (kbd "<C-f1>")  (lambda()(interactive) (kill-this-buffer)))

(add-hook 'bs-mode-hook 'turn-on-font-lock) ; bs.el
(global-set-key (kbd "C-%") 'replace-regexp)
;(global-set-key [(meta _)] 'sh-switch-to-process-buffer)

(global-unset-key "\M-q")
(global-set-key (kbd "M-q q") 'fill-paragraph)
(global-set-key (kbd "M-q w") 'unfill-paragraph)

(global-set-key (kbd "C-c t t")  'delete-trailing-whitespace)
(global-set-key (kbd "C-c t f")  'flush-blank-lines)
#+end_src

Wednesday, March 08, 2017

How to enable Nginx FancyIndex on Ubuntu

> From: How to enable Nginx FancyIndex on Ubuntu


sudo apt-get install nginx-extras

location / {
fancyindex on;
fancyindex_exact_size off;
}
Read more about Nginx FancyIndex:
  • http://wiki.nginx.org/NgxFancyIndex
  • https://github.com/aperezdc/ngx-fancyindex

Tuesday, March 07, 2017

SQLite Source Code Blocks in Org Mode



SQLite Source Code Blocks in Org Mode--> http://orgmode.org/worg/org-contrib/babel/languages/ob-doc-sqlite.html

# -*- coding: utf-8 -*-
#+STARTUP: content
#+LANGUAGE: ko
#+PROPERTY: header-args:sqlite :dir ~/org/ :db journal.db :var rel="cur" :results line :colnames yes

: header arguments -> :csv, :column, :line, :list, :html
: results -> silent raw
: separator \

※ 1. File scope variable which is name "#+PROPERTY" can be located any location of file.
※ 2. "#+PROPERTY" var will be initialize when file opening time.
    (therefore, if you modify "#+PROPERTY" it can be use until reopen the file again!)

* sqlite org babel

  [[http://orgmode.org/worg/org-contrib/babel/languages/ob-doc-sqlite.html][guide_from orgmode.org]]

** emacs babel setup
#+TITLE: dot
#+begin_src elisp
(org-babel-do-load-languages
 'org-babel-load-languages (quote ((emacs-lisp . t)
                                    (sqlite . t)
                                    (R . t)
                                    (python . t))))
#+end_src

** Org Mode Features for SQLite Source Code Blocks
Header Arguments
Language-specific default values

There are no language-specific default header arguments for SQLite.

** Language-specific header arguments
   There are 11 SQLite-specific header arguments. 

db
    a string with the name of the file that holds the SQLite database. Babel requires this header argument.
header
    if present, turn on headers in the output format. Headers are also output with the header argument :colnames yes.
echo
    if present, set the SQLite dot command .echo to ON.
bail
    if present, set the SQLite dot command .bail to ON.
csv
    the default SQLite output format for Babel SQLite source code blocks.
column
    an SQLite output format that outputs a table-like form with whitespace between columns.
html
    an SQLite output format that outputs query results as simple HTML tables.
line
    an SQLite output format that outputs query results with one value per line.
list
    an SQLite output format that outputs query results with the separator character between fields.
separator
    a string that specifies the separator character used by the SQLite `list' output mode and by the SQLite dot command .import.
nullvalue
    a string to use in place of NULL values. 

** Variables
  It is possible to pass variables to sqlite. Variables can be of type table or scalar. Variables are defined using :var=<value> and referred in the code block as $<name>.

Table variables
    Table variables are exported as a temporary csv file that can then be imported by sqlite. The actual value of the variable is the name of temporary csv file.
Scalar variables
    This is a value that will replace references to variable's name. String variables should be quoted; otherwise they are considered a table variable.

** Sessions
  SQLite sessions are not supported.

** Result Types
   SQLite source code blocks typically return the results of a query. The header arguments :csv, :column, :line, :list, and :html determine the output format.

: #+PROPERTY: header-args:sqlite :dir ~/org/ :db org.db :results list


* sample create
: #+name: sqlite-populate-test
: #+header: :results line
: #+header: :dir ~/tmp/
: #+header: :db hello.db
: #+begin_src sqlite
: create table greeting(one varchar(10), two varchar(10));
: insert into greeting values('Hello', 'world!');
: #+end_src

#+begin_src sqlite
create table greeting(one varchar(10), two varchar(10));
insert into greeting values('Hello', 'world!');
#+end_src


* sample query
: #+name: sqlite-hello
: #+header: :list
: #+header: :separator \ 
: #+header: :results raw
: #+header: :dir ~/tmp/
: #+header: :db hello.db
: #+begin_src sqlite
: select * from greeting;
: #+end_src

#+begin_src sqlite
select * from greeting;
#+end_src

#+RESULTS:
| one   | two    |
|-------+--------|
| Hello | world! |


* Using scalar variables

** using local var.
#+BEGIN_SRC sqlite :db ~/org/journal.db :var rel="tname" n=300 :colnames yes
drop table if exists $rel;
create table $rel(n int, id int);
insert into $rel(n,id) values (1,210), (3,800);
select * from $rel where id > $n;
#+END_SRC

#+RESULTS:
| n |  id |
|---+-----|
| 3 | 800 |



** usign file var.
#+BEGIN_SRC sqlite :var n=300 
drop table if exists $rel;
create table $rel(n int, id int);
insert into $rel(n,id) values (1,210), (3,800);
select * from $rel where id > $n;
#+END_SRC

#+RESULTS:
| n |  id |
|---+-----|
| 3 | 800 |



* Using table variables

  We can also pass a table to a query. In this case, the contents of the table are exported as a csv file that can then be imported into a relation:


** local var.

#+NAME: tableexample
| id |  n |
|----+----|
|  1 |  5 |
|  2 |  9 |
|  3 | 10 |
|  4 |  9 |
|  5 | 10 |

#+begin_src sqlite :db ~/org/journal.db :var orgtable=tableexample :colnames yes
drop table if exists testtable;
create table testtable(id int, n int);
.mode csv testtable
.import $orgtable testtable
select n, count(*) from testtable group by n;
#+end_src

#+RESULTS:
|  n | count(*) |
|----+----------|
|  5 |        1 |
|  9 |        2 |
| 10 |        2 |


** using global file var.
#+begin_src sqlite :var orgtable=tableexample
drop table if exists testtable;
create table testtable(id int, n int);
.mode csv testtable
.import $orgtable testtable
select n, count(*) from testtable group by n;
#+end_src

#+RESULTS:
|  n | count(*) |
|----+----------|
|  5 |        1 |
|  9 |        2 |
| 10 |        2 |

Pranten

 Pranten