小编Edu*_*eda的帖子

使用Bootstrap v4对齐按钮

Bootstrap v4删除了.btn-group-justified该类,请参阅https://github.com/twbs/bootstrap/issues/17631

如何证明按钮的合理性:

 <div class="btn-group btn-group-justified" role="group" aria-label="Justified button group">
   <a class="btn btn-primary" href="#" role="button">Left</a>
   <a class="btn btn-primary" href="#" role="button">Middle</a>
   <a class="btn btn-primary" href="#" role="button">Right</a>
 </div>
Run Code Online (Sandbox Code Playgroud)

css twitter-bootstrap-4 bootstrap-4

32
推荐指数
3
解决办法
2万
查看次数

用于检查PID是否被僵尸的便携式shell解决方案

我想检查PID是否正在运行(即存在并且没有被僵尸).

它真的很快,/proc/$PID/stat但我想要一些更便携的东西.

我现在最好的是:

( STAT="$(ps -ostat= -p$PID)"; test "$STAT" -a "$STAT" "!=" "Z" )
Run Code Online (Sandbox Code Playgroud)

这似乎适用于BSD和Linux.有没有更好的办法?

unix shell pid sh

25
推荐指数
1
解决办法
465
查看次数

如何在Ruby中通过HTTP进行基本身份验证?

看了很多之后,我发现了一些似乎有效的解决方案,但对我来说并不适用......

例如,我有这个脚本:

require 'net/http'
require "net/https"

@http=Net::HTTP.new('www.xxxxxxx.net', 443)
@http.use_ssl = true
@http.verify_mode = OpenSSL::SSL::VERIFY_NONE
@http.start() {|http|
    req = Net::HTTP::Get.new('/gb/PastSetupsXLS.asp?SR=31,6')
    req.basic_auth 'my_user', 'my_password'
    response = http.request(req)
    print response.body
}
Run Code Online (Sandbox Code Playgroud)

当我运行它时,它会给我一个请求身份验证的页面,但是如果我在浏览器中编写以下URL,我会毫无问题地进入网站:

https://my_user:my_password@www.xxxxxxx.net/gb/PastSetupsXLS.asp?SR=31,6
Run Code Online (Sandbox Code Playgroud)

我也试过open-uri:

module OpenSSL
    module SSL
        remove_const :VERIFY_PEER
    end
end
OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE

def download(full_url, to_here)
    writeOut = open(to_here, "wb") 
    writeOut.write(open(full_url, :http_basic_authentication=>["my_user", "my_password"]).read) 
    writeOut.close 
end

download('https://www.xxxxxxx.net/gb/PastSetupsXLS.asp?SR=31,6', "target_file.html")
Run Code Online (Sandbox Code Playgroud)

但结果是一样的,该网站要求用户身份验证.我做错了什么提示?我必须在Base 64中编码密码吗?

ruby https basic-authentication

18
推荐指数
2
解决办法
3万
查看次数

茉莉花跑三次测试

我在我的开发盒上运行Karma/Jasmine/Angular 2.0测试.就在最近,我的开发盒上的Jasmine决定开始运行我的测试三次.是的,每次都是三次.

在第一次运行时,一切都按预期通过.但是,在第二次和第三次通过时,所有相同的事情都失败了.它总是承认有7个测试,但运行21个,10个失败(一级数学窗外)????

对于带有SauceLabs的Travis,这也失败了.(注意:通过3次测试链接到旧版本,但运行9次,5次失败???)

我有一个截图,karma.conf.js文件,以及一个启动整个事情的套件.非常感谢任何帮助.


罪魁祸首[TypeScript](删除此问题并在我的开发框中解决):

完整来源

