小编Som*_*nha的帖子

如何在没有index.html的情况下使用Jekyll-paginate?

我正在尝试在Github页面上构建我的博客,我必须使用Jekyll-paginate,原因很明显.问题是,我不会将index.html页面用于欢迎页面以外的任何内容.我在一个名为articles的文件夹中有一个名为index.html的单独页面,因此博客的URL应该是xyz.github.io/articles/.

然而,这提出了一个主要问题 - 显然jekyll-paginate拒绝在博客根目录中没有明确的index.html的情况下工作.所以,我尝试使用没有这种限制的jekyll-paginate-v2,它完美无缺!

但是,github页面不支持jekyll-paginate-v2,因此,我回到了正方形1.我该怎么办?

注意:这是我的代码:

index.md

---
layout: home
title: SomuSysAdmin
---

If you're new to this site and have no idea what's going on, first go and read the [About](about.md) section of the blog.

Here's a list of all the major articles this blog contains: 

## [Red Hat Certified Systems Administrator (RHCSA) Guide]({% post_url 2017-09-11-RHCSA %})
Run Code Online (Sandbox Code Playgroud)

这是我的_config.yml:

# -----------------------------------------------------------------------------
#  User configuration
# -----------------------------------------------------------------------------

title:               SomuSysAdmin

# The unique resource location of your page.
# …
Run Code Online (Sandbox Code Playgroud)

markdown jekyll github-pages github-flavored-markdown jekyll-paginator

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

如何将$(this)传递给函数?

我的代码是:

