小编cyb*_*ron的帖子

在Java中加入路径

Python我可以加入两个路​​径os.path.join:

os.path.join("foo", "bar") # => "foo/bar"
Run Code Online (Sandbox Code Playgroud)

我试图在Java中实现同样的目标,而不用担心是否OS存在Unix,Solaris或者Windows:

public static void main(String[] args) {
    Path currentRelativePath = Paths.get("");
    String current_dir = currentRelativePath.toAbsolutePath().toString();
    String filename = "data/foo.txt";
    Path filepath = currentRelativePath.resolve(filename);

    // "data/foo.txt"
    System.out.println(filepath);

}
Run Code Online (Sandbox Code Playgroud)

我期待那Path.resolve( )会加入我的当前目录/home/user/testdata/foo.txt制作/home/user/test/data/foo.txt.我错了什么?

java

91
推荐指数
6
解决办法
6万
查看次数

在R中带有"Shiny"的模糊搜索框小部件?

有没有人根据模糊匹配创建或看到一个闪亮的应用程序,其中包含搜索框小部件,在您键入时提供上下文建议

彭博终端使用它,谷歌使用它.其中一种可能的底层技术叫做elasticsearch.org模糊查询,有两个R实现:

  1. duncantl/RElasticSearch
  2. ropensci/elastic

搜索框过滤器的基本到来Shiny数据表并不完全切断它.

如果这是尚未与Shiny集成的内容,那么任何粗略的指南如何构建它?我怀疑当你想查找特定的行而没有显示完整的表时,它对于包含大量文本的biggish表(或文档)非常有用.

fuzzy-search r elasticsearch shiny

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

不同整数类型之间的差异

我想知道uint32_t和之间有什么区别uint32,当我查看头文件时它有这个:

types.h:

    /** @brief 32-bit unsigned integer. */
    typedef unsigned int uint32;
stdint.h:

    typedef unsigned   uint32_t;
Run Code Online (Sandbox Code Playgroud)

这只会带来更多问题:有什么区别

unsigned varName;
Run Code Online (Sandbox Code Playgroud)

unsigned int varName;
Run Code Online (Sandbox Code Playgroud)

我在用 MinGW.

c c++

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

在C++中灌输的目的是什么?

我今天正在使用一些代码,我看到:

extern std::locale g_classicLocale;
class StringStream : public virtual std::ostringstream
{
 public:
        StringStream() { imbue(g_classicLocale); }
        virtual ~StringStream() {};
};
Run Code Online (Sandbox Code Playgroud)

然后我面对imbue.这个imbue函数在C++中的用途是什么?它有什么作用?使用imbue(非线程安全,内存分配)是否存在任何潜在问题?

c++

14
推荐指数
2
解决办法
9700
查看次数

检查是否至少选择了一个单选按钮 - JavaScript

假设我有以下HTML形式:

<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  <title>Choose</title>
</head>

<body>
  <form method="post" enctype="application/x-www-form-urlencoded">
    <h1>Choose</h1>

    <p><input type="radio" name="choose" value="psychology"><font size="5" color="#0033CC">Instant Psychology</font><br>
    <br>
    <input type="radio" name="choose" value="geography"><font size="5" color="#CC0000">Instant Geography</font><br>
    <br>
    <input type="radio" name="choose" value="gastronomy"><font size="5" color="#660033">Instant Gastronomy</font><br>
    <br>
    <input type="submit" name="Submit" value="Go"></p>
  </form>


</body><link rel="stylesheet" type="text/css" href="data:text/css,"></html>
Run Code Online (Sandbox Code Playgroud)

如何编写JavaScript函数以确保至少选择了一个无线电输入?

javascript

14
推荐指数
4
解决办法
6万
查看次数

查看日期时间之间是否已经过了24小时 - Python

我有以下方法:

# last_updated is a datetime() object, representing the last time this program ran
def time_diff(last_updated):
    day_period = last_updated.replace(day=last_updated.day + 1, 
                                      hour=1,
                                      minute=0,  
                                      second=0,
                                      microsecond=0)
    delta_time = day_period - last_updated
    hours = delta_time.seconds // 3600
    # make sure a period of 24hrs have passed before shuffling
    if hours >= 24:
        print "hello"
    else:
        print "do nothing"
