Javascript replace all
function replaceAll(string, search, replace) { return string.split(search).join(replace); }
11 августа 2020, 11:09
function replaceAll(string, search, replace) { return string.split(search).join(replace); }
WITH T(StyleID, ID) AS (SELECT 1,1 UNION ALL SELECT 1,1 UNION ALL SELECT 1,1 UNION ALL SELECT 1,2) SELECT *, RANK() OVER(PARTITION BY StyleID ORDER BY ID) AS 'RANK', ROW_NUMBER() OVER(PARTITION BY StyleID ORDER BY ID) AS 'ROW_NUMBER', DENSE_RANK() OVER(PARTITION BY StyleID ORDER BY ID) AS 'DENSE_RANK' FROM T Returns StyleID ID RANK ROW_NUMBER DENSE_RANK ----------- -------- --------- --------------- ---------- 1 1 1 1 1 1 1 1 2 1 1 1 1 3 1 1 2 4 4 2
const currentDate = new Date("2020-07-28T17:23:47.568Z"); const dateSub = new Date(currentDate.getTime() + 1000); console.log(dateSub.toISOString());
docker run \ -e "NODE_ENV=production" \ -u "node" \ -m "300M" --memory-swap "1G" \ -w "/home/node/app" \ --name "my-nodejs-app" \ node [script]
sudo netstat -ltnp | grep -w ':80'
docker restart $(docker ps -a -q)
$file = new SplFileObject("file.txt"); while (!$file->eof()) { echo $file->fgets(); }
function lines($filename) { $file = new SplFileObject($filename); while (!$file->eof()) { yield $file->fgets(); } } foreach (lines('German.txt') as $line) { echo $line; }
import iuliia from "iuliia"; // list all supported schemas for (let schemaName of iuliia.Schemas.names()) { console.log(schemaName); } // transliterate using specified schema let source = "Юлия Щеглова"; iuliia.translate(source, iuliia.ICAO_DOC_9303); // "Iuliia Shcheglova" // or pick schema by name let schema = iuliia.Schemas.get("wikipedia"); iuliia.translate(source, schema); // "Yuliya Shcheglova"
diff -rq DIR1 DIR2
0.0.0.0 account.jetbrains.com 0.0.0.0 www.jetbrains.com 0.0.0.0 www-weighted.jetbrains.com
812LFWMRSH-eyJsaWNlbnNlSWQiOiI4MTJMRldNUlNIIiwibGljZW5zZWVOYW1lIjoi5q2j54mIIOaOiOadgyIsImFzc2lnbmVlTmFtZSI6IiIsImFzc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GhFyde05OdDtLpCv+jlWf5REAHHA201pAU6bJSZINyHDUTB+Beo28rRXSwSh3OUIvYwKNVeoBY+KwOJ7WnuTCUq1meE6GkKc4D/cXmgpOyW/1SmBz3XjVIi/zprZ0zf3qH5mkphtg6ksjKgKjmx1cXfZAAX6wcDBNaCL+Ortep1Dh8xDUbqbBVNBL4jbiL3i3xsfNiyJgaZ5sX7i8tmStEpLbPwvHcByuf59qJhV/bZOl8KqJBETCDJcY6O2aqhTUy+9x93ThKs1GKrRPePrWPluud7ttlgtRveit/pcBrnQcXOl1rHq7ByB8CFAxNotRUYL9IF5n3wJOgkPojMy6jetQA5Ogc8Sm7RG6vg1yow==
iptables -t nat -I OUTPUT -p tcp -o lo --dport 80 -j REDIRECT --to-ports 8080
ifconfig -a | grep ether | awk '{print $2}'
const collator = new Intl.Collator(undefined, { numeric: true, sensitivity: 'base' }); array.sort(collator.compare);
version: '3.1' services: jira: image: zhangguanzhang/atlassian-jira-software:8.0.0 container_name: jira8 restart: always environment: - "CATALINA_OPTS= -Xms1024m -Xmx4096m" links: - database volumes: - /home/jira8.0/data:/var/atlassian/jira - /home/jira8.0/logs:/opt/atlassian/jira/logs - /etc/localtime:/etc/localtime:ro ports: - '80:8080' database: restart: always container_name: jira8db image: percona:5.7 environment: - MYSQL_DATABASE=jira - MYSQL_USER=jira - MYSQL_PASSWORD=jira - MYSQL_ROOT_PASSWORD=jira volumes: - /home/jira8.0/db:/var/lib/mysql ports: - "127.0.0.1:3306:3306" command: - '--collation-server=utf8_bin' - '--character-set-server=utf8' - '--max_allowed_packet=34M' - '--innodb_log_file_size=256M'
docker-compose up -d --force-recreate --build
const WebSocket = require('ws'); const wss = new WebSocket.Server({ port: 8080 }); wss.on('connection', function connection(ws) { ws.on('message', function incoming(data) { wss.clients.forEach(function each(client) { if (client.readyState === WebSocket.OPEN) { client.send(data); } }); }); });Broadcasting excluding itself.
const WebSocket = require('ws'); const wss = new WebSocket.Server({ port: 8080 }); wss.on('connection', function connection(ws) { ws.on('message', function incoming(data) { wss.clients.forEach(function each(client) { if (client !== ws && client.readyState === WebSocket.OPEN) { client.send(data); } }); }); });
el.classList.add('show'); el.classList.remove('hide'); .show { transition: opacity 400ms; } .hide { opacity: 0; }source
file '/path/to/video/video.mp4' file '/path/to/video/video.mp4' file '/path/to/video/video.mp4' file '/path/to/video/video.mp4' file '/path/to/video/video.mp4'Run ffmpeg
ffmpeg -f concat -i playlist.txt -c copy output.mp4
docker inspect <container-id-or-name> | grep Gateway
copy for: 2508.226ms copy map: 1188.982ms copy spread: 1898.890ms
const map = [ [1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15] ]; const n = 10e6; console.time('copy for'); for (let i = 0; i < n; i++) { const m = []; for (let row = 0; row < map.length; row++) { m[row] = []; for (let reel = 0; reel < map[row].length; reel++) { m[row][reel] = map[row][reel]; } } } console.timeEnd('copy for'); console.time('copy map'); for (let i = 0; i < n; i++) { const m = map.map(a => a.map(item => item)); } console.timeEnd('copy map'); console.time('copy spread'); for (let i = 0; i < n; i++) { const m = map.map(a => [...a]); } console.timeEnd('copy spread');