小编Osc*_*yes的帖子

C#如何正确制作http web GET请求

我仍然是c#的新手,我正在尝试为这个页面创建一个应用程序,告诉我何时收到通知(回答,评论等等).但是现在我只是想简单地调用api来获取用户的数据.

我正在使用Visual Studio express 2012来构建C#应用程序,其中(现在)您输入了您的用户ID,因此应用程序将使用用户ID发出请求并显示此用户ID的统计信息.

这是我正在尝试发出请求的代码:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
//Request library
using System.Net;
using System.IO;

namespace TestApplication
{
    class Connect
    {
        public string id;
        public string type;

        protected string api = "https://api.stackexchange.com/2.2/";
        protected string options = "?order=desc&sort=name&site=stackoverflow";

        public string request()
        {
            string totalUrl = this.join(id);

            return this.HttpGet(totalUrl);
        }

        protected string join(string s)
        {
            return api + type + "/" + s + options;
        }

        protected string get(string url)
        {
            try
            {
                string rt; …
Run Code Online (Sandbox Code Playgroud)

.net c# httpwebrequest

97
推荐指数
4
解决办法
30万
查看次数

github,sourcetree获得未经授权的错误

我是github的新手,我使用sourcetree为我的git gui,我已经使用了几天,但现在最近我得到一个错误,说

remote: Invalid username or password.
fatal: Authentication failed for 'https://github.com/Nosthertus/nodejs_Chat.git/'
Run Code Online (Sandbox Code Playgroud)

当我试图再次向github注册时返回错误

authorization failed
Run Code Online (Sandbox Code Playgroud)

也许是因为我做了一个双因素安全,我想用github制作一个shh-key,但是没有解决问题,必须有一种方法让我的gui连接到我的github帐户而无需登录访问,如何我能解决这个问题吗?

git atlassian-sourcetree

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

Gradle:无法在Intellij中设置未知属性'classDumpFile'

我一直在通过互联网搜索并询问irc聊天,但他们都没有或没有给出任何答案来试图解决我的问题.

我试图让我的项目JaCoCoIntellijIDE 上使用,测试将在Jenkins服务器中完成,我已经在我的gradle.build文件中设置了一些设置,JaCoCo但是编译失败说Could not set unknown property 'classDumpFile' for object of type org.gradle.testing.jacoco.plugins.JacocoTaskExtension.

构建文件是这样的:

version '1.0-SNAPSHOT'

apply plugin: 'java'
apply plugin: 'jacoco'

sourceCompatibility = 1.8
targetCompatibility = 1.8

repositories {
    mavenCentral()
}

jacoco{
    toolVersion = '0.7.6.201602180812'
}

dependencies {
    testCompile group: 'junit', name: 'junit', version: '4.12'
    testCompile group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.5'
    compile group: 'mysql', name: 'mysql-connector-java', version: '5.1.6'
    compile group: 'org.json', name: 'json', version: '20180130'
}
test{
    jacoco { …
Run Code Online (Sandbox Code Playgroud)

java intellij-idea gradle jacoco

11
推荐指数
2
解决办法
9038
查看次数

Angularjs:$ scope.emit不起作用

我是新手,angularjs我正在创建一个Web应用程序来获得经验和实践.我的问题是,$scope.$emit似乎没有工作,我正在寻找方法来联系控制器之间的功能,到目前为止,我已经在互联网上找到$scope.emit并且$scope.on似乎适合这种任务,如果有另一种方式,我我想知道,反正代码写得像这样:

loginController.js

(function(angular)
{
    var app = angular.module('Organizer');

    // inject $scope to the controller in order to try $scope.$emit
    app.controller('login', function($http, $scope)
    {
        // i define the scope like this so i can access inside other functions
        var scope = this;
        scope.processing = false;
        scope.message = null;

        scope.submit = function()
        {
            scope.processing = true;

            // store data for post
            var post = {
                username: scope.username,
                password: scope.password
            };

            // send post data …
Run Code Online (Sandbox Code Playgroud)

angularjs angular-material

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

RESTful响应如何在Yii2中返回JSON而不是XML?

问题是来自Yii2中RESTful服务器的响应以XML形式返回,我需要它们采用JSON格式.

我按照Yii2的指南,控制器看起来一样,模型有点不同,它连接到数据库(模型以前是从高级模板中的默认模型复制的),而web配置也是一样的像指南.

只是为了澄清任何疑问,这里是代码:

UserController.php

<?php
namespace app\controllers;

use yii\rest\ActiveController;

class UserController extends ActiveController
{
    public $modelClass = 'app\models\User';
}
Run Code Online (Sandbox Code Playgroud)

web.php($ config)

$config = [
    'id' => 'basic',
    'basePath' => dirname(__DIR__),
    'bootstrap' => ['log'],
    'components' => [
        'request' => [
            // !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
            'cookieValidationKey' => 'WgkzlqvStTfGXY-ToFlQIJRDMX4LUQtY',
            'parsers'=>[
                'application/json'=>'yii\web\JsonParser'
            ]
        ],
        'cache' => [
            'class' => 'yii\caching\FileCache',
        ],
        'user' => [
            'identityClass' => 'app\models\User',
            'enableAutoLogin' …
Run Code Online (Sandbox Code Playgroud)

yii2

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

AWS:Lambda 权限策略可以有来自目标组的带有通配符的源吗?

我目前正在尝试将大部分 lambda 集成与 cloudformation 堆栈中的负载平衡器设置,并且我正在向 lambda 函数添​​加权限以允许lambda:InvokeFunction来自 elbv2 目标组的操作,所以我想有权限中的 sourceArn 是这样的:

arn:aws:elasticloadbalancing:eu-west-1:######:targetgroup/*/*
Run Code Online (Sandbox Code Playgroud)

在这一点上,我只是在没有在堆栈中添加目标组资源的情况下进行测试,但是在 cloudformation 中进行部署并检查 lambda 函数的组成方式后,aws 显示错误:

An error occurred while listing alb relations: 'arn:aws:elasticloadbalancing:eu-west-1:#######:targetgroup/*/*' is not a valid target group ARN (Service: AmazonElasticLoadBalancing; Status Code: 400; Error Code: ValidationError; Request ID: 2ec4bd65-816b-11e9-b1a8-3d113de48409)
Run Code Online (Sandbox Code Playgroud)

lambda 中的策略结果是这样组成的:

{
  "Version": "2012-10-17",
  "Id": "default",
  "Statement": [
    {
      "Sid": "project-dev-FixturesDashgetAllLambdaPermission-17SATFJ9GT266",
      "Effect": "Allow",
      "Principal": {
        "Service": "elasticloadbalancing.amazonaws.com"
      },
      "Action": "lambda:InvokeFunction",
      "Resource": "arn:aws:lambda:eu-west-1:######:function:project-dev-fixtures-getAll",
      "Condition": {
        "ArnLike": {
          "AWS:SourceArn": "arn:aws:elasticloadbalancing:eu-west-1:#######:targetgroup/*/*"
        }
      }
    }
  ]
} …
Run Code Online (Sandbox Code Playgroud)

amazon-web-services aws-cloudformation aws-lambda

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

Android Studio:活动预览不显示标题栏

我知道这个问题是在这里之前提出的,但是我已经尝试了给出的解决方案,但我没有像设备那样以确切的样式获得预览外观。

我正在使用Android版本4.2.2上的Samsung Galaxy S3 mini进行设备调试,它是完全未修改的,但是我不明白为什么,即使更改主题,设备仍然看起来相同(在当然是活动)

活动的代码就像任何新的空白活动一样

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
    android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity">

    <TextView android:text="@string/hello_world" android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

预览看起来像这样 在此处输入图片说明

但是设备看起来像这样 在此处输入图片说明

PS:我正在学习android,所以我可能会与答案混淆

android android-titlebar android-studio

5
推荐指数
2
解决办法
6878
查看次数

打字稿:使用ts-node-dev导入表达意外的Idenfitier

我正在开始一个新项目,Typescript我想typescript使用制作节点服务器express。我一直在关注有关如何运行Typescript文件而不必在此链接中编译文件的教程:https : //medium.com/javascript-in-plain-english/typescript-with-node-and-express-js-为什么何时以及如何使用eb6bc73edd5d

我现在面临的问题是,在执行运行的脚本时ts-node-dev,会引发错误:

> vidursyn@0.0.0 server:start /home/oscar/Documents/vidursyn
> ts-node-dev --respawn --transpileOnly ./src/server/app.ts

Using ts-node version 7.0.1, typescript version 3.2.4
/home/oscar/Documents/vidursyn/src/server/app.ts:1
(function (exports, require, module, __filename, __dirname) { import express from "express";
                                                                     ^^^^^^^

SyntaxError: Unexpected identifier
    at new Script (vm.js:80:7)
    at createScript (vm.js:274:10)
    at Object.runInThisContext (vm.js:326:10)
    at Object.obj.(anonymous function) [as runInThisContext] (/home/oscar/Documents/vidursyn/node_modules/ts-node-dev/lib/hook.js:30:19)
    at Module._compile (internal/modules/cjs/loader.js:664:28)
    at Module._compile (/home/oscar/Documents/vidursyn/node_modules/source-map-support/source-map-support.js:517:25)
    at Module.m._compile (/tmp/ts-node-dev-hook-9240179406846312.js:56:25)
    at Module._extensions..js (internal/modules/cjs/loader.js:712:10)
    at require.extensions.(anonymous function) (/tmp/ts-node-dev-hook-9240179406846312.js:58:14) …
Run Code Online (Sandbox Code Playgroud)

node.js express typescript ts-node

4
推荐指数
1
解决办法
1417
查看次数

从另一个GameObject的脚本设置转换

我正在尝试创建一个脚本来设置实例化时的对象.问题是,我不清楚如何做到这一点.我有这个功能..

function spawnPlayer()
{
    var CameraScript = GameObject.Find(PlayerPrefab.name).GetComponent("Camera Control");
    Network.Instantiate(PlayerPrefab, spawnObject.position, Quaternion.identity, 0);
}
Run Code Online (Sandbox Code Playgroud)

PlayerPrefab将成为将要实例化的预制件.当发生这种情况时,我需要在另一个GameObject上设置实例化的gameObject,这个GameObject是一个名为"Camera Control"的脚本,里面有一个我想要设置的变换Target.这该怎么做?

instantiation unity-game-engine unityscript gameobject

3
推荐指数
1
解决办法
3178
查看次数

流React:无法创建元素,因为React.Component [1]不是React组件

几周前我才开始使用flow,从一周前开始,我就收到了流错误,但我不知道如何解决。

代码如下:

// @flow

import React, { Component } from "react";
import { Redirect, Route } from "react-router-dom";
import CookieStorage from "./../services/CookieStorage";
import type { Component as ComponentType } from "react";

type Props = {
    component: ComponentType<any, any>
}

class ProtectedRoute extends Component<Props> {
    render() {
        const isAuthenticated     = this.isAuthenticated();
        const {...props}          = this.props;
        const AuthorizedComponent = this.props.component;

        return (
            <Route
                {...props}
                render={props => (
                    isAuthenticated ?
                        <AuthorizedComponent {...props} /> :
                        <Redirect to="/"/>
                )}
            />
        );
    }

    isAuthenticated(): boolean { …
Run Code Online (Sandbox Code Playgroud)

reactjs flowtype

3
推荐指数
1
解决办法
772
查看次数

Android:即使没有任何更改,资源链接在测试执行时也会失败

当我对始终运行良好的发布变体执行测试时,我开始遇到错误。代码始终在 Docker 容器中执行,因此我们可以确保构建始终是干净的。

今天出于某种原因,代码没有任何更改,我开始在测试运行中看到错误:

Execution failed for task:
am:processReleaseResources'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
   > Android resource linking failed
     /.gradle/caches/transforms-2/files-2.1/ff28653768e2ccb1135467db3600af3a/core-1.7.0-alpha02/res/values/values.xml:105:5-114:25: AAPT: error: resource android:attr/lStar not found.
Run Code Online (Sandbox Code Playgroud)

我对该错误进行了一些研究,但我只发现了与另一个资源相关的错误,而没有发现与 lStar 相关的错误。到目前为止,我发现 lStar 是特别添加到 Android 31(Android 12)的代码,如果我的 compileSdkVersion 值为 28,这对我来说为什么它应该开始在 Android 12 上工作毫无意义。

<declare-styleable name="ColorStateListItem">
    <!-- Base color for this state. -->
    <attr name="android:color"/>
    <!-- Alpha multiplier applied to the base color. -->
    <attr format="float" name="alpha"/>
    <attr name="android:alpha"/>
    <!-- Perceptual luminance applied to the base color. From 0 to 100. --> …
Run Code Online (Sandbox Code Playgroud)

android

3
推荐指数
1
解决办法
752
查看次数

sequelize:关联引用了错误的外键列名

我在这个问题上挣扎了几个小时,我似乎无法找到解决这个令人困惑的错误的方法。我正在尝试使用连接表进行查询并使用嵌套对象显示结果。

所以表是这样的:blogsaccounts通过表上的外键accounts_idblogs表相关联,这似乎是一个简单的连接查询,但我不能让 sequelize 使用正确的外键列名,因为它认为外键被称为account_id

模型是这样定义的:

帐户:

module.exports = function(sequelize, DataTypes) {
    return sequelize.define('accounts', {
        id: {
            type: DataTypes.INTEGER(11),
            allowNull: false,
            primaryKey: true,
            autoIncrement: true
        },
        username: {
            type: DataTypes.STRING,
            allowNull: false
        },
        ............
    }, {
        tableName: 'accounts',
        timestamps: false,
        freezeTableName: true
    });
Run Code Online (Sandbox Code Playgroud)

博客:

module.exports = function(sequelize, DataTypes){
    var model = sequelize.define("blogs", {
        id: {
            type: DataTypes.INTEGER(11),
            allowNull: false,
            primaryKey: true,
            autoIncrement: true
        },
        title: {
            type: DataTypes.STRING,
            allowNull: false,
        },
        content: …
Run Code Online (Sandbox Code Playgroud)

sequelize.js

2
推荐指数
1
解决办法
2871
查看次数

选中无线电时显示元素

只是试图让一个p元素显示何时input[type=radio]被选中

HTML代码:

<div class="form-group checkbox">
    <input type="radio" id="pago-deposito" name="[transaccion]pago"/>
    <label for="pago-deposito">check1</label>
    <p id="pago-hint">
        //hints
    </p>
</div>
Run Code Online (Sandbox Code Playgroud)

我试过的CSS

.checkbox > input#pago-deposito[type=radio]:checked + p#pago-hint{
    display: block;
}

#pago-hint{
    display: none;
    line-height: 40px;  
}
Run Code Online (Sandbox Code Playgroud)

这就是它,我已经在不同的地方实现了相同的方法,它的工作原理,我只是不知道为什么这个不

html css

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