小编Ant*_*i29的帖子

git:如何提取最新更改并解决冲突

我想从 github 存储库中提取所有最新更改。只有一个分支,只有一个人(开发人员)添加和修改代码。一旦添加了新功能,我就简单地将所有内容都拉进来。

通常,我所做的就是:

git pull
Run Code Online (Sandbox Code Playgroud)

但是这次我收到一条错误消息,内容如下:

自动合并失败;修复冲突,然后提交结果。

我只是想从 repo 中提取最新的更改。我不知道为什么只有一个人负责这个 repo 时会发生冲突。

注意:我不想向 repo 提交任何内容。

git conflict pull github

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

使用 CloudFront 的无效路径在 C# 中创建无效

我试图使 C#/.NET 中的 CloudFront 对象无效并得到以下异常:

您的请求包含一个或多个无效失效路径。

我的功能:

public bool InvalidateFiles(string[] arrayofpaths)
{
    for (int i = 0; i < arrayofpaths.Length; i++)
    {
        arrayofpaths[i] = Uri.EscapeUriString(arrayofpaths[i]);
    }

    try
    {
        Amazon.CloudFront.AmazonCloudFrontClient oClient = new Amazon.CloudFront.AmazonCloudFrontClient(MY_AWS_ACCESS_KEY_ID, MY_AWS_SECRET_KEY, Amazon.RegionEndpoint.USEast1);
        CreateInvalidationRequest oRequest = new CreateInvalidationRequest();
        oRequest.DistributionId = ConfigurationManager.AppSettings["CloudFrontDistributionId"];
        oRequest.InvalidationBatch = new InvalidationBatch
        {
            CallerReference = DateTime.Now.Ticks.ToString(),
            Paths = new Paths
            {
                Items = arrayofpaths.ToList<string>(),
                Quantity = arrayofpaths.Length
            }
        };

        CreateInvalidationResponse oResponse = oClient.CreateInvalidation(oRequest);
        oClient.Dispose();
    }
    catch
    {
        return false;
    }
    return true;
}
Run Code Online (Sandbox Code Playgroud)

传递给函数的数组包含一个 URL,如下所示: …

.net c# amazon-web-services cache-invalidation amazon-cloudfront

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

使用 JavaScript/jQuery 调用 do_action

userpro_ajax_url我有一个 AJAX 函数,可以在通过 Facebook 成功登录后发送信息。

do_action我正在尝试使用以下方法获得成功块来运行函数

<?php 
ob_start();  
do_action('userpro_social_login', <email needs to go here>);
ob_clean();
?>
Run Code Online (Sandbox Code Playgroud)

现在,如果我手动传递电子邮件地址,它可以正常工作,但是我可以动态获取电子邮件的唯一方法是通过 JavaScript 中的当前响应。

完整的功能是:

FB.api('/me?fields=name,email,first_name,last_name,gender', function(response) {
    jQuery.ajax({
        url: userpro_ajax_url,
        data: "action=userpro_fbconnect&id="+response.id+"&username="+response.username+"&first_name="+response.first_name+"&last_name="+response.last_name+"&gender="+response.gender+"&email="+response.email+"&name="+response.name+"&link="+response.link+"&profilepicture="+encodeURIComponent(profilepicture)+"&redirect="+redirect,
        dataType: 'JSON',
        type: 'POST',
        success:function(data){
            userpro_end_load( form );
            <?php 
            ob_start();  
            do_action('userpro_social_login', );
            ob_clean();
            ?>
            /* custom message */
            if (data.custom_message){
                form.parents('.userpro').find('.userpro-body').prepend( data.custom_message );
            }
            /* redirect after form */
            if (data.redirect_uri){
                if (data.redirect_uri =='refresh') {
                    //document.location.href=jQuery(location).attr('href');
                } else {
                    //document.location.href=data.redirect_uri;
                }
            }
        },
        error: function(){
            alert('Something wrong happened.');
        }
    }); …
Run Code Online (Sandbox Code Playgroud)

javascript php ajax wordpress jquery

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

如何为Yii2创建文件上载REST API控制器

我正在使用Ionic框架进行移动应用程序开发.下面的Yii2 API代码可用于文件上传,但它不起作用.它显示以下错误:

i)未定义的偏移量:0.

ii)yii\db\BaseActiveRecord-> save()

