Combine default parameters and destructuring for a compact version of the defaults / overrides pattern.
function foo ({
bar = 'no',
baz = 'works!'
} = {}) {| /* | |
| UPDATE: This bug has been fixed, but be warned: | |
| concise methods and unnamed function expression assignments | |
| in object literals DO NOT make the function name | |
| available to reference inside the function body. | |
| If you want method recursion, always use a named | |
| function expression. | |
| */ |
| function compose() { | |
| var fns = Array.prototype.slice.call( arguments ); | |
| return function( arg ) { | |
| return fns.reduceRight(function( result, fn ) { | |
| return fn( result ); | |
| }, arg ); | |
| }; | |
| } | |
| function double( n ) { |
| # Current branch - Determine current git branch, store in $currentbranch, and exit if not on a branch | |
| if ! currentbranch=$(git symbolic-ref --short -q HEAD) | |
| then | |
| echo We are not currently on a branch. | |
| exit 1 | |
| fi | |
| # Uncommited Changes - Exit script if there uncommited changes | |
| if ! git diff-index --quiet HEAD --; then | |
| echo "There are uncommited changes on this repository." |
| { | |
| "scripts": { | |
| "test": "babel-node test-runner.js | tap-min && date|| true && date", | |
| "test:spec": "babel-node test-runner.js | tap-difflet || true && date", | |
| "test:watch": "watch 'npm run test' ./" | |
| }, | |
| "devDependencies": { | |
| "babel-core": "~6.2.1", | |
| "babel-preset-es2015": "~6.1.18", | |
| "babel-preset-stage-0": "~6.1.18", |
Looking for support tables for HTML/CSS/JavaScript features or details on their implementation status in major browsers?
And then there’s Can I use…?.
Please star ⭐️ the gist to help! This is a proposal for a ⚡️ talk at Reactive Conference.
I wrote react-toolbox and presented it almost a year ago in lighning talk at Reactive Conf 2015 in Bratislava. At first it was just a proof of concept of a component library styled with CSS Modules and SASS. Now the project has grown quite a bit, and during this year there has been tons of changes and lessons learned.
Theming and customization is one of the most difficult and interesting problems to solve. For the first version we needed a custom Webpack loader to generate themes and doing simple style overrides was very painful. Today I'm working on a new playground that will allow you try CSS Modules live, and to create React Toolbox themes on the f
| import requests | |
| import base64 | |
| from tqdm import tqdm | |
| master_json_url = 'https://178skyfiregce-a.akamaihd.net/exp=1474107106~acl=%2F142089577%2F%2A~hmac=0d9becc441fc5385462d53bf59cf019c0184690862f49b414e9a2f1c5bafbe0d/142089577/video/426274424,426274425,426274423,426274422/master.json?base64_init=1' | |
| base_url = master_json_url[:master_json_url.rfind('/', 0, -26) + 1] | |
| resp = requests.get(master_json_url) | |
| content = resp.json() |
Not all random values are created equal - for security-related code, you need a specific kind of random value.
A summary of this article, if you don't want to read the entire thing:
Math.random(). There are extremely few cases where Math.random() is the right answer. Don't use it, unless you've read this entire article, and determined that it's necessary for your case.crypto.getRandomBytes directly. While it's a CSPRNG, it's easy to bias the result when 'transforming' it, such that the output becomes more predictable.uuid, specifically the uuid.v4() method. Avoid node-uuid - it's not the same package, and doesn't produce reliably secure random values.random-number-csprng.You should seriously consider reading the entire article, though - it's
| 100+ different js counter apps... |