小编gan*_*lf3的帖子

是否可以在btrfs文件系统上获取文件的压缩和未压缩大小?

是否可以确定启用透明压缩ls -lbtrfs文件系统上的压缩大小(我假设是列出的内容)和未压缩文件大小?

compression filesystems shell file filesize

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

将字符串拆分为数组而不删除分隔符?

我有一个字符串

 "asdf a  b c2 "
Run Code Online (Sandbox Code Playgroud)

我想将它拆分成这样的数组:

["asdf", " ", "a", " ", " ", "b", " ", "c2", " "]
Run Code Online (Sandbox Code Playgroud)

使用string.split(" ")删除空格,结果如下:

["asdf", "a", "", "b", "c2"]
Run Code Online (Sandbox Code Playgroud)

我想插入额外的分隔符,例如

string.replace(/ /g, "| |").replace(/||/g, "|").split("|");
Run Code Online (Sandbox Code Playgroud)

但这会产生意想不到的结果.

javascript jquery

18
推荐指数
3
解决办法
4203
查看次数

使元素的宽度与动态大小的图像相同?

我有一个响应式幻灯片式布局,每个图像下方都有标题.

我试图让标题与图像的宽度相同.问题是图像被缩放以垂直适合浏览器,我的标题是在缩放之前获得图像的宽度.

小提琴

#big_container {
  display:block;
	position:relative;
	width:100%;
	padding-bottom:40%;
	white-space:nowrap;
	overflow-x:scroll;
	overflow-y:hidden;
}
    
#big_container>div {
	position:absolute;
	top:0;
	right:0;
	bottom:0;
	left:0;
}

.little_container {
	display:inline-block;
	height:100%;
	width:100%;
	text-align:center;
}

#big_container figure {
  display:inline-block;
	height:100%;
	margin:0;
}

figure img {
	max-height:calc(100% - 40px); /* subtract height of caption */
}

figcaption {
	display:block;
	width:100%;
	text-align:left;
	box-sizing:border-box;
	margin:0;
	padding:10px;
	line-height:20px;
	background-color:#ddd;
}
Run Code Online (Sandbox Code Playgroud)
<div id="big_container">
  <div>

  <div class="little_container">
      <figure>
        <img src="http://placekitten.com/500/440">
        <figcaption>
          have a kitty!!1
        </figcaption>
      </figure>
  </div>
  
  <div class="little_container">
      <figure>
        <img src="http://placekitten.com/450/400">
        <figcaption> …
Run Code Online (Sandbox Code Playgroud)

html css

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

Python asyncio:未来还没有使用yield?

我正在尝试使用asyncio来进行异步客户端/服务器设置.

出于某种原因,我AssertionError: yield from wasn't used with future在运行客户端时得到了.

搜索此错误并未发生太多变化.
这个错误意味着什么,是什么导致它?

#!/usr/bin/env python3

import asyncio
import pickle
import uuid

port = 9999

class ClientProtocol(asyncio.Protocol):
    def __init__(self, loop):
        self.loop = loop
        self.conn = None
        self.uuid = uuid.uuid4()
        self.other_clients = []

    def connection_made(self, transport):
        print("Connected to server")
        self.conn = transport

        m = "hello"
        self.conn.write(m)

    def data_received(self, data):
        print('Data received: {!r}'.format(data))


    def connection_lost(self, exc):
        print('The server closed the connection')
        print('Stop the event loop')
        self.loop.stop()



# note that in my use-case, main() is …
Run Code Online (Sandbox Code Playgroud)

python python-asyncio

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

为什么this.parent()不是定义为函数?

的jsfiddle

我正在创建一个新的按钮元素

$('<button>Remove Entry</button>', { 'type': 'button', 'class': 'delete_button' });
Run Code Online (Sandbox Code Playgroud)

然而,似乎没有定义typeclass属性,控制台打印错误说this.parent()不是一个函数(虽然我很肯定我启用了jquery)

我担心我做了一些简单而愚蠢的事,但我似乎找不到任何错误.

javascript jquery

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

如何使图像标题宽度与图像宽度相匹配?

我试图这样做:

<div class="figure">
  <img src="/some/image.jpg">
  <p class="caption">
    <span class="caption-text">Some caption of any length</span>
   </p>
</div>
Run Code Online (Sandbox Code Playgroud)

因此,标题位于阴影框中,与图像的宽度相同.请注意,.figure有时可以在<td>表格内部,以防万一.它也不应超过父元素的宽度(在必要时缩小图像).

这是我到目前为止所拥有的:

.caption-text {
  font-size: 14px;
  font-family: Lato, proxima-nova, 'Helvetica Neue', Arial, sans-serif;
  font-weight: normal;
  line-height: 0px;
}

.figure {
  max-width: 100%;
  display: inline-block;
  position: relative;
}

.figure img {
  vertical-align: top;
  margin-bottom: 3px;
}

.caption {
  display: block;
  width: 100%;
  position: absolute;
  padding: 10px;
  background-color: #e3e3e3;
  box-sizing: border-box;
  margin: 0;
}
Run Code Online (Sandbox Code Playgroud)
<div style="width:500px">
  <h1>Some Title</h1>

  <!--part I want to style--> …
Run Code Online (Sandbox Code Playgroud)

html css css3

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

添加新插件后,cordova_plugins.js未更新

我刚开始使用带有android的cordova.

添加插件时遇到问题.

我使用cordova插件从Win7中的cmd添加org.apache.cordova.camera.它已添加但不在cordova_plugins.js文件中.

当我在cmd中键入cordova运行android时,文件正在更新,但随后我的所有代码都被删除并替换为基于Web的骨架应用程序.为什么会这样?如何自动更新此文件?

这就是我的cordova_plugins.js的样子:

cordova.define('cordova/plugin_list', function(require, exports, module) {
module.exports = [
    {
        "file": "plugins/org.apache.cordova.dialogs/www/notification.js",
        "id": "org.apache.cordova.dialogs.notification",
        "merges": [
            "navigator.notification"
        ]
    },
    {
        "file": "plugins/org.apache.cordova.dialogs/www/android/notification.js",
        "id": "org.apache.cordova.dialogs.notification_android",
        "merges": [
            "navigator.notification"
        ]
    },
    {
        "file": "plugins/org.apache.cordova.vibration/www/vibration.js",
        "id": "org.apache.cordova.vibration.notification",
        "merges": [
            "navigator.notification"
        ]
    }
];
module.exports.metadata = 
// TOP OF METADATA
{
    "org.apache.cordova.dialogs": "0.2.5",
    "org.apache.cordova.vibration": "0.3.6"
}
// BOTTOM OF METADATA
});
Run Code Online (Sandbox Code Playgroud)

如你所见,没有相机插件.它被添加到我的项目中,但不在此文件中,这是因为当我尝试在我的js文件中使用它时它不起作用.

我希望你明白我在说什么.

android phonegap-plugins cordova

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

GM_getValue未定义(在注入的代码中)?

我看到GM_getValue未定义的错误,但我没有补助GM_getValueGM_setValue与定义的默认值.

示例代码:

// ==UserScript==
// @name        SO_test
// @include     https://stackoverflow.com/*
// @version     1
// @grant       GM_getValue
// @grant       GM_setValue
// ==/UserScript==

// Get jQuery thanks to this SO post:
// https://stackoverflow.com/a/3550261/2730823
function addJQuery(callback) {
    var script = document.createElement("script");
    script.setAttribute("src", "//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js");
    script.addEventListener('load', function() {
        var script = document.createElement("script");
        script.textContent = "window.jQ=jQuery.noConflict(true);(" + callback.toString() + ")();";
        document.body.appendChild(script);
    }, false);
    document.body.appendChild(script);
}

function main() {
$("#wmd-input").on("contextmenu", function(e) {
    e.preventDefault();
    console.log("GM_getValue: " + GM_getValue("extra_markdown", True));
});
}
addJQuery(main); …
Run Code Online (Sandbox Code Playgroud)

greasemonkey code-injection

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

在bash中找出两个日期之间的差异

我试图通过以下方式获得两个日期之间的差异:

date -d $(echo $(date -d "Sun Dec 29 02:22:19 2013" +%s) - $(date -d "Sun Dec 28 03:22:19 2013" +%s) | bc)
Run Code Online (Sandbox Code Playgroud)

但是,这会回来

date: invalid date ‘82800’
Run Code Online (Sandbox Code Playgroud)

为什么会这样,我怎样才能得到理想的结果呢?

bash date

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

如何在linux上的python 3中检测鼠标点击?

我是python的新手,我希望能够在整个屏幕上检测鼠标点击事件.

这个问题与我想要的最接近,但是没有一个答案是非常具有描述性的.

我怎样才能做到这一点?

python

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

为什么这个递归函数返回正确的值?

运行这样的递归函数(在gcc 7.3.1中编译):

#include <stdio.h>

int arr[] = {5,1,2,6,7,3};
int arraySize = 6;

int recfind(int value, int index)
{
    if (arr[index] == value)
        return 1;
    if (index >= arraySize)
        return 0;
    // return recfind(value, ++index);
    recfind(value, ++index);
 }

int main() {
    printf("found 6? %d\n", recfind(6, 0));
    printf("found 9? %d\n", recfind(9, 0));
}
Run Code Online (Sandbox Code Playgroud)

我得到以下输出:

found 6? 1
found 9? 0
Run Code Online (Sandbox Code Playgroud)

为什么这样做?由于recfind未返回递归调用的结果,所以如何选择更高级别调用的返回值?

c recursion return return-value

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