Skip to main content

Kenyth Zeng's Library tagged programming   View Popular

26 Sep 09

Blocks and Closures in Ruby

This is one part of the three-part interview.

www.artima.com/closures.html - Preview

ruby programming interview toread

  • called higher order function style
  • But in
    Ruby, any method can be called with a block as an implicit argument. Inside the method,
    you can call the block using the yield keyword with a value.
  • 2 more annotations...

Bash Reference Manual

  • The preamble is prefixed to each string contained within the braces, and
    the postscript is then appended to each resulting string, expanding left
    to right.
18 Sep 09

HOWTO: Layout Django Apps @ Scott’s Repository Brew

  • in general different settings between production vs development. This makes it hard to keep track of the settings for production vs pre-production and the development instances.
  • These applications should contain no configuration that needs to be changed between installations.
  • 2 more annotations...

PEP 257 -- Docstring Conventions

  • "A universal convention supplies all of maintainability, clarity,
    consistency, and a foundation for good programming habits too.
    What it doesn't do is insist that you follow it against your will.
    That's Python!"
  • some software (such as the Docutils [4] docstring processing
    system [1] [2]) will be aware of the conventions, so following them
    will get you the best results.
  • 3 more annotations...

PEP 8 -- Style Guide for Python Code

  • One of Guido's key insights is that code is read much more often than it
    is written.
  • Two good reasons to break a particular rule:

    (1) When applying the rule would make the code less readable, even for
    someone who is used to reading code that follows the rules.

    (2) To be consistent with surrounding code that also breaks it (maybe for
    historic reasons) -- although this is also an opportunity to clean up
    someone else's mess (in true XP style).
  • 28 more annotations...

PEP 20 -- The Zen of Python

  • The Zen of Python


        Beautiful is better than ugly.
    Explicit is better than implicit.
    Simple is better than complex.
    Complex is better than complicated.
    Flat is better than nested.
    Sparse is better than dense.
    Readability counts.
    Special cases aren't special enough to break the rules.
    Although practicality beats purity.
    Errors should never pass silently.
    Unless explicitly silenced.
    In the face of ambiguity, refuse the temptation to guess.
    There should be one-- and preferably only one --obvious way to do it.
    Although that way may not be obvious at first unless you're Dutch.
    Now is better than never.
    Although never is often better than *right* now.
    If the implementation is hard to explain, it's a bad idea.
    If the implementation is easy to explain, it may be a good idea.
    Namespaces are one honking great idea -- let's do more of those!



    Easter Egg


        >>> import this

Comment out a python code block - Stack Overflow

  • Is there any mechanism to comment out large blocks of Python code? Right
    now the only ways I can see of commenting out code are to either start
    every line with a #, or to enclose the code in """ (triple quotes),
    except that actually makes it show up in various doc tools.
  • all Real Python Programmers use ed, where this problem is easily solved with: 12,31s/^/#/
  • 1 more annotations...
07 Sep 09

Tabs versus Spaces

  • To get vim to interpret tab
    as an ``indent'' command instead of an insert-a-tab command, do this:


      set softtabstop=2


    To set the mod-N indentation used when you hit the tab key
    in vim (what Emacs calls c-basic-offset), do this:


      set shiftwidth=2


    To cause the TAB file-character to be displayed as
    mod-N in vi and vim (what Emacs calls tab-width),
    do this:


      set tabstop=4


    To cause TAB characters to not be used in the file for compression,
    and for only spaces to be used (what emacs calls
    indent-tabs-mode), do this:


      set expandtab
04 Sep 09

How do I indent multiple lines quickly in vi? - Stack Overflow

  • Use the > command. To indent 5 lines, 5>>. To mark a block of lines and indent it, Vjjj> to indent 3 lines (vim only). To indent a curly-braces block, put your cursor on one of the curly braces and use >%.



    If you're copying blocks of text around and need to align the indent of a block in its new location, use ]p instead of just p. This aligns the pasted block with the surrounding text.

10 Aug 09

Java的多进程运行模式分析 - 51CTO.COM

  • 我们需要通过java代码启动多个java子进程。这样做虽然占用了一些系统资源,但会使程序更加稳定,因为新启动的程序是在不同的虚拟机进程中运行的,如果有一个进程发生异常,并不影响其它的子进程。
  • Runtime中的exec方法执行java classname。如果执行成功,这个方法返回一个Process对象
  • 1 more annotations...
13 Jul 09

Windows Programming/Message Loop Architecture - Wikibooks, collection of open-content textbooks

  • lpszArgument essentially contains all the information that the argc and argv variables used to show, except that the command-line arguments are not broken up into a vector.
    • WinMain has a number of different jobs:



      1. Register the window classes to be used by the program
      2. Create any Windows used by the program
      3. Run the message loop
  • 7 more annotations...

飙高音(译文) - 阮一峰的网络日志

  • 最快的学生做题的速度,比普通学生快三到四倍,比最慢的学生快十倍。标准差之大非常惊人。
  • 作业的质量与所花费的时间基本上是不相关的。
  • 2 more annotations...
1 - 20 of 45 Next › Last »
Showing 20 items per page

Highlighter, Sticky notes, Tagging, Groups and Network: integrated suite dramatically boosting research productivity. Learn more »

Join Diigo