我正在访问返回 JSON 的状态信息端点
watch 'curl localhost:8000/something | jq'
Run Code Online (Sandbox Code Playgroud)
它只返回来自 的“(23) Failedwriting body” jq。这里想要什么jq?
请注意,这在没有该部分的情况下也有效watch?
有谁知道如何在调用函数中观察变量.例如:C#:
void fn a()
{
int myVar=9;
b();
}
b()
{
Throw new Exception();
}
Run Code Online (Sandbox Code Playgroud)
当我在函数b中得到异常时如何观察myVar?我在一个循环中有一个非常大的递归函数,并在一次迭代中得到一个异常.我不知道它属于哪个迭代$%^&*(.我做的是将我的有趣变量推广到全局,所以我可以在任何地方看它们.但是,我不认为这只是调试的好主意.
感谢大家!
我想知道是否有人可以帮助我做一些我认为相当直接的事情:
基本上我想扩展所有数据类型的原型(包括内部类型),以允许某种自定义函数,考虑:
var x = "some string";
var y = 101;
x = "some other value";
y++;
x.onChange();
y.onChange();
Run Code Online (Sandbox Code Playgroud)
这是我之后的基本思想,但我真正想要的是实际上让onChange(在这个例子中)与实际变量(而不是标准原型扩展)的新函数不同,即:
x.onChange = function() {
alert("x.onChange");
}
y.onChange = function() {
alert("y.onChange");
}
Run Code Online (Sandbox Code Playgroud)
这似乎没有用,但我必须错过一些非常简单的事情吗?我的意思是我可以扩展所有对象和类型并添加新功能......不是吗?
任何帮助将不胜感激!
我有
std::string str = "hello world";
std::wstring wstr = L"goodbye world";
std::cout << str << std::endl;
std::wcout << wstr << std::endl;
Run Code Online (Sandbox Code Playgroud)
当我在VS 6.0的调试器"自动"窗口中启动调试并在第三行设置断点时,我得到了:
std::cout {...}
str {0x001f2de1 "hello world"}
wstr {0x001f2e4a}
Run Code Online (Sandbox Code Playgroud)
而且我看不到wstr的价值......
我怎么能配置VS能够这个?
感谢名单
我知道我可以使用w命令为变量和表达式添加监视,是否可以告诉它简单地解析每个命令并停止该命令中是否有某段文本?
像w m/bad command/where这样$_的字符串包含正在执行的下一个命令.
我正在Windows上使用Komodo进行远程CGI调试,但我也可以perl -d在linux shell上使用.
更新:
我会尽量让这个更清楚.有一个文件,磁盘上的数据被删除,我不知道在哪里.我正在调试的程序包含许多彼此需要的.pl文件,而且完整的代码库甚至更大.我当然可以通过这个来获取数据文件名称的一部分(我知道扩展名),或者unlink.但由于我不知道我的程序正在使用哪些代码文件,这不会让我走得太远.
让我们考虑一下这段代码,它将被调试:
if ($foo == 1) {
unlink 'filename.example';
}
Run Code Online (Sandbox Code Playgroud)
现在当我调试这个时,如果下一个即将执行的perl命令(来自脚本)包含/example/,我希望调试器停止.我想要一种在执行下一个命令之前运行的钩子.
这样的话,我也不需要知道那里(在哪一行或文件)的东西,我想打破在是,我也不需要一个变量名(有没有).
我知道这很难解释,但我认为这可能是一个常见的问题.也许完全有另一种方法?
我已经创建了一个应用程序是angularjs,其中我有一个指令,我正在指令中的一个监视器,当$ rootScope变量发生更改时触发指令中的某些方法,但问题是当$ rootScope.name值被更改指令内的手表不起作用
我的代码如下所示
var module = angular.module('myapp', []);
module.controller("TreeCtrl", function($scope, $rootScope) {
$scope.treeFamily = {
name : "Parent"
};
$scope.changeValue = function()
{
$rootScope.name = $scope.userName;
};
});
module.directive("tree", function($compile) {
return {
restrict: "E",
transclude: true,
scope: {},
template:'<div>sample</div>',
link : function(scope, elm, $attrs) {
function update()
{
};
scope.$watch('name', function(newVal, oldVal) {
console.log('calling');
update();
}, true);
}
};
});
Run Code Online (Sandbox Code Playgroud) 任何人都可以提供一个代码示例,如何在类中设置变量更改的观察者?我试图用几种方式使用不同的功能(Scalar :: Watcher,Moo的触发属性)和OOP框架(Moo,Mojo :: Base),但都失败了.
以下是我失败的代码,以便更好地理解我的任务.在这个例子中,我需要每次更改attr1时更新attr2.
使用Mojo :: Base和Scalar :: Watcher:
package Cat;
use Mojo::Base -base;
use Scalar::Watcher qw(when_modified);
use feature 'say';
has 'attr1' => 1;
has 'attr2' => 2;
has 'test' => sub { # "fake" attribute for getting access to $self
my $self = shift;
when_modified $self->attr1, sub { $self->attr2(3); say "meow" };
};
package main;
use Data::Dumper;
my $me = Cat->new;
$me->attr1;
warn Dumper $me;
say $me->attr1(3)->attr2; # attr2 is still 2, but …Run Code Online (Sandbox Code Playgroud) 我尝试在$ route.params.slug更改时使用vuejs的watch属性执行操作,但似乎不起作用...
当我单击到路由器链接时,我的$ route.params.slug实际上发生了变化,但观察者未触发...
有我的app.js
import Vue from 'vue'
import VueRouter from 'vue-router'
import Clients from './components/ClientsComponent'
import Slider from './components/SliderComponent'
import store from './store/store'
require('./bootstrap');
Vue.use(VueRouter)
const routes = [
{path: '/references/clients', component: Slider, name: 'client'},
{path: '/references/clients/:slug-:id', component: Slider, name: 'client.show'}
]
const router = new VueRouter({
mode: 'history',
routes
})
const app = new Vue({
el: '#app',
store: store,
router,
components: {
Clients,
Slider
}
});
Run Code Online (Sandbox Code Playgroud)
我的store.js
import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)
export …Run Code Online (Sandbox Code Playgroud) 我正在VueJS中为正在制作的应用程序创建组件,当var更改时,它具有一些监视程序,可将逻辑应用于组件的其他部分。一旦组件被初始化,在用户通过Axios完成一些事件之后,仍然需要服务器上的一些数据来设置它。这些数据从主应用程序发出的事件到达组件。现在的事情是,此var通常会更改(并非总是更改),但是我不希望第一次应用该逻辑,因此我决定设置一个标志并在watcher中检查它是否返回,但是这没有发生:一旦将该标志设置为true(它检查!this.flag),无论如何都会触发观察程序。这是代码:
data(){
return {
isSet: false,
myVar: {
first: 0,
second: 0
}
}
},
watch: {
'myVar.first': {
handler: function(newVal, oldVal){
if(!this.isSet || other.condition){return}
console.log('first triggered');
},
immediate: false
},
'myVar.second': {
handler: function(newVal, oldVal){
if(!this.isSet || other.condition){return}
console.log('second triggered');
},
immediate: false
}
},
methods: {
setBus(){ // gets called on created(){}
let self = this;
Bus.$on('my-event', function(c){
self.doFirstSet(c);
});
},
doFirstSet(c){
// do other setting
if(c.someCondition){
this.doExtraConfig(c);
}
this.isSet = true; // at this point is when …Run Code Online (Sandbox Code Playgroud) 我尝试查看某些文件以进行更改.但WatchKey我得到watch_object.watch_service.poll(16, TimeUnit.MILLISECONDS);的总是null.没有一个错误打印到控制台,所以我有点迷路.
public class FileWatcher implements Runnable {
public FileWatcher() {
}
static public class Watch_Object {
public File file;
public WatchService watch_service;
}
static public HashMap<Object, Watch_Object> watched_files = new HashMap<>();
static public boolean is_running = false;
static public synchronized void watch(Object obj, String filename) {
File file = new File(filename);
if (file.exists()) {
try {
WatchService watcher = null;
watcher = FileSystems.getDefault().newWatchService();
Watch_Object watch_object = new Watch_Object();
watch_object.file = file;
watch_object.watch_service = …Run Code Online (Sandbox Code Playgroud) watch ×10
debugging ×3
javascript ×2
perl ×2
vuejs2 ×2
angularjs ×1
bash ×1
c# ×1
c++ ×1
curl ×1
java ×1
jq ×1
mojolicious ×1
moo ×1
observable ×1
oop ×1
vue-router ×1
vue.js ×1
wstring ×1