UP | HOME

感谢那些照顾过我的人,也谢谢那些伤害过我的人,让我成为这样一个人。

Learn Programming Language from Diving into Source Code

1. Master Core Functions

ID: 4df69bd2-3b91-4f61-ab75-a7bf83761e1b
PUBDATE: <2019-08-14 Wed 19:09>

If you're a beginner on learning Programming Language, mastering some core and frequently used functions is really helpful. This can let you write better code.

This thought is comes from book <Clojure Standard Library: An annotated reference>. I get a free chance to choose an ebook after filled a form from Manning Publications. (I choose this book because I'm learning Clojure, need to master basic of Clojure as a beginner.)

2. Dive into Language Source Code

ID: fe16cda6-4303-41ca-9a35-48a8b1e6c854
PUBDATE: <2019-08-14 Wed 19:09>

Programming Language usually has a mechanism to check out source code. For example, Emacs Lisp, it can use M-. to jump to function definition. Clojure is same. About other languages like Python, Ruby etc. In Emacs also can use M-. or Emacs extensions to support this.

3. Search code examples on public source code hosting websites

ID: 225b3e31-c8e2-4e48-b725-1584a3f0dcdf
PUBDATE: <2019-08-14 Wed 19:09>

Learning with examples is helpful for beginner, you can search code on public source code hosting websites. Here is my collected list:

Rosetta Code
Rosetta Code is a programming chrestomathy site. The idea is to present solutions to the same task in as many different languages as possible, to demonstrate how languages are similar and different, and to aid a person with a grounding in one approach to a problem in learning another. Rosetta Code currently has 874 tasks, 223 draft tasks, and is aware of 687 languages, though we do not (and cannot) have solutions to every task in every language.
CoCycles
search for open source code by functionality.
Sourcegraph
search for code, docs, and usage examples.
(no term)
https://github.com/search
(no term)
https://bitbucket.org/
(no term)
https://cloud.google.com/tools/cloud-repositories/
(no term)
https://www.codeplex.com/
(no term)
https://gitorious.org/
(no term)
https://code.google.com/
SourceForge
The Complete Open-Source Software Platform. Create, collaborate & distribute to over 33 million users worldwide.
(no term)
http://freecode.com/
(no term)
https://gitlab.com/public
(no term)
https://www.openhub.net/
(no term)
http://sources.debian.net/
(no term)
https://codesearch.debian.net/

3.1. Emacs package engine-mode

ID: 6c3ffd6f-1c43-490e-ac65-528c3f03c6dd

Emacs has a package called "engine-mode" which can define search engine based on URL by replacing query keyword with "%s". It is quite quick to use it to open a search query in web browser. Even can use thing-at-point to get word or symbol at point to avoid manually input.

3.1.1. how to define engine

ID: 5771d61a-a49c-49f8-9f9e-d5b762857537
  1. simple
    ID: b1d53db2-70c9-400a-8068-87b2b0b59bb4
    
    (defengine github
      "https://github.com/search?ref=simplesearch&q=%s")
    
  2. specify key
    ID: b4d6e855-00e6-4919-8aa0-2d34bc58f76c
    
    (defengine duckduckgo
      "https://duckduckgo.com/?q=%s"
      :keybinding "d")
    
  3. specify browser function
    ID: cf89a876-7da0-48fc-a1cb-e58270fbead2
    
    (defengine github
      "https://github.com/search?ref=simplesearch&q=%s"
      :browser 'eww-browse-url)
    
  4. specify docstring
    ID: 7c1d115d-c6c7-4bab-aff6-7aa570211df2
    
    (defengine ctan
      "http://www.ctan.org/search/?x=1&PORTAL=on&phrase=%s"
      :docstring "Search the Comprehensive TeX Archive Network (ctan.org)")
    

3.1.2. my config part

ID: a8323cd7-a7c8-4347-9e4b-9cffff2c569f
;; general search engines
(defengine google
  "http://www.google.com/search?ie=utf-8&oe=utf-8&q=%s"
  ;; "http://www.google.com/search?q=%s"
  :docstring "Google"
  :keybinding "g")
(defengine duckduckgo
  "https://duckduckgo.com/?q=%s"
  :docstring "DuckDuckGo"
  :keybinding "d")
(defengine blekko
  "https://blekko.com/#?q=%s"
  :docstring "Blekko"
  ;; :keybinding "B"
  )
(defengine bing
  "http://cn.bing.com/search?q="
  :docstring "Bing")
(defengine baidu
  "http://www.baidu.com/s?wd=%s"
  :docstring "Baidu"
  :keybinding "b")

;; Wikipedia
(defengine wikipedia
  "http://www.wikipedia.org/search-redirect.php?language=en&go=Go&search=%s"
  :docstring "Wikipedia"
  :keybinding "w")
(defengine baidu_baike
  "http://baike.baidu.com/search/none?word=%s"
  :docstring "Baidu Baike"
  :keybinding "W")
(defengine wolfram-alpha
  "http://www.wolframalpha.com/input/?i=%s"
  :docstring "Wolfram Alpha"
  :keybinding "A")

;; programming

;; Docs: API
(defengine APIs
  "http://apis.io/?search=%s"
  :docstring "APIs"
  :keybinding "a")
(defengine mozilla-developer
  "https://developer.mozilla.org/en-US/search?q=%s"
  :docstring "Mozilla Developer"
  :keybinding "m")
(defengine rfcs
  "http://pretty-rfc.herokuapp.com/search?q=%s"
  ;; "https://www.rfc-editor.org/search/rfc_search_detail.php?rfc=%s"
  :docstring "RFC"
  :keybinding "R")
(defengine emacswiki
  "www.emacswiki.org/emacs?search=%s"
  :docstring "Emacs Wiki"
  :keybinding "e")

4. More tips will updated on this post

ID: b38fbf60-66e3-4c18-8069-769b0bc656db
PUBDATE: <2019-08-14 Wed 19:09>

If anyone suggest more skill tips about learning from diving into source code. I will add them at this post.