Click "raw" below to install. Requires Google Chrome, Firefox + Greasemonkey, or some other browser supporting user scripts / content scripts / user javascript.
= Problem =
timeit.timeit()
doesn't let you pass local vars to the code to be timed.
= Solution =
(pdb) !import sys, timeit
(Pdb) !dv = (lambda sys=sys: (lambda **kw: setattr(sys.modules['__main__'], 'VARS', kw)))()
(Pdb) !tt = lambda s, sys=sys: sys.stdout.write('%.3g ms\n' % timeit.timeit(s, 'import sys; self = sys.modules["__main__"].SELF', number=10)/10.*1000)
Uses capped collection, tailable cursors and streams.
- init.js recreates collection capped collection 'queue' on mongodb.
- writer.js spams queue with new messages
- worker.js processes all messages saved to queue,
- onceWorker.js processes only unprocessed messages, so you can spawn several of them and each of your messages will be processed by only one worker.
{ | |
"test": ["foo", "bar"], | |
"child": { | |
"grandchild": 12345 | |
}, | |
"sibling": "sibling value", | |
"awkwardly/named~variable": true | |
} |
# to generate your dhparam.pem file, run in the terminal | |
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048 |
title | slug | createdAt | language | preview |
---|---|---|---|---|
Unit testing Angular.js app with node.js, mocha, angular-mocks and jsdom |
unit-testing-angular-js-app-with-node |
2015-07-05T18:04:33Z |
en |
Majority of search result about unit testing Angular.js apps is about how to do it by using test frameworks that run the tests in a real browser. Even though it's great to be able to test your code in multiple platforms, in my opinion it creates a lot of boilerplate code and makes it hard to run the tests in, for instance a CI-server. |
Lean unit tests with minimal setup
Sometimes you may want to undo a whole commit with all changes. Instead of going through all the changes manually, you can simply tell git to revert a commit, which does not even have to be the last one. Reverting a commit means to create a new commit that undoes all changes that were made in the bad commit. Just like above, the bad commit remains there, but it no longer affects the the current master and any future commits on top of it.
git revert {commit_id}
Deleting the last commit is the easiest case. Let's say we have a remote origin with branch master that currently points to commit dd61ab32. We want to remove the top commit. Translated to git terminology, we want to force the master branch of the origin remote repository to the parent of dd61ab32:
Copyright 2020 Aubrey Taylor | |
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | |
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTH |