This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://jsfiddle.net/antonfisher/qky16fp3/ | |
// For human: | |
/** | |
* Get Array key by percentage | |
* | |
* getArrayKeyByPercent(["a", "b", "c"], 0) ==> "a" | |
* getArrayKeyByPercent(["a", "b", "c"], 50) ==> "b" | |
* getArrayKeyByPercent(["a", "b", "c"], 90) ==> "c" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Usage: | |
* $npm install shelljs | |
* $node split-vs-sed.js | |
*/ | |
/** | |
* Results: | |
* | |
* $ node split-vs-sed.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## | |
# Check directory | |
# $1 {String} - path | |
# $2 {Number} - show error | |
# | |
# @returns {Number} 0 - exists / 1 - not exists | |
# | |
# Example: | |
# check_directory_exits /tmp 1; | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## | |
# Get full file/directory path | |
# | |
# Examples: | |
# full_path=$(get_full_path '/tmp'); # /tmp | |
# full_path=$(get_full_path '~/..'); # /home | |
# full_path=$(get_full_path '../../../'); # /home | |
# | |
# @param {String} $1 - relative path | |
# @returns {String} absolute path |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
while true; do | |
arecord -r 44100 -c 1 2>/dev/null | ssh [email protected] "cat > /tmp/record.fifo"; | |
sleep 1; | |
done; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var extJsTT = { | |
button: { | |
click: function () {}, | |
is: { | |
enabled: function () {}, | |
}, | |
wait: { | |
is: { | |
enabled: function () {}, | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git checkout --orphan docs | |
git rm -rf . | |
git reset | |
git add ... | |
git push | |
git co master |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var ActiveDirectory = require('activedirectory'); | |
var ad = new ActiveDirectory({ | |
url: 'ldap://10.10.10.10', | |
baseDN: 'dc=domain,dc=com', | |
username: 'Administrator', | |
password: 'kokoko' | |
}); | |
ad.findUser('', function (err, user) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* | |
* Search with tree vs filter() | |
* | |
* Generate data file: | |
* echo "module.exports = [" > /tmp/data.js; for n in {1..1000000}; do echo "\"bk-${n}\"," >> /tmp/data.js; done; echo "]" >> /tmp/data.js; | |
* | |
* Run search: | |
* node --max-old-space-size=4096 ./fulltext-prefix-search-tree-vs-filter.js | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* | |
* Search value with tree vs filter() | |
* | |
* Generate data file: | |
* echo "module.exports = [" > /tmp/data.js; for n in {1..1000000}; do echo "\"bk-${n}\"," >> /tmp/data.js; done; echo "]" >> /tmp/data.js; | |
* | |
* Run search: | |
* node --max-old-space-size=4096 ./prefix-search-tree-vs-filter.js | |
* |
OlderNewer