$(document).ready(function(){

    var hCount = 0,
        eCount = 0,
        nCount = 0,
        mCount = 0;

$("#head").click(function() {
        var pPos = counter(hCount);
        $(this).animate({left:pPos+"px"}, 1000);
    });

function counter(count)
{
    count++;
    if(count === 10)
    {
        count = 0;
        pPos = 0;
    }
    else
    {
        var pPos = $(this).css('left');
        pPos = pPos.substring(0,(pPos.length-2))
        pPos -= 367;

    }

    return pPos;
}
Run Code Online (Sandbox Code Playgroud)

我收到一个错误说明

未捕获的TypeError:无法读取未定义的属性"defaultView"

我不知道是什么导致了这个错误.

另外,我怎么能传递给函数counter()的值$(this)$("#head").click?我不能直接提及$("#head")因为我将重复使用更多div的功能#head,而不是在重用函数计数器中的代码时.

javascript jquery function this parameter-passing

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

我在哪里搞砸了Java中这个数学表达式的评估?

我的代码是:

int x=5,y=3;
x+=y*++x-x/y-y++;
System.out.println("Value = "+x);
Run Code Online (Sandbox Code Playgroud)

我的评价如下:

x + = y*++ xx/y-y ++
(x = 5 | y = 3)

x = x +(y*++ xx/y-y ++)
(x = 5 | y = 3)| ++和 - 具有最高优先级

x = x +(y*6-x/y-3)
(x = 6 | y = 4)|*和/具有次优先级

x = x +(4*6-(6/4)-3)
(x = 6 | y = 4)

x = x +(24 -1 -3)
(x = 6 | y = 4)

x = 6 + 20
(x = 6 …

java expression

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

如何使用sed用\(空格)替换空间?

当我使用sed用X替换所有空格时,命令有效,命令为:

sed 's/ /X/g' filelist.tmp
Run Code Online (Sandbox Code Playgroud)

但是,当我尝试使用\ space替换所有出现的空间时,代码为:

sed 's/ /\ /g' filelist.tmp
Run Code Online (Sandbox Code Playgroud)

它不起作用.我究竟做错了什么?请注意,我是shell脚本的新手.

bash shell sed

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

如何将 h2 Markdown 标题转换为链接?

我对使用 Jekyll 和 Markdown 创建网站不太熟悉,所以请告诉我我的方法是否有明显的错误。

我的代码是:

[## Red Hat Certified Systems Administrator (RHCSA) Guide]({% post_url 2017-09-11-RHCSA %})
Run Code Online (Sandbox Code Playgroud)

我期望的输出是一个 h2 标头,它也是一个链接。但是,当我使用 Jekyll 提供页面时,链接工作正常,但链接文本不是 h2 标头,而是仅包含## Red Hat Certified Systems Administrator (RHCSA) Guide.

那么,如何使用 markdown 将<h2>标签嵌套在标签内呢<a href>

markdown github jekyll github-pages github-flavored-markdown

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

使用foreach循环输入2D数组

我想将以下传统for循环转换为foreach循环:

for(int i=0;i<3;i++)
    for(int j=0;j<3;j++)
        arr[i][j]=sc.nextInt();
Run Code Online (Sandbox Code Playgroud)

我的尝试是:

for(int[] innerArr: arr)
    for(int ele: innerArr)
        ele = sc.nextInt();
Run Code Online (Sandbox Code Playgroud)

这不起作用.我认为,因为innerArr代表一行数组,并ele代表该行中的单个元素,上面的代码将起作用.但我想只有该元素的现有值arr[i][j]被复制到ele.是否可以使用foreach循环为该元素赋值?

java arrays foreach for-loop

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

气泡排序算法中的迭代次数是否等于(n-1)!对于n个元素?

我最近在一本书中读到,如果我们n在数组中对元素进行排序,那么所需的迭代次数将是n*(n-1)*...*1 = 7!.

但我确信实际的比较次数是(n-1)+(n-2)+ ... + 1 = n(n-1)/ 2.那么迭代次数和比较次数有何不同?我猜不是,因为在每次迭代中,值都会被比较[ if(m[j]>m[j+1])].我错过了什么,或者这本书错了吗?

整个代码:

for(i=0;i<7;i++)
{
    for(j=0;j<7-i;j++)
    {
        if(m[j]>m[j+1])
        {
            t=m[j];
            m[j]=m[j+1];
            m[j+1]=t;
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

algorithm bubble-sort

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

为什么我得到NaN值?

我的jQuery是:

$("#listDB").on("change", ".qfStyle", function(event) {
    var id = $(this).parents("tr").find('.itemCbox').val();
    $qnty = $("#qnty"+id);
    $unit = $("#unit"+id);
    $price = $("#price"+id);

    if($(this).parents("tr").find('.pbo').text()=="Kilos")
    {
        if(this.value<1)
        {
            $qnty.text(this.value*1000);
            $unit.text("gm");

            var data = "action=getPrice&id="+id;
            $.post("addBill.php", data, function(json) {
                alert(json.price);
                $price.text(json.price*this.value);
            }, 'json');
        }
    }
});
Run Code Online (Sandbox Code Playgroud)

服务器返回的JSON数据是:

{ "价格": "52.00"}

这里this指的是一个文本框.我得到NaN了表达式的值:

$price.text(json.price*this.value);
Run Code Online (Sandbox Code Playgroud)

但我保证这两个this.valuejson.price是两个数字.那么,为什么当我乘以NaN时会得到NaN?

javascript jquery json

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

为什么我的媒体查询不起作用?

.small_only {
  display: block;
}

.large_only {
  display: none;
}


/* === Media Queries === */

// Extra large devices (large desktops, 1200px and up)
@media (min-width: 1200px) {
  .small_only {
    display: none;
  }
  .large_only {
    display: block;
  }
}
Run Code Online (Sandbox Code Playgroud)
<div class="container">
  <div class="row">
    <div class="col-lg-12 col-xs-12">
      <div class="small_only">
        <h1>SMALL</h1>
      </div>
      <div class="large_only">
        <h1>This should only be visible in large windows</h1>
      </div>
    </div>
  </div>
</div>
Run Code Online (Sandbox Code Playgroud)

问题:无论屏幕有多宽,输出都只包含"SMALL"字样.

我觉得我错过了一些明显的东西,但对于我的生活,我无法弄清楚它是什么.

css media-queries

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

this.prop不是一个函数?

我的jQuery代码是:

$('#edit').click(function(){
    var data = $("#list :input").serialize();
    $.post($("#list").attr('action'), data, function(json) 
    {
        currentRow = json.rowArr[0];
        $("#id").val(currentRow.id);
        $("#id_disp").val(currentRow.id);
        $("#shop").val(currentRow.shop);
        $("#category").val(currentRow.category);
        $("#item").val(currentRow.item);
        $("#qnty").val(currentRow.qnty);
        $("#unit").val(currentRow.unit);

        $.each($("#price_based_on").children('option'), function(index, val) {
            if(this.value.toUpperCase()==currentRow.price_based_on.toUpperCase())
            {
                console.log("Match");
                this.prop("selected", true);
            }
        });

        $("#mrp").val(currentRow.mrp);
        $("#sellers_price").val(currentRow.sellers_price);
        $("#last_updated_on").val(currentRow.last_updated_on);

    },"json");
});
Run Code Online (Sandbox Code Playgroud)

其中,唯一感兴趣的是线条:

$.each($("#price_based_on").children('option'), function(index, val) {
    if(this.value.toUpperCase()==currentRow.price_based_on.toUpperCase())
    {
        console.log("Match");
        this.prop("selected", true);
    }
});
Run Code Online (Sandbox Code Playgroud)

在使用语句时,this.prop("selected", true);我收到错误:

未捕获的TypeError:this.prop不是函数

当.prop()显然是一个存在的函数时,为什么会发生这种情况?我如何解决它?

javascript jquery

0
推荐指数
2
解决办法
7889
查看次数