public function actionNew() {
    $model = new Apiprofile();
    $userid = $_REQUEST['user_id'];
    $photo = $_FILES['photo'];
    $model->user_id = $userid;
    $model->photo = $photo;
    $name = $model->user_id;
    $model->file = UploadedFile::getInstance($model, 'photo');

    if($model->file) {
        $model->file->saveAs('uploads/photos/'.$name.'.'.$model->file->extension);
        $model->photo = $name.'.'.$model->file->extension;
        $model->save();
    }

    $name = $model->user_id;

    if($model->save()) {
        echo json_encode(array('status'=>1,'data'=>$model->attributes),JSON_PRETTY_PRINT);
    } else {
        echo json_encode(array('status'=>0,'error_code'=>400,'errors'=>$model->errors),JSON_PRETTY_PRINT);
    }
}
Run Code Online (Sandbox Code Playgroud)

php api yii2 ionic-framework

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

当我们上下滚动 recyclerView 时隐藏和显示 viewgroup

我想在向下滚动时隐藏视图组,并在recyclerview.

这是我的代码,其中rvSearchItemsRecyclerview,并且rlSearchRelative Layout我想要隐藏和显示的代码:

rvSearchItems.addOnScrollListener(new RecyclerView.OnScrollListener() {
    @Override
    public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
        super.onScrollStateChanged(recyclerView, newState);
    }

    @Override
    public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
        super.onScrolled(recyclerView, dx, dy);
        if (dy >= 0) {
            if (rlSearch.getVisibility() != View.GONE)
                rlSearch.setVisibility(View.GONE);
        } else if(dy<-5) {
            if (rlSearch.getVisibility() != View.VISIBLE)
                rlSearch.setVisibility(View.VISIBLE);
        }
    }
});
Run Code Online (Sandbox Code Playgroud)

这里的主要问题是当我们快速滚动时它工作正常。如果我们缓慢滚动,它会闪烁多次。

android

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

如何搜索“com.apple.coreaudio.avfaudio”的错误代码?

我在哪里可以得到com.apple.coreaudio.avfaudio错误代码的信息,例如:

由于未捕获的异常“com.apple.coreaudio.avfaudio”而终止应用程序,原因:“错误 -50”

将 PCM 缓冲区写入AVAudioFile. 缓冲区来自AVAudioEngine的输出节点。

在此处输入图片说明

错误:

*终止应用程序由于未捕获的异常'com.apple.coreaudio.avfaudio',理由是: '错误-50' *第一掷调用堆栈:(0x18eb46fe0 0x18d5a8538 0x18eb46eb4 0x1a8d051cc 0x1a8d731dc 0x1000d45e0 0x1000d4820 0x1a8d14654 0x1a8d146c0 0x1a8d8c26c 0x1a8d8c1fc 0x100ae5a10 0x100af1a84 0x100b001f8 0x100ae7a60 0x100af3128 0x100ae9634 0x100af5630 0x100af6f48 0x18dc0968c 0x18dc0959c 0x18dc06cb4) libc++abi.dylib:以未捕获的 NSException 类型异常终止

你可以帮帮我吗?

avaudioengine avaudiofile

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

Keras softmax 激活,category_crossentropy 损失。但输出不是0、1

我只用很少的数据训练了一个 epoch 的 CNN 模型。我使用 Keras 2.05。

这是 CNN 模型的(部分)最后 2 层number_outputs = 201。训练数据输出是一种热编码 201 输出。

model.add(Dense(200, activation='relu', name='full_2'))
model.add(Dense(40, activation='relu',  name='full_3'))
model.add(Dense(number_outputs, activation='softmax'))

model.compile(loss='categorical_crossentropy', optimizer=adam, metrics=['accuracy'])
Run Code Online (Sandbox Code Playgroud)

模型保存为 h5 文件。然后,保存的模式将加载与上面相同的模型。batch_image是一个图像文件。

prediction = loaded_model.predict(batch_image, batch_size=1)
Run Code Online (Sandbox Code Playgroud)

我得到这样的预测:

