小编Squ*_*gs.的帖子

下载动画GIF

我正在使用下面的内容从网上抓取动画gif.但是,在将其保存到磁盘后,我丢失了gif中的帧,并且它不再具有动画效果.不确定问题是否在下面的方法中,或者是否是在我保存它的时候,但是对于为什么以下方法不起作用的任何反馈意见.该方法正在运行 - 只是没有创建一个合适的动画GIF文件.

public Image getImage(String url)
{
    HttpWebRequest httpWebRequest = (HttpWebRequest)HttpWebRequest.Create(url);
    HttpWebResponse httpWebReponse = (HttpWebResponse)httpWebRequest.GetResponse();
    Stream stream = httpWebReponse.GetResponseStream();
    return Image.FromStream(stream, true, true);
}

Image im = getImage(url)
im.Save(pth,ImageFormat.Gif);
Run Code Online (Sandbox Code Playgroud)

.net c# gif animated

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

PHPUnit Laravel Hash不可用

我在Laravel中进行了单元测试,用于测试看起来像这样的API调用,但是在运行时遇到以下运行时错误:

RuntimeException: A facade root has not been set.
Run Code Online (Sandbox Code Playgroud)

我在setup方法中创建了一个用户,打算在tearDown()方法中再次删除它,然后运行我的auth测试.

首先,有没有更好的方法来做我想要的?例如,在不触及数据库的情况下模拟用户?其次,如何设置"立面根"或该错误究竟意味着什么?为了创建一个Dummy用户,我已经尝试不打扰散列该特定字段,但是错误似乎转移到模型,其中(再次)使用了Hash外观类.

是否有任何其他步骤来设置环境,以便这些外观可用于测试?

提前致谢.

use Illuminate\Support\Facades\Hash;

/*
* Make sure the structure of the API call is sound.
*/
public function testAuthenticateFailed()
{

  $this->json('POST', $this->endpoint,
        [ 'email' => 'test@test.com',
          'password' => 'password',
        ])
         ->seeJsonStructure([
             'token'
  ]);

}

//create a user if they don't already exist.
public function setup()
{
  $user = User::create([
      'company_id' => 9999,
      'name'=>'testUser',
      'email' => 'test@test.com',
      'password' => 'password',
      'hashed_email' => Hash:make('test@test.com'),
  ]);
}
Run Code Online (Sandbox Code Playgroud)

php phpunit laravel laravel-facade

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

SVG动画围绕中心点旋转路径。

目前,我无法让此SVG完美地沿其轴旋转。我试过计算我认为应该成为中心的内容。谁能为我指出正确的方向,为什么它不能完美地围绕质心旋转?还是将来如何最好地计算?

