Skip to content

Instantly share code, notes, and snippets.

@yihangho
yihangho / index.markdown
Last active May 9, 2016 13:58
Rails Best Practice
  1. master branch is always deployable.
  2. Cut a new branch off master whenever working on something new.
  3. When you're ready, either merge the feature branch back into master or make a PR if you want your code reviewed.
  4. Commit and push often.
  5. Source code is always open-sourceable (i.e., do not commit API keys, private keys, etc).
    • API keys: use environment variables (set them in .bashrc or .zshrc).
    • Private keys: ignore using .gitignore.
  6. Always write tests. If possible, make the tests as comprehensive as possible. Otherwise, treat them as sanity tests (i.e., to make sure nothing is obviously broken).
  7. Whenever a bug is discovered, write test for it before fixing it (i.e., practice TDD when shit hits the fan).
  8. Use only the seven default actions (index, new, create, show, edit, update, destroy) in controllers. DHH.

Keybase proof

I hereby claim:

  • I am yihangho on github.
  • I am yihangho (https://keybase.io/yihangho) on keybase.
  • I have a public key whose fingerprint is 4BE3 D8D2 3DEA BEE9 6E0B 6BA4 E71E 9BF2 FD9A 6A84

To claim this, I am signing this object:

def successor((x,y),X,Y):
return set([
(0,y), # empty X
(x,0), # empty Y
(X,y), # fill X
(x,Y), # fill Y
(0,y+x) if x+y<=Y else (x-(Y-y), y+(Y-y)), # X->Y
(x+y,0) if x+y<=X else (x+(X-x), y-(X-x)), # Y->X
]) - set([(x,y)]) # remove self
#ifdef DEBUG
#define debug printf("Debug: ");printf
#else
#define debug //
#endif
#include <cstdio>
int main()
{