Run Code Online (Sandbox Code Playgroud)

我想知道从那以后24小时过去了last_updated,我怎么能这样做last_updated呢?

python timezone datetime

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

ReferenceError:函数未定义 - JavaScript

我正在尝试在后端创建Javascript聊天Python.这是我正在使用的代码......

<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>UDP Chat</title>
  <!-- including JQuery just to simplify things -->
  <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
  <script type="javascript/text">
    var chat_room_id = undefined;
    var last_received = 0;

    /**
     * Initialize chat:
     * - Set the room id
     * - Generate the html elements (chat box, forms & inputs, etc)
     * - Sync with server
     * @param chat_room_id the id of the chatroom
     * @param html_el_id the id of the html element where the chat …
Run Code Online (Sandbox Code Playgroud)

html javascript

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

如何阻止我的批处理文件打印正在运行的代码?

我有以下脚本:

FOR %%i IN (1 2 3) DO (     
    IF %%i==1 ( 
       ECHO %%i 
    )
    IF %%i==2 ( 
       ECHO %%i 
    )
    IF %%i==3 ( 
       ECHO %%i 
    )
)
Run Code Online (Sandbox Code Playgroud)

我只想打印

1
2
3
Run Code Online (Sandbox Code Playgroud)

因为我将再次使用相同的逻辑来编写更完整的任务......我不是Windows的人,我不知道如何做到这一点batch.相反,我得到:

c:\>FOR %i IN (1 2 3) DO (
IF %i == 1 (ECHO %i  )
 IF %i == 2 (ECHO %i  )
 IF %i == 3 (ECHO %i  )
)

c:\>(
IF 1 == 1 (ECHO 1  )
 IF 1 == 2 (ECHO 1  ) …
Run Code Online (Sandbox Code Playgroud)

windows batch-file

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

close函数无法识别 - C++

我在一个名为的文件中有以下代码RaftLog.cc:

#include <algorithm>
#include <fcntl.h>
#include <sys/stat.h>



namespace LogCabin {
namespace Server {
namespace RaftConsensusInternal {

namespace FilesystemUtil = Storage::FilesystemUtil;

namespace {
bool
fileToProto(const std::string& path, google::protobuf::Message& out)
{
    int fd = open(path.c_str(), O_RDONLY);
    if (fd == -1)
        return false;
    else
        close(fd);
    FilesystemUtil::FileContents file(path);

        // more code down here, not useful to the problem.
Run Code Online (Sandbox Code Playgroud)

但是,当我编译时,我有:

build/Server/RaftLog.cc: In function ‘bool LogCabin::Server::RaftConsensusInternal::{anonymous}::fileToProto(const string&, google::protobuf::Message&)’:
build/Server/RaftLog.cc:43:17: error: ‘close’ was not declared in this scope
build/Server/RaftLog.cc: In function ‘void LogCabin::Server::RaftConsensusInternal::{anonymous}::protoToFile(google::protobuf::Message&, const string&)’: …
Run Code Online (Sandbox Code Playgroud)

c c++ unix

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

fwrite和write之间的主要区别是什么?

我正在编写一个回调函数C:

static size_t writedata(void *ptr, size_t size, size_t nmemb, void *stream){

        size_t written = fwrite(ptr, size, nmemb, (FILE)*stream);
        return written;
}
Run Code Online (Sandbox Code Playgroud)

此函数将用于另一个函数,该函数执行HTTP请求,检索请求并将其写入本地计算机.该writedata功能将用于后面的部分.整个操作必须是multithreaded,所以我write和之间存在疑问fwrite.可能有人帮助我,概述之间的差异write(),并fwrite()C,所以我可以选择哪一个最适合到我的问题吗?

c c++

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

标签 统计

c++ ×4

c ×3

javascript ×2

batch-file ×1

datetime ×1

elasticsearch ×1

fuzzy-search ×1

html ×1

java ×1

python ×1

r ×1

shiny ×1

timezone ×1

unix ×1

windows ×1