describe('From the Conductor Service', () => {
    let arr: Array<ComponentStatusModel> = null;
    let svc: ConductorService = null;

    beforeEach(() => {  
        arr = [/* Inits the array*/];
        svc = new ConductorService();
    });

    describe('when it is handed a container to hold objects which need loaded', () => {
        // More passing tests...

        /// vvvvv The culprit !!!!!
        describe('then when you need to access the container', () => { …
Run Code Online (Sandbox Code Playgroud)

javascript unit-testing jasmine karma-runner angular

16
推荐指数
1
解决办法
1212
查看次数

React hook 表单不观察数组字段中的字段

我的反应挂钩表单中有一个字段数组,其中有一个复选框字段。我想观看该字段,但我只能观看整个数组字段,如下所示:

\n
const Period = ({ item, index, datepicker }) => {\n    const { control } = useFormContext<InntektFormValues>();\n    const value = useWatch({\n        control,\n        name: "incomes",\n    });\n\n\n    return value[index].selected datepicker : <div className="min-w-[160px]"></div>;\n};\n
Run Code Online (Sandbox Code Playgroud)\n

这是我映射字段数组的地方:

\n
export const IncomeTable = () => {\n    const { control } = useFormContext<IncomeFormValues>();\n    const incomeField = useFieldArray({\n        control,\n        name: "incomes",\n    });\n\n   \n    return ({incomes.fields.map((item, index) => (\n                    <TableRowWrapper\n                        key={item.id}\n                        cells={[\n                            <Period\n                                item={item}\n                                index={index}\n                                datepicker={\n                                    <FormControlledDatePicker\n                                        key={`incomes[${index}].from`}\n                                        name={`incomes[${index}].from`}\n                                        label="From"\n                                        placeholder="DD.MM.\xc3\x85\xc3\x85\xc3\x85\xc3\x85"\n                                        defaultValue={item?.from ?? null}\n                                        hideLabel\n                                    />\n                                }\n …
Run Code Online (Sandbox Code Playgroud)

reactjs react-hook-form

6
推荐指数
1
解决办法
3036
查看次数

Angular 2 ngOnChange和Input Binding不适用于动态添加的组件

ngOnChange生命周期方法和输入绑定不适用于动态添加Angular`` Components using ViewContainerRef.createComponent.

http://plnkr.co/edit/MBYdMP?p=preview

export class StaticChildComp implements OnChanges {
  @Input() public value: any;
  @Output() public valueChange:EventEmitter = new EventEmitter();

  change() {
    this.valueChange.emit(this.value);
  }

  ngOnChanges(changes: {}): any {
    console.log("From Static Child:" + JSON.stringify(changes));
  }
}

@Component({
  selector: 'dynamic-child-comp',
  template: `
    <input type="text" [(ngModel)]="value" (change)="change($event)"/>
  `,
  inputs: ["value"],
  outpus: ["valueChange"]
})
export class DynamicChildComp extends StaticChildComp {
  ngOnChanges(changes: {}): any {
    console.log("From Dynamic Child:" + JSON.stringify(changes));
  }
}


@Component({
  selector: 'parent-comp',
  template: `

    <span>What Parent can see: …
Run Code Online (Sandbox Code Playgroud)

angular

5
推荐指数
0
解决办法
880
查看次数

使用Angular2的Webpack Hot Reload?

我有一个最奇怪的问题与webpack热重载中间件和角度2 ..我有一个简单的index.html <my-app></my-app>.我的webpack配置也非常简单.它在下面.

我的应用程序是HMR文档的克隆版(http://andrewhfarmer.com/webpack-hmr-tutorial/);

app.use(webpackDevMiddleware(compiler, {
    hot: true,
    filename: 'bundle.js',
    publicPath: '/',
    stats: {
        colors: true,
    },
    historyApiFallback: true
}));

app.use(webpackHotMiddleware(compiler, {
    log: console.log,
    path: '/__webpack_hmr',
    heartbeat: 10 * 1000
}));
Run Code Online (Sandbox Code Playgroud)

在第一次加载时,这很有效.应用程序出现了,index.html就<script type="text/javascript" src="http://localhost:3000/main.js"></script>在其中.然后我在应用程序中更改某些内容作为测试,我可以在控制台中看到webpack成功重建,但浏览器不会更新.所以我尝试重新加载,应用程序停留在加载横幅上,因为脚本标记似乎完全消失了.

谁看过这个吗?有什么想法我可以让它工作?

var webpack = require('webpack');
var helpers = require('./webpack.helpers');
var autoprefixer = require('autoprefixer');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var CopyWebpackPlugin = require('copy-webpack-plugin');

module.exports = {
    devtool: 'eval-source-map',
    entry: [
        'webpack-hot-middleware/client?path=/__webpack_hmr&timeout=20000',
        './src/client/polyfills.ts',
        './src/client/vendor.ts',
        './src/client/main.ts'
    ],
    module: {
        preLoaders: [
            {test: /\.ts$/, loader: 'tslint'} …
Run Code Online (Sandbox Code Playgroud)

javascript webpack webpack-hmr angular

5
推荐指数
0
解决办法
3394
查看次数

模块'UploaderModule'导入的意外值'FileUploadModule' - ng2-file-upload

使用angular 2.0.1(发布)和ng2-file-upload 1.1.0(最新版本)运行此代码时出现上述错误.我正在使用带有systemjs的jspm来捆绑我的应用程序(所有这些都是最新的).

import {Component, NgModule} from '@angular/core';
import {CommonModule} from '@angular/common';
import {FileUploadModule} from 'ng2-file-upload';

@Component({
  selector: 'uploader',
  templateUrl: '/build/templates/uploader.html'
})
export class UploaderComponent {
    uploader = new FileUploader({url: '/upload'});
    hasBaseDropZoneOver = false;

    fileOverBase(event) {
        this.hasBaseDropZoneOver = event;
    }

    clearQueue() {
        this.uploader.clearQueue();
    }
}

console.log(FileUploadModule);

@NgModule({
    imports: [CommonModule, FileUploadModule],
    declarations: [UploaderComponent],
    exports: [UploaderComponent]
})
export class UploaderModule {};
Run Code Online (Sandbox Code Playgroud)

如果我检查FileUploadModule的值,它看起来非常好,就像它看起来就像我检查过的所有其他模块一样.我的应用程序中还有其他所有功能,但这一部分.这个模块的"意外"是什么?

完整错误:

错误:(SystemJS)模块'UploaderModule'(...)导入的意外值'FileUploadModule'

这是FileUploadModule导出的相对部分,对我来说很好

var FileUploadModule = (function() {
  function FileUploadModule() {}
  FileUploadModule = __decorate([core_1.NgModule({
    imports: [common_1.CommonModule],
    declarations: [file_drop_directive_1.FileDropDirective, file_select_directive_1.FileSelectDirective],
    exports: …
Run Code Online (Sandbox Code Playgroud)

systemjs jspm angular

5
推荐指数
0
解决办法
1853
查看次数

将Angular 2 Universal Starter部署到Azure App Service

有没有人下载过Angular 2 Universal Starter,执行"npm run build",创建客户端文件夹和服务器文件夹,然后将其部署到Azure?

如果是这样,我真的想要一些关于如何继续进行的指示,因为我在google有多难以找到没有人做过... ...-)

azure universal angular

5
推荐指数
0
解决办法
710
查看次数

在使用ng-packagr创建的角度4组件库中使用外部javaScript库

在Nikolas LeBlanc的这篇优秀文章的帮助下,我正在尝试创建一个Angular 4组件库:

https://medium.com/@nikolasleblanc/building-an-angular-4-component-library-with-the-angular-cli-and-ng-packagr-53b2ade0701e

问题是这个...我的库依赖于外部JavaScript文件 - 让我们调用它somefunctions.js.

在常规的Angular 4应用程序中 - 我已经能够通过引用文件中的angular-cli.json文件来完成此操作:

  "scripts": [
      "./app/js/somefunctions.js"
  ],
Run Code Online (Sandbox Code Playgroud)

...然后声明变量类型anytypings.d.ts的文件.

这使得JavaScript文件可供应用程序使用,并且它可以正常工作.

但是 - 我的目标是创建一个Angular 4组件库,并将其打包/发布到npm.

当我按照创建库的说明进行操作时 - 功能模块没有打包somefunctions.js.

所以 - 如果其他人安装我的模块,他们将不会somefunctions.js,并且它显然不会工作.

所以,我想我需要知道如何告诉ng-packagr捆绑模块,使其包含somefunctions.js,以及如何设置我的模块,以便我的代码可以在其他应用程序中安装模块时引用该文件.

提前致谢!

javascript angular ng-packagr

5
推荐指数
0
解决办法
277
查看次数