What is the best way to inject a value into the middle of arguments?
- Would prefer it to be a one liner
- Need it to be really fast!
JSPerf here: http://jsperf.com/inject-into-arguments
Of the two below "slice-and-concat.js" is 12% faster in Chrome.
| div[data-preference="card-management"]:before { | |
| content:""; | |
| display: block; | |
| position: absolute; | |
| left: 0; | |
| top: 61px; | |
| width: 100%; | |
| height: 6px; | |
| -webkit-background-size: 50px 50px, 100%; |
| ::-webkit-scrollbar { | |
| -webkit-appearance: none; | |
| width: 7px; | |
| } | |
| ::-webkit-scrollbar-thumb { | |
| border-radius: 4px; | |
| background-color: rgba(0,0,0,.5); | |
| -webkit-box-shadow: 0 0 1px rgba(255,255,255,.5); | |
| } |
| # http://stackoverflow.com/questions/592620/check-if-a-program-exists-from-a-bash-script | |
| command -v foo >/dev/null 2>&1 || { echo >&2 "I require foo but it's not installed. Aborting."; exit 1; } | |
| type foo >/dev/null 2>&1 || { echo >&2 "I require foo but it's not installed. Aborting."; exit 1; } | |
| hash foo 2>/dev/null || { echo >&2 "I require foo but it's not installed. Aborting."; exit 1; } |
What is the best way to inject a value into the middle of arguments?
JSPerf here: http://jsperf.com/inject-into-arguments
Of the two below "slice-and-concat.js" is 12% faster in Chrome.
| module HashConverter | |
| class << self | |
| def to_underscore hash | |
| convert hash, :underscore | |
| end | |
| def to_camel_case hash | |
| convert hash, :camelize, :lower | |
| end | |
| def convert obj, *method | |
| case obj |
| var Denby = require('denby'); | |
| var Mustache = require('mustache'); | |
| /** | |
| * new DenbyMustache(options) | |
| * - options (Object): Configuration options. | |
| * | |
| * See [DenbyMustache#options] and [Denby#options] for more information. | |
| **/ | |
| function DenbyMustache(options) { |
| document.addEventListener('keydown', function(e) { | |
| window.lol = window.lol || 0; | |
| window.lol++; | |
| console.log(lol); | |
| }, false); |
| #!/bin/sh | |
| if git-rev-parse --verify HEAD >/dev/null 2>&1 ; then | |
| against=HEAD | |
| else | |
| # Initial commit: diff against an empty tree object | |
| against=4b825dc642cb6eb9a060e54bf8d69288fbee4904 | |
| fi | |
| # Find files with trailing whitespace | |
| for FILE in `exec git diff-index --check --cached $against -- | sed '/^[+-]/d' | sed -E 's/:[0-9]+:.*//' | uniq` ; do |
| // Removes craigslist listings for portland suburbs | |
| $('blockquote font[size="-1"]').each(function(i, element) { | |
| var text = element.textContent.trim(); | |
| if (text.match(/Gresham|Beaverton|Troutdale|Wilsonville|Sellwood|WOODLAND/i)) { | |
| $(element.parentNode).hide(); | |
| } | |
| }); |
| // 1. Collect our modules, using the specified directories... | |
| require('modulr').build('client', | |
| { | |
| isPackageAware: true, | |
| paths: ['.','./node_modules'], | |
| }, | |
| function(e, result) { | |
| if (e) { | |
| throw e; | |
| } |