在Ubuntu机器上:
$ php -v
PHP 5.5.10-1~dotdeb.1 (cli) (built: Mar 6 2014 18:55:59)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
with uopz v2.0.4, Copyright (c) 2014, by Joe Watkins <krakjoe@php.net>
with Zend OPcache v7.0.3, Copyright (c) 1999-2014, by Zend Technologies
with Xdebug v2.2.3, Copyright (c) 2002-2013, by Derick Rethans
Run Code Online (Sandbox Code Playgroud)
我的test.php文件很简单:
<?php
exit(1);
Run Code Online (Sandbox Code Playgroud)
我希望这个命令php test.php || echo "error"显示"错误",但它退出状态代码为0.
$ php test.php
$ echo $?
0
Run Code Online (Sandbox Code Playgroud)
但在同一台机器上相同的代码,但不是在文件中按预期工作:
$ php -r "exit(1);" || echo "error" …Run Code Online (Sandbox Code Playgroud) 我刚刚在一些 js 导入中发现了“~/”
import { Foo, Bar, Baz } from "~/types/schema"
Run Code Online (Sandbox Code Playgroud)
这有点令人困惑,因为“~”通常表示$HOME目录。对于我的一生 - 我无法用谷歌搜索答案。
我找到的唯一答案是What is the ~ (tilde) do in this javascript import?
处理import {IDispatch} from '~react-redux~redux';使用波浪号,但不作为 int 路径~something而不是~/something)
rake assets:precompile
Run Code Online (Sandbox Code Playgroud)
创建像application-be2b8c92856ffacee861d9e9c2935e3e这样的新文件,但有一个名为application-c730047bc2a5cf3a706aa3a9f998ab77.css的旧文件.它将永远不会被使用.有没有办法清理变更后的资产?我不想删除所有资产目录,因为这对于所有那些未被触及的文件来说似乎有些过分(并且它在git中看起来很糟糕)
我希望Recoverable模块为我的用户发送带有重置密码链接的"邀请"电子邮件(该应用仅限邀请),我在初始化程序中部分声明了方法:
module Devise
class Mailer
def invite_new_user(record)
devise_mail(record, :invitation_instructions)
end
end
end
module Devise
module Models
module Recoverable
def send_invite_user_instructions!
return unless status == User::STATUS_PENDING
generate_reset_password_token!
::Devise.mailer.invite_new_user(self).deliver
end
end
end
end
Run Code Online (Sandbox Code Playgroud)
可恢复性很好地扩展,但它说我的邮件程序没有invite_new_user方法(rails console输出):
1.9.2p290 :002 > user.send_invite_user_instructions!
User Load (1.4ms) SELECT "users".* FROM "users" WHERE "users"."reset_password_token" = 'zMQK1CEXYupjNKpH8dph' LIMIT 1
(0.3ms) BEGIN
(15.0ms) UPDATE "users" SET "reset_password_token" = 'zMQK1CEXYupjNKpH8dph', "updated_at" = '2012-05-01 17:40:32.085256' WHERE "users"."id" = 59
(4.5ms) COMMIT
NoMethodError: undefined method `invite_new_user' for Devise::Mailer:Class
Run Code Online (Sandbox Code Playgroud)
但是在同一控制台会话中调用has方法:
1.9.2p290 :003 > ::Devise.mailer.method_defined? …Run Code Online (Sandbox Code Playgroud) 当在 pry 调试会话期间,我想检查FooClass.new.foo我会在 pry 控制台中执行此操作的分步执行时
$ FooClass.new.foo #this gives me path and line of the method
break /path/to/foo_class.rb:LINE_WHERE_FOO_IS_DEFINED
FooClass.new.foo
Run Code Online (Sandbox Code Playgroud)
这有效,但我需要查找路径、行,它会留下一个断点,我有时必须删除。
有一个更快的方法:
break FooClass#foo
FooClass.new.foo
Run Code Online (Sandbox Code Playgroud)
但还是两步,断点还在。
有没有办法在一个命令中做到这一点,比如
step-into FooClass.new.foo
Run Code Online (Sandbox Code Playgroud)
这将启动一个 Pry 子会话,进入方法执行,在它退出/完成后,我又回到了原始会话中,没有多余的断点了?
换句话说:我正在调试中,并且在之前看到了一个名为几行的方法(我无法立即进入它)。我不想把 abinding.pry放在源代码中(再次启动调试会话可能需要很多时间)。
我创建了一个 VueJs 项目并将其部署到 AWS。我已经根据文档 (Real-World Example section)对项目进行了 dockerized 。我刚刚添加了一行来复制我的 nginx conf 文件,如下所示:
# build stage
FROM node:lts-alpine as build-stage
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build
# production stage
FROM nginx:stable-alpine as production-stage
COPY --from=build-stage /app/dist /usr/share/nginx/html
COPY confs/nginx/nginx.conf /etc/nginx/nginx.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
Run Code Online (Sandbox Code Playgroud)
然后我意识到当我检查页面 url 时我的 css 不起作用。我也有一个这样的conf文件:
events {
worker_connections 4096; ## Default: 1024
}
http {
server {
listen 80;
location / {
root …Run Code Online (Sandbox Code Playgroud) 我之前安装过 Laravel,并删除了该文件夹,现在几个月后我安装了 Laravel 安装程序,但当我laravel new在 Windows Powershell 中编写命令时,它返回此错误。
_ _
| | | |
| | __ _ _ __ __ ___ _____| |
| | / _` | '__/ _` \ \ / / _ \ |
| |___| (_| | | | (_| |\ V / __/ |
|______\__,_|_| \__,_| \_/ \___|_|
In NewCommand.php line 153:
Application already exists!
new [--dev] [--jet] [-f|--force] [--] [<name>]
Run Code Online (Sandbox Code Playgroud) 我使用Mocha,Test :: Unit和delayed_job来测试是否已经执行了mailer方法,如下所示:
test "should send info about paid payment" do
payment = Payment.new :contractor_name => "notempty", :address => "notempty"
UserMailer.expects(:send_payment_info)
payment.set_paid!
end
# model method
def set_paid!
self.status = 'paid'
self.paid_at = Date.today
self.save!
UserMailer.delay.send_payment_info self
end
Run Code Online (Sandbox Code Playgroud)
不使用延迟方法测试按预期工作,但有了它(我在初始化器配置中有Delayed :: Worker.delay_jobs =!Rails.env.test?)我得到:
NoMethodError:未定义的方法
deliver' for nil:NilClass app/models/payment.rb:33:inset_paid!' test/unit/payment_test.rb:50:in,test_should_send_info_about_paid_payment'
我不知道如何解决这个问题?也许我应该以不同的方式使用UserMailer?
在尝试在openSuse上安装RedCloth时,我得到了这个错误:
sudo gem install RedCloth
Building native extensions. This could take a while...
ERROR: Error installing RedCloth:
ERROR: Failed to build gem native extension.
/usr/bin/ruby extconf.rb
creating Makefile
make
sh: make: nie znaleziono polecenia
Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/RedCloth-4.2.3 for inspection.
Results logged to /usr/lib/ruby/gems/1.8/gems/RedCloth-4.2.3/ext/redcloth_scan/gem_make.out
Run Code Online (Sandbox Code Playgroud)
我试图谷歌这个并且把所有东西都搞砸了.所以我需要帮助.
我不知道为什么我的红宝石中会发生这种情况,但是您看到同样的行为吗?
3.1.2 :001 > ["url", "label:from", "label:type", "label:batch", "note"].index('url')
=> nil
Run Code Online (Sandbox Code Playgroud)
3.1.2 :002 > ["url", "label:from", "label:type", "label:batch", "note"].index('note')
=> 4
Run Code Online (Sandbox Code Playgroud)
3.1.2 :003 > ["Url", "label:from", "label:type", "label:batch", "note"].index('Url')
=> 0
Run Code Online (Sandbox Code Playgroud)
小写时找不到“url”。这是保留字吗?
编辑:似乎无法找到第一次出现的“url”字符串:
["note", "url", "label:from", "label:type", "label:batch", "note", "url"].index 'url'
=> 6
Run Code Online (Sandbox Code Playgroud)