<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 17 17" >
<style type="text/css">
    .st0{fill:#000000;}
</style>
    <path id="arrow" class="st0" d="M9.3,16.4c3.2-0.4,5.8-2.9,6.2-6.1c0.5-4.2-2.8-7.7-6.9-7.8V0.6c0-0.1-0.1-0.2-0.2-0.1l-4,2.9
    c-0.1,0-0.1,0.1,0,0.2l3.9,2.8c0.1,0.1,0.2,0,0.2-0.1V4.5c2.9,0,5.2,2.5,5,5.4c-0.2,2.5-2.2,4.5-4.8,4.7c-2.7,0.2-5-1.7-5.4-4.2
    c-0.1-0.5-0.5-0.8-1-0.8c-0.6,0-1,0.5-1,1.1C2.1,14.2,5.4,16.9,9.3,16.4L9.3,16.4z"/>

    <animateTransform attributeType="xml" attributeName="transform" type="rotate" from="360 8.425116062164307 8.459185183048248" to="0 8.425116062164307 8.459185183048248" dur="0.5s" additive="sum" repeatCount="indefinite" />
</svg>
Run Code Online (Sandbox Code Playgroud)

https://jsfiddle.net/vfz5t0vw/

svg svg-animate

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

在Woocommerce中获取并显示相关产品

我已经在主题中包含了Woocommerce相关产品,其中包括:

<?php wc_get_template( 'single-product/related.php' ); ?>
Run Code Online (Sandbox Code Playgroud)

这已被复制到我的模板中,并且正在执行。

但是,即使我为此产品添加了各种加售,该$related_products变量(在循环中使用)仍为NULL。为了开始展示这些相关产品,是否还有其他变量在起作用?

php wordpress loops product woocommerce

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

如何在PHP页面中包含JSP

我希望在PHP模板中包含JSP包含java代码的文件.这两个包含的问题是头文件和页脚文件.任何人有这样做的经验吗?我们正在考虑只是做一个HTTP请求来独立地从JSP文件中获取生成的HTML,但不确定这样做是否会有轻微的性能问题.

有没有更好的解决方案使用Apache中的一些工具来执行此操作?

php jsp

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

基于自定义头的 Spring Security antMatcher 规则

在 Spring 框架中,我目前正在尝试使用自定义标头而不是 url 来区分某些端点。目前,我似乎看不到如何允许具有自定义标头的特定 URL,但在 Spring Security 中拒绝另一个 URL。我的安全配置目前有一个 antMatcher,如下所示:

.antMatchers( HttpMethod.POST, "/api/website-user" ).permitAll()
Run Code Online (Sandbox Code Playgroud)

但是,我还有一些其他“POST”方法也受到保护 - 对于这个特定的端点,我只希望通过发送的标头来识别和排除它。

你如何告诉 Spring 安全这个 URL 应该未经身份验证通过

 @PostMapping( headers = "X-Operation-Name=forgot-password" )
   public WebsiteUser forgotPassword( @Valid PasswordResetRequestModel passwordReset )
Run Code Online (Sandbox Code Playgroud)

但是例如这个没有(并且依赖于经过身份验证的用户)?

@PostMapping( headers = "X-Operation-Name=resend-verification" )
   public WebsiteUser resendVerification( Principal principal )
Run Code Online (Sandbox Code Playgroud)

java spring spring-security http-headers spring-boot

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

使用 IntSummaryStatistics 跨多个字段求平均值

我正在尝试使用 Java 8 流来创建一个 CarData 对象,该对象由列表中所有 CarData 字段的平均值组成getCars

   CarData = new CarData();
   CarData.getBodyWeight returns Integer
   CarData.getShellWeight returns Integer
Run Code Online (Sandbox Code Playgroud)
     List<CarData> carData = carResults.getCars();
    
    IntSummaryStatistics averageBodyWeight = carData.stream()
            .mapToInt((x) -> x.getBodyWeight())
            .summaryStatistics();
    
    averageBodyWeight.getAverage(); 


            IntSummaryStatistics averageShellWeight = carData.stream()
            .mapToInt((x) -> x.getShellWeight())
            .summaryStatistics();
    
    getShellWeight.getAverage(); 
Run Code Online (Sandbox Code Playgroud)

我不想在我最终返回的结果中把这些都放在一起。

视觉上,这是我的清单

getCars() : [
 {CarData: { getBodyWeight=10, getShellWeight=3 } }
 {CarData: { getBodyWeight=6, getShellWeight=5 } }
 {CarData: { getBodyWeight=8, getShellWeight=19 } }
]
Run Code Online (Sandbox Code Playgroud)

我试图实现的输出是一个对象,它具有我指定的每个字段的平均值。不确定我是否需要使用Collectors.averagingInt或 IntSummaryStatistics 的一些组合来实现这一点。对于这些技术中的任何一种,在一个字段中都可以轻松完成,只是不确定在使用多个整数字段时我缺少什么。

 {CarData: { getBodyWeight=8, getShellWeight=9 } }
Run Code Online (Sandbox Code Playgroud)

java java-8 java-stream

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

Javascript反射,用字符串调用方法

    var OrderDetails = function () {
        var orderdetails = {};
            orderdetails.doSomething = function(){
               alert('do something');
            };
            return orderdetails;
    }
Run Code Online (Sandbox Code Playgroud)

代码中的其他地方......

    processMethod('doSomething')

    function processMethod(strMethod)
    {
        // strMethod = 'doSomething'; 
            var orderdet = OrderDetails(); //not the exact instantiation, just illustrating it is instantiated
            orderdet.strMethod(); //this is the line I'm stuck with.
    } 
Run Code Online (Sandbox Code Playgroud)

我正在尝试通过它在Javascript中的String名称来调用方法.我已经看过apply,call和eval()作为这个问题的潜在解决方案,但似乎无法使它们中的任何一个工作.对于我的特定对象场景,是否有任何关于语法的指导?

javascript reflection

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

Webpack HTML 为每个入口点生成一个 javascript

我正在为项目设置 Webpack,并使用 HTML webpack 插件生成 HTML 文件。

我的问题是生成的 HTML 包含所有捆绑包,而不是特定 HTML 文件的特定入口点。这是我的 ATM 代码

    const path = require('path');
var HtmlWebpackPlugin = require('html-webpack-plugin');

module.exports = {
  entry: {
    one: './js/one.js',
    two: './js/two.js',
    three: './js/three.js',
  },
  output: {
    path: path.resolve(__dirname, 'dist'),
    filename: './js/[name].js',
  },
  module: {
        loaders: [],
        rules:[
          {
            test: /\.css$/,
            use: [ 'style-loader', 'css-loader' ]
          },
          {
            test: /\.(png|jpg|woff|woff2|eot|ttf|svg)$/,
            use: ['url-loader?limit=100000&name=./img/[hash].[ext]'],
          }

        ]
  },
  plugins: [
  new HtmlWebpackPlugin({
    title: 'One',
    template: 'one.ejs', // Load a custom template (ejs by default …
Run Code Online (Sandbox Code Playgroud)

webpack html-webpack-plugin

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

错误:运行 `yarn run install-pods` 时生成 pod ENOENT

我正在尝试在我的计算机上设置本机反应,但在运行时yarn run install-pods出现以下错误。

$ ./cli.js installPods
events.js:292
      throw er; // Unhandled 'error' event
      ^

Error: spawn pod ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:268:19)
    at onErrorNT (internal/child_process.js:468:16)
    at processTicksAndRejections (internal/process/task_queues.js:84:21)
Emitted 'error' event on ChildProcess instance at:
    at Process.ChildProcess._handle.onexit (internal/child_process.js:274:12)
    at onErrorNT (internal/child_process.js:468:16)
    at processTicksAndRejections (internal/process/task_queues.js:84:21) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'spawn pod',
  path: 'pod',
  spawnargs: [ 'install', '--project-directory=./hosts/native/ios' ]
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
 musketeer % yarn run …
Run Code Online (Sandbox Code Playgroud)

react-native yarnpkg

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