├── .gitignore ├── README.rst ├── css └── use_css_hinters_linters.rst ├── js └── use_jsbin_for_ajax_requests.rst └── python └── use_coverage_with_unittest.rst /.gitignore: -------------------------------------------------------------------------------- 1 | # Mac cruft 2 | .DS_Store 3 | 4 | # TextMate 5 | .tm_properties 6 | 7 | # Don't commit drafts 8 | drafts/ 9 | -------------------------------------------------------------------------------- /README.rst: -------------------------------------------------------------------------------- 1 | ====== 2 | how-to 3 | ====== 4 | 5 | A set of quick 1-page how-to guides. 6 | 7 | These are really just notes that I write for myself, to aid my own memory and 8 | learning. 9 | -------------------------------------------------------------------------------- /css/use_css_hinters_linters.rst: -------------------------------------------------------------------------------- 1 | ================================== 2 | How to Use CSS Hinters and Linters 3 | ================================== 4 | 5 | CSS hinters and linters help you find and fix problems with your CSS. 6 | 7 | Installation 8 | ------------ 9 | 10 | Install the linters that you want:: 11 | 12 | $ npm install csslint -g 13 | $ npm install prettycss -g 14 | $ [sudo] npm install recess -g 15 | 16 | Recess 17 | ------ 18 | 19 | Run Recess to find some problems:: 20 | 21 | $ recess project/assets/css/example.css 22 | 23 | Analyzing the following files: project/assets/css/example.css 24 | 25 | FILE: project/assets/css/example.css 26 | STATUS: Busted 27 | FAILURES: 1 failure 28 | 29 | Incorrect property order for rule ".someclass" 30 | 31 | Correct order below: 32 | 33 | 12. position: fixed; 34 | 13. top: 3em; 35 | 14. right: 4em; 36 | 37 | I can't find built docs on the set of rules that Recess uses, but if you look 38 | at the docstrings in https://github.com/twitter/recess/tree/master/lib/lint, 39 | they're described there. 40 | 41 | CSSLint 42 | ------- 43 | 44 | Run CSSLint to find other problems:: 45 | 46 | $ csslint project/assets/css/example.css 47 | 48 | csslint: There are 1 problems in project/assets/css/example.css. 49 | 50 | example.css 51 | 1: warning at line 18, col 3 52 | Fallback color (hex or RGB) should precede RGBA color. 53 | color: rgba(255,255,255,0.5); 54 | 55 | CSSLint rules: https://github.com/stubbornella/csslint/wiki/Rules 56 | 57 | PrettyCSS 58 | --------- 59 | 60 | Run PrettyCSS to find even more problems:: 61 | 62 | $ prettycss project/assets/css/example.css 63 | There were 0 errors and 2 warnings detected. 64 | Warning: You should use a relative unit instead of px (1px, line 22, char 16) 65 | Warning: You should use a relative unit instead of px (-1px, line 22, char 20) 66 | 67 | PrettyCSS error/warning reference: https://github.com/fidian/PrettyCSS/blob/master/docs/ErrorsAndWarnings.md 68 | 69 | Makefiles and Linters 70 | --------------------- 71 | 72 | You can use a Makefile to run several linters with one command. 73 | 74 | Create a file called `Makefile` that contains this:: 75 | 76 | lint: 77 | recess project/assets/css/example.css 78 | csslint project/assets/css/example.css 79 | prettycss project/assets/css/example.css 80 | 81 | .. warning:: Use tabs in `Makefile`, not spaces! Spaces don't work. 82 | `Makefiles` are the only place in any project where tabs are okay. 83 | 84 | What Next? 85 | ---------- 86 | 87 | Here are some suggestions on what to do next. 88 | 89 | * Configure the linters to ignore certain rules, if you want. 90 | * Set up Grunt tasks to run the linters. See http://gruntjs.com 91 | -------------------------------------------------------------------------------- /js/use_jsbin_for_ajax_requests.rst: -------------------------------------------------------------------------------- 1 | ========================================== 2 | How To Use JSBin For Testing AJAX Requests 3 | ========================================== 4 | 5 | Set up 2 bins: 6 | 7 | Bin 1: JSON 8 | ----------- 9 | 10 | Create a new bin. Paste the JSON response that you'd like to test against in JS. 11 | 12 | Delete the HTML. You should see Output change to be identical to the JSON in JS. 13 | 14 | The URL for the simulated JSON response is now the URL of the bin, e.g. http://jsbin.com/ipamut/. 15 | 16 | Bin 2: Your Code 17 | ---------------- 18 | 19 | Create a 2nd bin. Code as usual. 20 | 21 | In your AJAX request in JS, use the URL from earlier. For example:: 22 | 23 | d3.json("http://jsbin.com/ipamut/", function(json) { 24 | ... 25 | } 26 | 27 | That's it. 28 | -------------------------------------------------------------------------------- /python/use_coverage_with_unittest.rst: -------------------------------------------------------------------------------- 1 | ==================================== 2 | How To Use Coverage.py With Unittest 3 | ==================================== 4 | 5 | This is adapted from: 6 | * http://nedbatchelder.com/code/coverage/ 7 | 8 | Install It 9 | ---------- 10 | 11 | First, install Coverage.py: 12 | 13 | .. code-block:: bash 14 | 15 | pip install coverage 16 | 17 | Gather Data 18 | ----------- 19 | 20 | Run your test suite, but replace `python blah blah` with `coverage blah blah` 21 | and specify a source directory. 22 | 23 | For example: 24 | 25 | .. code-block:: bash 26 | 27 | coverage run --source cookiecutter setup.py test 28 | 29 | Ideally your tests should be outside of your source directory, so that you 30 | don't have to configure excludes or package them. It's much neater that way. 31 | 32 | Print Coverage Reports 33 | ---------------------- 34 | 35 | Command-Line Report 36 | ~~~~~~~~~~~~~~~~~~~ 37 | 38 | To print a quick command line report, maximize your command prompt and type: 39 | 40 | .. code-block:: bash 41 | 42 | coverage report -m 43 | 44 | HTML Report 45 | ~~~~~~~~~~~ 46 | 47 | To print a fancier HTML report: 48 | 49 | .. code-block:: bash 50 | 51 | coverage html 52 | open html_cov/index.html 53 | 54 | Set Up Coveralls 55 | ---------------- 56 | 57 | Sign up for Coveralls.io with your GitHub account. Click [Add Repo] and add 58 | the repo for which you want a badge. 59 | 60 | Here you'll use `coveralls-python`_. 61 | 62 | Add this to `.travis.yml` in the corresponding spots: 63 | 64 | .. code-block:: yaml 65 | 66 | install: 67 | - pip install coveralls 68 | 69 | # change from 'script: python setup.py test' to this 70 | script: coverage run --source cookiecutter setup.py test 71 | 72 | after_success: 73 | coveralls 74 | 75 | Then when you push, after Travis finishes building, check your Coveralls 76 | account for the results. 77 | 78 | .. _`coveralls-python`: https://github.com/coagulant/coveralls-python 79 | --------------------------------------------------------------------------------