小编gri*_*rim的帖子

Composer无法运行安装后脚本

尝试在Composer post install/update挂钩中运行bash脚本时出现以下错误:

> post-install.sh
sh: 1: post-install.sh: not found
Script post-install.sh handling the post-install-cmd event returned with an error



  [RuntimeException]
  Error Output: sh: 1: post-install.sh: not found
Run Code Online (Sandbox Code Playgroud)

原始composer.json

可以工作,但更新后安装/更新命令以便在两个地方运行真的很烦人.

{
  "require": {
    "twbs/bootstrap": "3.3.5"
    ...
    ...
  },
  "scripts": {
    "post-install-cmd": [
      "mkdir -p _libraries",
      "cp -r vendor/twbs/bootstrap/dist _libraries/bootstrap/",
      ...
      ...
    ],
    "post-update-cmd": [
      "mkdir -p _libraries",
      "cp -r vendor/twbs/bootstrap/dist _libraries/bootstrap/",
      ...
      ...
    ]
  }
}
Run Code Online (Sandbox Code Playgroud)

根据Composer文档:

用Composer的术语表示,脚本可以是PHP回调(定义为静态方法),也可以是任何命令行可执行命令.

所以我composer.json应该能够这样工作:

想要composer.json

{
  "require": {
    "twbs/bootstrap": "3.3.5"
    ... …
Run Code Online (Sandbox Code Playgroud)

bash composer-php

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

MySQL查询中两个Spacial点之间的距离(米)

我正在尝试查询MySQL数据库(版本5.7.15)以检索距离某些坐标300米范围内的所有位置(在我的情况下为40.7542,-73.9961):

SELECT *
FROM location 
WHERE st_distance_sphere(latlng, POINT(40.7542, -73.9961)) <= 300
Run Code Online (Sandbox Code Playgroud)

MySQL文档:

ST_Distance_Sphere(g1,g2 [,radius])

返回球体上两点和/或多点之间的最小球面距离(米),如果任何几何参数为NULL或空,则返回NULL.

不幸的是,该查询还返回距离POINT(40.7542,-73.9961)超过300米的点,例如:

  • POINT(40.7501,-73.9949)(现实生活中约470米)
  • POINT(40.7498,-73.9937)(现实生活中约530米)

mysql geospatial

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

Greenbot Eventbus 3.0:onEvent,onEventMainThread,onEventBackgroundThread和onEventAsync有什么区别?

我有点混淆的使用onEvent,onEventMainThread,onEventBackgroundThreadonEventAsyncGreenrobot的EventBus 3.0

从我在文档中看到的:

  • onEventThreadMode.POSTING(默认)一起使用
  • onEventMainThread 与...一起使用 ThreadMode.MAIN
  • onEventBackgroundThread 与...一起使用 ThreadMode.BackgroundThread
  • onEventAsync 与...一起使用 ThreadMode.ASYNC

但是在事件从后台线程发布的情况下:

@Subscribe(threadMode = ThreadMode.MAIN)
public void onEventMainThread(MyEvent event) {
    // some UI manipulation
}
Run Code Online (Sandbox Code Playgroud)

具有与以下完全相同的行为:

@Subscribe(threadMode = ThreadMode.MAIN)
public void onEvent(MyEvent event) {
    // some UI manipulation
}
Run Code Online (Sandbox Code Playgroud)

和:

@Subscribe
public void onEventMainThread(MyEvent event) {
    // some UI manipulation
}
Run Code Online (Sandbox Code Playgroud)

抛出,CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch …

java android event-bus greenrobot-eventbus greenrobot-eventbus-3.0

7
推荐指数
2
解决办法
4320
查看次数

bootstrap scrollspy不工作

这就是我面临的问题.

http://bittu.github.com/folderGrid/

它首先突出显示最后一个选项卡,当滚动时,它在每个滚动步骤上仅在两个标签之间切换.

这是我使用的一小段代码.

<body data-spy="scroll" data-target=".subnav" data-offset="50">

<div class="subnav">
    <ul class="nav nav-pills">
        <li><a href="#contents">Contents</a></li>
        <li><a href="#config">Config Options</a></li>
        <li><a href="#usage">Usage</a></li>
        <li><a href="#examples">Examples</a></li>
    </ul>
</div>

<div class="row">
    <div class="span12">
        <section id="contents">
            ....
        </section>
        <section id="config">
            ....
        </section>
        <section id="usage">
            ....
        </section>
        <section id="examples">
            ....
       </section>
    </div>
</div>
Run Code Online (Sandbox Code Playgroud)

包括所有必要的文件.并尝试了所有数字data-offset

twitter-bootstrap twitter-bootstrap-2

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

Flask中的内部重定向

简而言之:

通过仅使用Flask微框架(及其依赖项),我们可以执行从一个路由到另一个路由的内部重定向吗?

例如:

  1. 用户提交注册表(两者usernamepassword)@app.route('/register', methods=['POST'])
  2. 如果注册成功,Flask会在内部执行HTTP POST以@app.route('/login', methods['POST'])传递usernamepassword
  3. 处理并登录用户

细节:

我正在使用FlaskFlask-JWT扩展构建REST API .更具体地说,我正在实施登录和注册.

登录工作正常,并返回带有令牌的JSON对象.

以下是我的(登录)身份验证处理程序(即/auth(POST请求) - 默认Flask-JWT身份验证URL规则):

@jwt.authentication_handler
def authenticate(username, password):
    user = User.query.filter_by(username=username).first()
    if user and user.verify_password(password):
        return user
    return None
Run Code Online (Sandbox Code Playgroud)

成功登录返回:

{
  "token": "<jwt-token>"
}
Run Code Online (Sandbox Code Playgroud)

以下是我的注册路线:

@app.route('/register', methods=['PUT'])
def register():
    username = request.form.get('username')
    password = request.form.get('password')
    if username is None or password is None:
        abort(400)  # missing parameters …
Run Code Online (Sandbox Code Playgroud)

python registration flask flask-jwt

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

Vuetify:如何将图标和长文本对齐在同一行?

在我的 vue.js 2.5.7 / vuetify": "^1.0.8" 应用程序中,我使用一张卡片,其标题包含一些文本,文本左侧有一个图标:

    <v-card class="p-3" tile="true">

        <v-card-title class="headline">
            <v-icon color="teal" class="a_link" v-if="confirm_modal_dialog_icon" left="true">{{ confirm_modal_dialog_icon }}</v-icon>
            {{ confirm_modal_dialog_confirm_text }}
        </v-card-title>

        <v-card-text v-if="confirm_modal_dialog_detailed_text">
            {{ confirm_modal_dialog_detailed_text }}
        </v-card-text>
Run Code Online (Sandbox Code Playgroud)

如果confirm_modal_dialog_confirm_text变量包含长文本,则标题跨越两行:

  1. 图标
  2. 文本

我可以使图标(左侧)和长文本始终显示在同一行吗?如果是的话怎么办?

谢谢!

vuetify.js

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

Ziparchive 无法仅在 PHP 中打开 zip 文件

我正在尝试使用 PHP ZipArchive类解压缩文件,但是当我尝试时:

$file = '/path/to/zip/file.zip';
$zip = new ZipArchive();
$res = $zip->open($file, ZipArchive::CHECKCONS);
Run Code Online (Sandbox Code Playgroud)

结果是ZipArchive::ER_INCONS(Zip存档不一致)

现在,我已经能够在桌面 (Windows 7) 上打开 zip 文件,并在运行 PHP 应用程序的同一机器 (Ubuntu 12.04) 上使用bash命令行工具。unzip我什至可以使用 PHP 解压缩文件exec('unzip', $file);

我已经检查了缓存文件夹和 zip 文件的权限,并且网络服务器具有读取和写入权限。我可以使用 PHP 的 ZipArchive 类打开同一目录中的其他 zip 文件。

我不确定它是否相关,但我尝试打开的 zip 文件包含两个 zip 文件。

关于为什么会发生这种情况有什么想法吗?

php bash ziparchive

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