This file contains hidden or 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
function* fibonacci(n, current = 0, next = 1) { | |
if (n<1) | |
return 0; | |
yield current; | |
yield* fibonacci(n - 1, next, current + next) | |
} | |
const fib20 = fibonacci(20); |
This file contains hidden or 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
[Unit] | |
Description=Docker container cdn-redis | |
Requires=docker.service | |
After=docker.service | |
[Service] | |
Restart=always | |
RestartSec=3 | |
ExecStartPre=-/usr/bin/docker rm -f cdn-redis | |
ExecStart=/usr/bin/docker run --name=cdn-redis -v /data/cdn.ewf/redis:/data/cdn.ewf/redis cdn-redis:latest |
This file contains hidden or 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
String.prototype.repeat= function(n){ | |
n = n || 1; | |
return Array(n+1).join(this); | |
} | |
function sleep(delay) { | |
var start = new Date().getTime(); | |
while (new Date().getTime() < start + delay); | |
} |
This file contains hidden or 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
// Convert all words in uppercase to capitalized ones | |
var a = $('textarea').text().replace(/((?!ВКС|РФ|СМИ)([А-Я])([А-Я\-]+))/g, | |
function(match, p1, p2, p3) { return p2 + p3.toLowerCase() }); | |
$('textarea').text(a) |
This file contains hidden or 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
1 #! /usr/bin/bash | |
2 | |
3 query_exec () | |
4 { | |
5 # ssh -T for remote SSH connection | |
6 echo "$1" | mysql -uroot -proot -N test | |
7 } | |
8 | |
9 employees=$(query_exec 'SELECT id,id,firstname,lastname,age FROM `employee` test') | |
10 |
This file contains hidden or 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
# Remove the leading capital C letter from PHP filenames | |
for filename in $(find -type f -name "C*.php"); | |
do | |
new=$(echo $filename | sed -r 's/C([A-Z].*\.php)/\1/'); | |
echo $new; | |
git mv $filename $new; | |
done |
This file contains hidden or 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
PHP: | |
r00t:php# git log --format=%H --numstat --no-merges | awk 'NF==3 {plus+=$1; minus+=$2} END {printf("+%d, -%d, diff=%d, rate=%0.4f\n", plus, minus, plus-minus,minus/plus)}' | |
+10281181, -7373425, diff=2907756, rate=0.7172 | |
Linux kernel: | |
r00t:linux# git log --format=%H --numstat --no-merges | awk 'NF==3 {plus+=$1; minus+=$2} END {printf("+%d, -%d, diff=%d, rate=%0.4f\n", plus, minus, plus-minus,minus/plus)}' | |
+38145990, -20701172, diff=17444818, rate=0.542 | |