小编Pao*_*aJ.的帖子

如何杀死这个不朽的nginx工作者?

我已经启动了nginx,当我像root一样停止时

/etc/init.d/nginx stop
Run Code Online (Sandbox Code Playgroud)

之后我输入

ps aux | grep nginx
Run Code Online (Sandbox Code Playgroud)

并获得响应 tcp LISTEN 2124 nginx WORKER

kill -9 2124  # tried with kill -QUIT 2124, kill -KILL 2124
Run Code Online (Sandbox Code Playgroud)

然后我再次打字

ps aux | grep nginx
Run Code Online (Sandbox Code Playgroud)

并获得响应tcp LISTEN 2125 nginx WORKER 等等.

如何杀死这个不朽的查克诺里斯工人?

linux admin nginx

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

可以将枚举的默认类型设置为unsigned char吗?

我必须将一些枚举打包到byte array(char*)并通过网络发送.可以将枚举的默认类型设置为unsigned char吗?(我现在可以转换或使用& 0xff提取第一个字节/ char,但这需要额外的操作,所以有没有办法在enum的定义中解决这个问题?)

c++

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

如何从列分数中选择最小值和最大值?

如何从列分数中选择最小值和最大值?会话查询可以实现吗?

class Player(Base):
    username = Column(String)
    score = Column(Integer)
    # more not impoortant columns
Run Code Online (Sandbox Code Playgroud)

sqlalchemy

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

Boost找不到未来::然后从demo

我想尝试提升未来,我已经安装了1.55并包含在make文件中,我想尝试官方演示

#define BOOST_THREAD_PROVIDES_FUTURE

#include <boost/thread/future.hpp>

using namespace boost;

int main()
{
  future<int> f1 = async([]() { return 123; });
  future<int> f2 = f1.then([](future<int> f) { return f.get();} );// here .get() won't block });
} 
Run Code Online (Sandbox Code Playgroud)

但我在编译期间总是遇到错误

error: ‘class boost::future<int>’ has no member named ‘then’
Run Code Online (Sandbox Code Playgroud)

当我用f2评论它时,它编译.

c++ boost boost-thread

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

在C++中有类似于Java中的弱引用吗?

在C++中有类似于Java中的弱引用吗?我有游戏中的对象列表(类Soldier,列表是std :: list*enemy),我在其中列出了可见的敌人士兵列表.我的每一个士兵都可以指向敌方士兵(士兵*目标;内部课程).当我的其他地方士兵杀死敌人士兵时,我需要什么(然后杀死士兵从敌人名单中移除)我希望所有具有士兵指针的士兵现在都有空,因为它被删除了.我可以用士兵的身份解决这个问题,并在每个循环中检查是否有同样身份的敌人士兵但似乎是蛮力.我能以更优雅的方式解决这个问题吗(我不能用c ++ 11吗?

class Soldier{
Soldier* target;

public:
// other functions
void shootAtTarget();
};
Run Code Online (Sandbox Code Playgroud)

c++

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

如何检查路径上的目录是否为空?

如果文件夹为空,如何检查Go?我可以检查:

files, err := ioutil.ReadDir(*folderName)
if err != nil {
    return nil, err
}

// here check len of files 
Run Code Online (Sandbox Code Playgroud)

但是我觉得应该有更优雅的解决方案.

directory go

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

如何使用SQLAlchemy实现内连接?

如何使用SQLAlchemy实现内连接?我想做一个简单的聊天

class Base(object):
    def __tablename__(self):
        return self.__name__.lower()

    id = Column(Integer, primary_key=True)

Base = declarative_base(cls=Base)

class PlayerModel(Base):
    __tablename__ = 'players'
    username = Column(String(30), nullable=False)
    email = Column(String(75), nullable=False)
    password = Column(String(128), nullable=False)

class MessageModel(Base):
    __tablename__ = 'messages'
    player_id = Column(Integer,ForeignKey('chats.id'), nullable=False)
    message = Column(String(2000), nullable=False)
    time = Column(TIMESTAMP, server_default=func.now())

    def __repr__(self):
        return "<Message('%s')>" % (self.type)
Run Code Online (Sandbox Code Playgroud)

我想阅读所有比某个日期更年轻的消息,并在结果中列出像这样的词典

[{'username':'x','message':'y','time':'number0'},{'username':'y','message':'z','time':'number1'},
{'username':'x','message':'zz','time':'number'}]
Run Code Online (Sandbox Code Playgroud)

为此我需要内部联接.如何使这个工作?

python sqlalchemy python-2.7

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

如何将float转换为长度为4的字节数组(char*的数组)?

如何将float转换为长度为4的字节数组(char*的数组)?我需要通过网络发送一些数据,tcp,并需要将float作为字节数组发送.(我知道两位小数的精度,所以目前我在客户端乘以100并在服务器上除以100 - 基本上转换为整数然后用&0xff <<操作查找字节).但它很丑陋,可能会在一段时间内失去精确度.

c++

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

编译.so for boost python无法找到模块

我试图将c ++代码包装到python中,只有一个类可以导出两个函数.我编译到map.so,当我试图import map 得到像噪音一样的错误

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: ./map.so: undefined symbol: _ZTIN5noise6module6ModuleE
Run Code Online (Sandbox Code Playgroud)

我的c ++目录看起来像(噪声是dowwnloaded源代码,所有代码都在src中)

/ map.cpp
  real_map.h
  real_map.cpp
  noise/
       src/
          .h and .cpp and new directory
Run Code Online (Sandbox Code Playgroud)

我的CMakeLists.txt看起来像

project (map)
cmake_minimum_required(VERSION 2.8)

find_package(PythonLibs)
include_directories (${PYTHON_INCLUDE_DIRS})

find_package(Boost 1.45.0 COMPONENTS python)
include_directories (${Boost_INCLUDE_DIRS})


add_library (
    map SHARED  
    WrappedMediumMapTile.cpp
)

target_link_libraries (medium_map
    boost_python
    ${PYTHON_LIBRARIES}
    ${Boost_LIBRARIES}
)
Run Code Online (Sandbox Code Playgroud)

有谁知道什么是问题?

我要包装的.cpp类

#include <list>
#include <iostream>
#include <vector>
#include <utility>
#include <map>

#include "noise/src/noise.h"
#include "noiseutils/noiseutils.h"

class MapTile
{ …
Run Code Online (Sandbox Code Playgroud)

c++ python boost boost-python

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

Node.js有virtualenv吗?

我是Node.js的新手.任何人都可以告诉我是否有类似于Python的东西virtualenv?我需要在同一台机器上的不同版本的Node.js上运行应用程序.

node.js

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