Skip to content

Instantly share code, notes, and snippets.

View weakish's full-sized avatar

weakish weakish

View GitHub Profile
@weakish
weakish / doctest.md
Created November 4, 2018 15:33
#survey of #Ruby #doctest

Ruby Doctest

Doctest in Python is a good design. Doctest ensures code, documentation, and tests are in a single place. So readers can understand the logic of code easier, without a lot of navigation.

Unlike Python, Ruby does not have built-in doctest, but there are some third party libraries enabling doctest in Ruby.

@weakish
weakish / cli.md
Created November 4, 2018 15:32
#survey of #Ruby #cli #ui

Command line UI in Ruby

ruby -s

If you just want some switches, then you can use ruby -s:

Switches will be stored as global variable with true as their value:

#!/usr/bin/env ruby -s
@weakish
weakish / api-doc.md
Created November 4, 2018 15:30
#survey of #Ruby API #doc

Ruby API Doc

docco supports a lot of languages, including Ruby.

RDoc

Ruby's built in.

@weakish
weakish / dnd-5e-basic.md
Last active July 31, 2022 09:03
#DnD 5e basic guide

DnD 5e basic rules

Features

  1. Free for personal use.
  2. The three pillars of adventure are listed as exploration, social interaction, and combat. The Combat section itself is only 9 pages.
  3. Light rules covering 4 classes and 4 races, with an emphasis on DM (Dungeon Master) discretion. Complex bonus system is replaced with advantages and disadvantages. The PDF has 110 pages.
@weakish
weakish / ceylon-1_3.md
Created August 25, 2018 05:51
#ceylon 1.3 changes

What is new in Ceylon 1.3

Static members

When to use static members instead of toplevel methods or values:

  • when a function needs to access private members of a class
  • when a class needs to define private state or constants that are shared by all instances
@weakish
weakish / import.sh
Created August 11, 2018 18:11
copy #vivaldi browser bookmark file to current dir #sh
#!/bin/sh
os="$(uname)"
case "$os" in
'Linux')
cp "$HOME/.config/vivaldi/Default/Bookmarks" ./
;;
'Darwin')
cp "$HOME/Library/Application Support/Vivaldi/Default/Bookmarks" ./
@weakish
weakish / config
Created August 11, 2018 17:33
#socks #proxy for #ssh ~/.ssh/config
Host gist.github.com
User git
ProxyCommand nc -x localhost:1080 %h %p
@weakish
weakish / algorithms-to-live-by.md
Last active September 18, 2018 12:14
#afterwords on Algorithms to Live By

Brian Christian, Tom Griffiths. 2016-4-19. Algorithms to Live By[M]. He: Henry Holt and Co.. ISBN 9781627790369

这本书,算法科普得并不清楚,结合生活的部分又很啰嗦。不过这个思路是值得肯定的。有时候编程的时候知道用算法,一到生活中就忘了用。比如第3章“排序”,就提到让东西乱糟糟的有时反而是最高效的。编程的时候都知道,如果以后不搜索或极少搜索,那就没必要排序。但生活中有时却会不假思索地给东西排序,这其实是一种强迫症。再比如第4章“缓存”的LRU,用于归纳整理乃至丢弃物品很有用。以及第7章“过拟合”提到的更少的信息、计算和时间实际上有时能加快进度。还有第8章的“Relaxation”,例如,当你拿不定主意如何选择工作的时候,不妨假定每个工作的报酬都是一样的。以及最重要的第9章“随机性”,很多问题都可以通过随机方法解决。第7章、第8章、第9章简直就是我这样选择困难症的救星。

第2章“Explore/Exploit”没有考虑到探索潜在的奖励(惩罚):你更厌恶乏味还是不确定性?

第5章“规划”提到首先完成处理时间较短的任务能让你建立信心,从而加快进度。但有时候先完成难的、大的任务,会发觉容易的、小的任务不值得完成了。


@weakish
weakish / Haskell_The-Craft-of-Functional-Programming_3e.md
Last active August 27, 2017 15:59
#Haskell the Craft of #FunctionalProgramming (3e) #afterwords

Haskell:the Craft of Functional Programming (3rd. Edition)

This book is based on Haskell 2010.

It introduces features of Haskell in the following chapters:

  1. Chapter 13: type class
  2. Chapter 17: laziness
  3. Chapter 18: monad
  4. Chapter 19: DSL
@weakish
weakish / 金庸武侠武功选.md
Created August 24, 2017 12:49
#金庸 #武侠 小说 #武功 选
  • 神门十三剑(武当) 专刺手腕神门穴。

  • 柳絮剑法(慕容) 缓缓刺出,轻飘飘的没有声响。

  • 三分剑术(天山) 以快打慢,以变扰敌。每一手都只使到三分之一为止,未待对方招架,自己招术已变。一招中包含三招,最为繁杂凶狠。这派剑术没有守势,全都是进攻杀着。

  • 雨打飞花剑法(昆仑)