小编Kir*_*hou的帖子

仅使用CSS在pre上创建行号

我尝试在每行前面设置一个带有行号的代码预先设置框.我更喜欢用CSS做.这就是我所做的

pre {
  background: #303030;
  color: #f1f1f1;
  padding: 10px 16px;
  border-radius: 2px;
  border-top: 4px solid #00aeef;
  -moz-box-shadow: inset 0 0 10px #000;
  box-shadow: inset 0 0 10px #000;
}
pre span {
  display: block;
  line-height: 1.5rem;
}
pre span:before {
  counter-increment: line;
  content: counter(line);
  display: inline-block;
  border-right: 1px solid #ddd;
  padding: 0 .5em;
  margin-right: .5em;
  color: #888
}
Run Code Online (Sandbox Code Playgroud)
<pre>
  <span>lorem ipsum</span>
  <span>&gt;&gt; lorem ipsum</span>
  <span>lorem ipsum,\ </span>
  <span>lorem ipsum.</span>
  <span>&gt;&gt; lorem ipsum</span>
  <span>lorem ipsum</span>
  <span>lorem ipsum</span>
  <span>lorem ipsum</span>
</pre>
Run Code Online (Sandbox Code Playgroud)

但是,所有行都具有数字1.增量不起作用.这是一个 …

html css css-counter

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

Javascript - ERR_CONTENT_LENGTH_MISMATCH

我正在制作一个基本的jquery游乐场网站.我收到错误:net::ERR_CONTENT_LENGTH_MISMATCH正在页面加载时发生,并且页面上没有加载背景图像.

有问题的图像是300kb,也是动态变化的.我假设这与文件大小有关,但我真的不知道是什么.

最初使用的HTML:

<p style="margin:0px; padding:0px;">
  <img id="background" src="/bg1.jpg" style='width:100%;' border="0" alt="Null">
</p>
Run Code Online (Sandbox Code Playgroud)

用于更改背景的javascript/jquery:

var changebg = function() {
  if (myscore % 20 == 0) {
    level++;
    document.getElementById("level").innerHTML = "Level: " + level;
    $("#level").fadeIn(1500, function(){$("#level").hide()})
    backgroundindex++;
    if (backgroundindex > 6) {
      backgroundindex == Math.floor((Math.random()*6)+1)};
    document.getElementById("background").src="/bg"+backgroundindex+".jpg";
  };
}
Run Code Online (Sandbox Code Playgroud)

html javascript jquery

42
推荐指数
2
解决办法
8万
查看次数

接收json并反序列化为spring mvc控制器上的对象列表

我的代码如下:

调节器

@RequestMapping(value="/setTest", method=RequestMethod.POST, consumes="application/json")
public @ResponseBody ModelMap setTest(@RequestBody List<TestS> refunds, ModelMap map) {
    for(TestS r : refunds) {
        System.out.println(r.getName());
    }
    // other codes
}
Run Code Online (Sandbox Code Playgroud)

TestS pojo

public class TestS implements Serializable {
    private String name;
    private String age;
    //getter setter
}
Run Code Online (Sandbox Code Playgroud)

Json请求

var z = '[{"name":"1","age":"2"},{"name":"1","age":"3"}]';
$.ajax({
    url: "/setTest",
    data: z,
    type: "POST",
    dataType:"json",
    contentType:'application/json'               
});
Run Code Online (Sandbox Code Playgroud)

它给出了这个错误

java.lang.ClassCastException:java.util.LinkedHashMap无法强制转换为com.gogoair.cidb.entities.TestS

我使用的是Spring 3.1.2jackson 2.0.4

编辑:我想在我的控制器方法中接收TestS对象列表,并处理它们.我无法找到我发送错误的json或我的方法签名是错误的.

spring spring-mvc jackson

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

Graphviz图定位xlabels

