小编Tsc*_*cka的帖子

array_merge没有按预期工作

我有一个双级数组.在第一级有大约10个索引.它们包含275个元素数组,每个数组都包含一个单词.

Array
(
[0] => Array
    (
    [0] => Suspendisse
    [1] => Nam.
    [2] => Amet
    [3] => amet
    [4] => urna
    [5] => condimentum
    [6] => Vestibulum
    [7] => sem
    [8] => at
    [9] => Curabitur
    [10] => lorem
    .... to [275]
    )
[1] => Array
    (
    ... you get the idea
    )
... 10 elements total
)
Run Code Online (Sandbox Code Playgroud)

现在,通过环境,比如占用空间的添加图像,我有时需要重新计算剩余的单词数量,并重新分配仍然保留的数组.

为此,我编写了下面的函数,使剩下的数组成为一个很长的单词数组,然后我可以将array_chunk调整到正确的比例.&$ array是对"mother array"的引用,$ memory是一个多余的单词数组,$ index是我们迭代for循环的地方,$ limit是第二级的"数组"长度,在这里案例275

function redistribute(&$array,$memory,$index,$limit)
{
$ret[] = $array[0];
// skip past the current processed items
for($c=1;$c<$index;$c++) …
Run Code Online (Sandbox Code Playgroud)

php arrays multidimensional-array array-merge

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

如何从Web.config中的规则中排除目录(ASP.NET)

我在我的Web.config中设置了这些规则:

    <rules>
        <rule name="replacedash">
          <match url="(.*)(-)(.*)\.aspx$" />
          <action type="Redirect" url="{R:1}{R:3}" redirectType="Permanent" />
        </rule>
        <rule name="extensionless" stopProcessing="true">
              <match url="(.*)\.aspx$" />
              <action type="Redirect" url="{R:1}" redirectType="Permanent" />
        </rule>
        <rule name="removeextension" enabled="true">
            <match url=".*" negate="false" />
                <conditions>
                    <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                    <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                    <add input="{URL}" pattern="(.*)\.(.*)" negate="true" />
                </conditions>
                <action type="Rewrite" url="{R:0}" />
        </rule>
    </rules>
Run Code Online (Sandbox Code Playgroud)

我已将我的网站从普通的ASP.NET升级到ASP.NET MVC,我已经编写了这些规则,以防万一在搜索引擎中仍有一些旧的缓存链接,扩展名为.aspx; 但是,我的Web服务器上有一些目录仍然包含.aspx文件,原因很充分,我的规则也在重写这些扩展.

如何从继承我的规则中排除这些文件夹?

asp.net asp.net-mvc web-config

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

如何将Webpack插件仅用于一项

我想在webpack中使用同一文件使用多个条目,但要传递一个变量。

我的想法是对每个条目使用webpack.definePlugin。

例:

{
  entry: {
    file1: 'myfile.js',
    file2: 'myfile.js',
  },
  output: {
    filename: '[name]/myjs.js'
  }
}
Run Code Online (Sandbox Code Playgroud)

我设置了插件:

{
   plugins: [
     new webpack.DefinePlugin({
        MYVARTOFILE: 'a',
        filename: 'file1/myjs.js' // I want to make something like this
     }),
     new webpack.DefinePlugin({
        MYVARTOFILE: 'b',
        filename: 'file2/myjs.js' // I want to make something like this
     })
   ]
}
Run Code Online (Sandbox Code Playgroud)

或者,如果可能,可以通过其他方式将变量传递给每个条目。
如果可以:

  entry: {
    file1: 'myfile.js?variable=a',
    file2: 'myfile.js?variable=b',
  }
Run Code Online (Sandbox Code Playgroud)

并在我的文件中获取该变量。

plugins webpack

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

十月CMS站点的Git部署

我为我的大多数站点设置了 Git 部署,它运行得非常好。我最近开始使用 October,对于我自己创建的主页,我想在本地工作,然后使用 Git 将新的和更新的页面部署到实时服务器。

It is my understanding that (apart from blog plugins for instance) October uses flat files for it's content. If I create files locally within my local install of October, can I safely Git push only the files I have worked on (html, css, js etc.) up to the site along with front matter and have them work on the remote deployment server? Will October just integrate them?

php git web-deployment octobercms

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

TipTap 编辑器中无法正确识别空格

我们在项目中使用TipTap的富文本编辑器。
但我们有一个问题,空间无法正确识别,只有在每两次单击后才会创建一个空间。我们使用 Vue.JS 作为框架。

import { Editor, EditorContent, EditorMenuBar } from 'tiptap'
import {
  HardBreak,
  Heading,
  OrderedList,
  BulletList,
  ListItem,
  Bold,
  Italic,
  History
} from 'tiptap-extensions'
import EditorMenuButton from './EditorMenuButton.vue'
export default {
  name: 'editor',
  components: {
    EditorMenuButton,
    EditorMenuBar,
    EditorContent
  },
  props: {
    value: {
      type: null,
      default: ' '
    }
  },
  data () {
    return {
      innerValue: ' ',
      editor: new Editor({
        extensions: [
          new HardBreak(),
          new Heading({ levels: [1, 2, 3] }),
          new BulletList(),
          new OrderedList(),
          new ListItem(),
          new …
Run Code Online (Sandbox Code Playgroud)

html javascript frontend vue.js tiptap

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

是否更好地使用&$大字符串来节省内存?

所以我想知道,为了在一个非常繁忙的服务器上节省一些宝贵的内存分配.

如果我在编译最终输出时有大约1-5mb的字符串在我的程序中被抛出,那么通过引用明确地传递它们会更好吗?这会节省内存吗?

所以基本上问题是:记忆明智什么更好,A或B并且值得努力吗?

A:

function something($whoa) {
  $whoa .= 'bar';
  return $whoa;
}
$baz = 'foo';
$baz = something($baz);
echo $baz;
Run Code Online (Sandbox Code Playgroud)

B:

function something(&$whoa) {
  $whoa .= 'bar';
}
$baz = 'foo';
something($baz);
echo $baz;
Run Code Online (Sandbox Code Playgroud)

php memory memory-management pass-by-reference

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

什么是php composer以及依赖管理器是什么意思?

我试图了解作曲家的确是什么和做什么.我对它完全陌生,围绕它的概念是什么.

我遇到的问题是:

  • 什么是依赖?这在PHP中意味着什么?
  • 作曲家是一个依赖经理是什么意思?
  • 一般来说,使用composer或依赖管理器的主要理由是什么?

php dependency-management composer-php

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

在Java版本1.5之前,如何在ArrayList中处理没有泛型的类型

我对Java的历史有疑问.
Java已经ArrayList从1.2开始了.
Java从版本1.5开始具有泛型.

ArrayList没有泛型的实现如何定义类型?

java generics arraylist

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

为Android游戏绘制方形网格时遇到问题

我希望它在屏幕中央显示为 7 x 7 方形网格,但是正如您在我当前的代码中看到的那样,垂直线位于正确的位置,但水平线不在。我相信这是一个简单的修复,任何帮助将不胜感激 -

public class GameGrid extends View {

    Paint black = new Paint();

    public GameGrid(Context context) {
        super(context);

        black.setColor(Color.BLACK);
        black.setStrokeWidth(8);
    }

    @Override
    public void onDraw(Canvas canvas) {

        float startX;
        float stopX;
        float startY;
        float stopY;

        int width = canvas.getWidth();
        int height = canvas.getHeight();

        int gridSize = 7;
        int gridSpacing = width / gridSize;

        //Vertical Grid-lines
        for (int i = 0; i < gridSize; i++) {

            startX = width / 2 - height / 2;
            stopX = …
Run Code Online (Sandbox Code Playgroud)

java grid android android-studio

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

通过代码检测类删除我无法控制

我需要在从一个元素中删除一个类时调用一个函数,我无法控制何时删除该类.

目前我可以通过使用setTimeout使其工作,所以它是这样的:

function checkClassRemoval() {
    if (!$('.myElement').hasClass('mySecondClass')) {
        // run function
    }   
}   

setTimeout(checkClassRemoval, 1000);
Run Code Online (Sandbox Code Playgroud)

除了每秒运行一次检查之外,是否有更好的方法来清除班级?

javascript jquery

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