ndarray: [[ 0.00498065  0.00497852  0.00498095  0.00496987  0.00497506  0.00496112
   0.00497585  0.00496474  0.00496769  0.0049708   0.00497027  0.00496049
   0.00496767  0.00498348  0.00497927  0.00497842  0.00497095  0.00496493
   0.00498282  0.00497441  0.00497477  0.00498019  0.00497417  0.00497654
   0.00498381  0.00497481  0.00497533  0.00497961  0.00498793  0.00496556
   0.0049665   0.00498809  0.00498689  0.00497886  0.00498933  0.00498056
Run Code Online (Sandbox Code Playgroud)

问题:

  1. 预测数组应该是1, …

keras softmax

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

Python Windows 服务 pyinstaller 错误

我用 Python 创建了一个程序。它的任务是检查一些日志并执行一些活动。

Reg_Version.py

class RegisterService:
.
.

    def performAction(self):
        self.__logFileSizeCheck()
        self.__getHostName()
        self.__deteleFiles()
        self.__createFiles()
.
.

class Service(win32serviceutil.ServiceFramework):
    _svc_name_ = '_test'
    _svc_display_name_ = '_Service Template'
    def __init__(self, *args):
        win32serviceutil.ServiceFramework.__init__(self, *args)
        self.log('init')
        self.stop_event = win32event.CreateEvent(None, 0, 0, None)
    def log(self, msg):
        servicemanager.LogInfoMsg(str(msg))
    def sleep(self, sec):
        win32api.Sleep(sec*1000, True)
    def SvcDoRun(self):
        self.ReportServiceStatus(win32service.SERVICE_START_PENDING)
        try:
            self.ReportServiceStatus(win32service.SERVICE_RUNNING)
            self.log('start')
            self.start()
            self.log('wait')
            win32event.WaitForSingleObject(self.stop_event, win32event.INFINITE)
            self.log('done')
        except Exception, x:
            self.log('Exception : %s' % x)
            self.SvcStop()
    def SvcStop(self):
        self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)
        self.log('stopping')
        self.stop()
        self.log('stopped')
        win32event.SetEvent(self.stop_event)
        self.ReportServiceStatus(win32service.SERVICE_STOPPED)
    # to be overridden
    def start(self): …
Run Code Online (Sandbox Code Playgroud)

python windows service py2exe pyinstaller

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

找不到模块:无法解析“material-ui/FlatButton”

我收到以下错误:

/src/Components/Home/post.jsx 找不到模块:无法解析 /Users/apple/Documents/dev/source/sm-ui/servicemonster-ui 中的“material-ui/FlatButton”

我尝试安装material-ui但失败了。我怎样才能解决这个问题?

post.jsx

import React from 'react';
import {Card, CardActions, CardHeader, CardMedia, CardTitle, CardText} from 'material-ui/Card';
import FlatButton from 'material-ui/FlatButton';
import Toggle from 'material-ui/Toggle';

export default class CardExampleControlled extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            expanded: false,
        };
    }

    handleExpandChange = (expanded) => {
        this.setState({expanded: expanded});
    };

    handleToggle = (event, toggle) => {
        this.setState({expanded: toggle});
    };

    handleExpand = () => {
        this.setState({expanded: true});
    };

    handleReduce = () => {
        this.setState({expanded: false}); …
Run Code Online (Sandbox Code Playgroud)

react-redux

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

在 Android 下载管理器上获取总字节数返回 -1

我正在创建一个进度条来显示 Android 下载管理器中下载 apk 的百分比,但DownloadManager.COLUMN_TOTAL_SIZE_BYTES总是返回-1,并且当下载完成时,它会返回文件大小。

String url = Config.GET_APK+ finalApk;
final DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url));
request.addRequestHeader("Authorization", token);

// in order for this if to run, you must use the android 3.2 to compile your app
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
    request.allowScanningByMediaScanner();
    request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
}
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, finalApk);
Log.d("PATH1", String.valueOf(Environment.DIRECTORY_DOWNLOADS + "/" + finalApk));
// get download service and enqueue file
final DownloadManager manager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE);
final long downId = manager.enqueue(request);
Log.d("DOWNLOADID", String.valueOf(downId));

download.show();

new Handler().postDelayed(new Runnable() …
Run Code Online (Sandbox Code Playgroud)

android android-download-manager

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