我尝试过使用xlp并且也遵循这个graphviz线程(http://www.graphviz.org/content/how-use-xlp-attribute-positioning-external-labels-xlabel),但两者都没有实际工作.

这是我的点代码:

digraph {
    forcelabels=true;
    rankdir=LR;
    graph[ranksep=1,nodesep=.5];
    node[shape=box];
    "start" [xlabel="start",xlp="0,0",shape=doublecircle,label=" "];
    "requested"->"fault";
    "requested"->"progress";
    "start"->"requested";
    "progress"->"fault";
    "progress"->"progress";
    "progress"->"complete";
    "fault" [xlabel="fault",shape=doublecircle,label=" "];
    "complete" [xlabel="complete",shape=doublecircle,label=" "];
}
Run Code Online (Sandbox Code Playgroud)

这就是它的样子: 在此输入图像描述

理想情况下,start,fault和complete将直接位于节点之下,但我似乎无法正确定位xlabels.

graphviz

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

mac OSX Sierra,由于需要cURL v 9.0.0或更高版本而不能添加vagrant box laravel/homestead,而libcurl.4.dylib提供v7.0.0

我在mac OSX 10.12.1上安装了最新的vagrant.

当我试图跑vagrant box add laravel/homestead无济于事.然后我得到:

$ vagrant box add laravel/homestead
The box 'laravel/homestead' could not be found or could not be accessed in the remote catalog. If this is a private box on HashiCorp's Atlas, please verify you're logged in via "vagrant login". Also, please double-check the name. 
Run Code Online (Sandbox Code Playgroud)

扩展的URL和错误消息如下所示:

URL: ["https://atlas.hashicorp.com/laravel/homestead"]
Error: 
Run Code Online (Sandbox Code Playgroud)

请注意,没有列出错误,也没有提到SSL问题.

所以我试着跑步vagrant box add laravel/homestead.这是我得到的回应的摘录:

$ vagrant box add laravel/homestead https://atlas.hashicorp.com/laravel/boxes/homestead/versions/0.5.0/providers/virtualbox.box --debug
==> box: Adding box 'laravel/homestead' (v0) for provider: 
INFO box_add: …
Run Code Online (Sandbox Code Playgroud)

macos vagrant laravel homestead

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

Extjs日期选择器.在月份更改时突出显示日期

我突出显示日期选择器显示的一个月内的一些日期.这是通过向Picker组件添加highlightDates函数来完成的

Ext.override(Ext.form.field.Picker, {

    highlightDates: function (picker, dates) {

        if (Ext.isEmpty(dates)) return;
        for(var i = 0; i < dates.length; i++) {
            var t = new Date(dates[i].date),
                dtMillis = t.getTime(),
                offset = t.getTimezoneOffset() * 60 * 1000,
                dt = dtMillis + offset,
                cells = picker.cells.elements;  

            for (var c = 0; c < cells.length; c++) {
                var cell = Ext.fly(cells[c]);
                if (cell.dom.firstChild.dateValue == dt) {
                    cell.addCls('cell-highlight');
                    break;
                }
            }
        }
    }
});
Run Code Online (Sandbox Code Playgroud)

传递给上面函数的日期对象是来自控制器中的Ajax调用的变量集.

getDates: function (cmp) {
    var me = this;
    Ext.Ajax.request({
        url: …
Run Code Online (Sandbox Code Playgroud)

extjs

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

如何将ipython魔术输出存储到变量中

我是一个python和Ipython初学者.这可能是一个微不足道的问题.它可能与其他问题重复.但是我不知道应该搜索哪些关键词.

我已经知道如何与shell交互.

例如:

In [1]: a = !ls
In [2]: a
        ...same ls result as shell...
In [3]: type(a)
Out[3]: IPython.utils.text.SList
Run Code Online (Sandbox Code Playgroud)

但是,如何与Ipython魔术互动?

例如

In [1]: a = %history -t 
        ...Ipython result...
In [2]: a
In [3]: type(a)
Out[3]: NoneType
Run Code Online (Sandbox Code Playgroud)

python ipython ipython-magic

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

我的 AWS CLI 无法使用 sudo

我有shell脚本,用途aws cli,我的脚本将被使用sudo执行(例如:sudo ./test.sh

但我收到了消息: Unable to locate credentials. You can configure credentials by running "aws configure".

其实,我并配置了两个sudo aws configureaws configure

我做错了什么?请帮忙。谢谢!

shell aws-cli

6
推荐指数
2
解决办法
6270
查看次数

C教程 - 想知道`int i =*(int*)&s;`

通过C教程学习

#include <stdio.h>

int main() {
  short s = 10;
  int i = *(int *)&s; // wonder about this
  printf("%i", i);
  return 0;
}
Run Code Online (Sandbox Code Playgroud)

当我告诉C该地址s是一个int时,它是否应该读取4个字节?

从2字节的最左侧开始s.在这种情况下,这不是非常危险的,因为我不知道它在读什么,因为短路只分配了2个字节?

如果尝试访问我没有分配/属于我的内存,这不应该崩溃吗?

c

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

ReactJS:如何在Jest中使用动作触发reducer

我正在为减速机测试工作.但是具有动作功能的减速器的返回状态是异常的.

reducer.react-test.js

import reducer from '../../test_module/reducer';

describe('Test Reducer', () => {

  const initStatus = { id: -1, list: [] };

  it('1. has default state', () => {    
    expect(reducer(initStatus, { type: 'unexpected' })).toEqual({
      ...initStatus
    });    
  });

  it('2. has added once', () => {    
    expect(reducer(initStatus, { type: "ADD" })).toEqual({
      ...initStatus,
      id: 0,
      list: [0],
    });   
  });

  it('3. has added twice', () => {    
    const afterAddOnce = reducer(initStatus, { type: "ADD" });
    expect(reducer(afterAddOnce, { type: "ADD" })).toEqual({
      ...initStatus,
      id: 1,
      list: [0,1],
    }); …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs jestjs redux

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