pipe

Get argument from pipe

不打扰是莪最后的温柔 提交于 2020-02-27 05:30:47
问题 Consider having the results from the pipe: find . Now I would like to access in the second command behind the pipe what is actually piped (inputed) and then for example to print it twice. find . | printf $arg$arg\n #each filename would be printed twice per line Please note that the question is not asking about printing whatever once gets from pipe twice, I know how to use bash for loop or write a script that could accomplish the mentioned. How I can get $arg to use it quickly in inline

gulp 搭建静态服务器

无人久伴 提交于 2020-02-26 12:49:37
步骤: 安装依赖:npm i browser-sync --save-dev 导入browser-sync,通过create创建 设置Sass和Js任务,将其压缩重命名并引入页面,任务结束时reload服务 设置默认任务,此任务负责,初始化服务器,监视setJs和setCss的变化 var gulp = require("gulp"); var browser = require("browser-sync").create(); var concat = require("gulp-concat"); var rename = require("gulp-rename"); var sass = require("gulp-sass"); var minifyCss = require("gulp-minify-css"); var uglify = require("gulp-uglify"); gulp.task("setJs",()=>{ gulp.src("./src/js/*.js") .pipe(concat("c.js")) .pipe(uglify()) .pipe(rename("c.min.js")) .pipe(gulp.dest("./dist")) .on("end",browser.reload); }); gulp.task("setSass",()

Bash: grep pattern from command output

点点圈 提交于 2020-02-26 08:12:39
问题 I'm really new with bash, but it's one of the subjects on school. One of the exercises was: Give the line number of the file "/etc/passwd" where the information about your own login is. Suppose USERNAME is my own login ID, I was able to do it perfectly in this way: cat /etc/passwd -n | grep USERNAME | cut -f1 Which simply gave the line number required (there may be a more optimised way). I wondered however, if there was a way to make the command more general so that it uses the output of

Bash: grep pattern from command output

妖精的绣舞 提交于 2020-02-26 08:12:28
问题 I'm really new with bash, but it's one of the subjects on school. One of the exercises was: Give the line number of the file "/etc/passwd" where the information about your own login is. Suppose USERNAME is my own login ID, I was able to do it perfectly in this way: cat /etc/passwd -n | grep USERNAME | cut -f1 Which simply gave the line number required (there may be a more optimised way). I wondered however, if there was a way to make the command more general so that it uses the output of

rxjs6 控制虚线长度

那年仲夏 提交于 2020-02-26 03:21:21
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <script src="./rxjs.umd.js"></script> <style> .box { } </style> </head> <body> <input type="checkbox" id="check"> <div class="box" id="box"> </div> <script> const {range, interval, fromEvent} = rxjs; const {map,tap, mergeMap, mapTo, filter, throttleTime, debounceTime, repeat, switchMap, takeUntil} = rxjs.operators; const box = document.getElementById('box') const check = document.getElementById('check') const change$ = fromEvent(check, 'change').pipe( // map(x => x.target.checked), // filter(x => x === true) )

rxjs6 Utility Operators

余生颓废 提交于 2020-02-25 23:21:35
Utility Operators tap 用于执行副作用的函数 interval(100).pipe( take(3), tap(v => console.log('tap', v)) ).subscribe(v => console.log('sub', v)) // tap 0 // sub 0 // tap 1 // sub 1 // tap 2 // sub 2 delay 在流开始的时候延时执行 let st = +new Date() interval(100).pipe( delay(200) ).subscribe(v => { let ed = +new Date() console.log('sub', v, ed - st) st = ed }) // sub 0 303 // sub 1 99 // sub 2 102 // sub 3 102 delayWhen 延迟到内层流输出数据 let st = +new Date() interval(100).pipe( // delay(200) delayWhen(() => interval(200)) ).subscribe(v => { let ed = +new Date() console.log('sub', v, ed - st) st = ed }) // sub 0 303 // sub

rxjs6 Filtering Operators

老子叫甜甜 提交于 2020-02-25 18:43:39
debounce / debounceTime 防抖, 一直输入的情况下, 只有输入间隔大于200ms时发送数据, 减少无用请求数 change$.pipe( debounce(() => interval(200)) ).subscribe(console.log) change$.pipe( debounceTime(200) ).subscribe(console.log) distinct 去重, 可以传入一个 keySelector 的函数 // 1,2,3 of(1, 2, 1, 2, 3).pipe( distinct() ).subscribe(console.log) // { name: 'a' } { name: 'b' } of( {name: 'a',}, {name: 'b'}, {name: 'a'} ).pipe( distinct(v => v.name) ).subscribe(console.log) distinctUntilChanged 完整的去重需要维护一个set, 为了节省内存, 可以只和上一个比较, 常用于已经排序的情况 of( {age: 4, name: 'Foo'}, {age: 7, name: 'Bar'}, {age: 5, name: 'Foo'}, {age: 6, name: 'Foo'}, ).pipe(

Gulp自动添加版本号

本小妞迷上赌 提交于 2020-02-23 05:21:18
推荐使用 gulp-rev + gulp-rev-collector 是比较方便的方法,结果如下: "/css/style.css" => "/dist/css/style-1d87bebe.css" "/js/script1.js" => "/dist/script1-61e0be79.js" "cdn/image.gif" => "//cdn8.example.dot/img/image-35c3af8134.gif" 但是由于公司发布系统限制,如果用上面方法实现,每次更新都会积压过多过期无用的文件,我们预期效果是: "/css/style.css" => "/dist/css/style.css?v=1d87bebe" "/js/script1.js" => "/dist/script1.js?v=61e0be79" "cdn/image.gif" => "//cdn8.example.dot/img/image.gif?v=35c3af8134" 怎么破?改上面两个Gulp插件是最高效的方法了。 安装Gulp npm install --save-dev gulp 分别安装gulp-rev、gulp-rev-collerctor npm install --save-dev gulp-rev npm install --save-dev gulp-rev-collector

How to redirect input in Powershell without BOM?

时光怂恿深爱的人放手 提交于 2020-02-22 04:24:07
问题 I am trying to redirect input in Powershell by Get-Content input.txt | my-program args The problem is the piped UTF-8 text is preceded with a BOM (0xefbbbf), and my program cannot handle that correctly. A minimal working example: // File: Hex.java import java.io.IOException; public class Hex { public static void main(String[] dummy) { int ch; try { while ((ch = System.in.read()) != -1) { System.out.print(String.format("%02X ", ch)); } } catch (IOException e) { } } } Then in powershell javac

How to redirect input in Powershell without BOM?

∥☆過路亽.° 提交于 2020-02-22 04:18:34
问题 I am trying to redirect input in Powershell by Get-Content input.txt | my-program args The problem is the piped UTF-8 text is preceded with a BOM (0xefbbbf), and my program cannot handle that correctly. A minimal working example: // File: Hex.java import java.io.IOException; public class Hex { public static void main(String[] dummy) { int ch; try { while ((ch = System.in.read()) != -1) { System.out.print(String.format("%02X ", ch)); } } catch (IOException e) { } } } Then in powershell javac