小编Ken*_*ter的帖子

Ubuntu 16 UFW 未登录 /var/log/ufw.log 或其他位置

UFW 未登录任何位置。

ufw配置:

root@localhost:/var/log# ufw status verbose
Status: active
Logging: on (full)
Default: deny (incoming), allow (outgoing), deny (routed)
New profiles: skip

To                         Action      From
--                         ------      ----
2022/tcp                   ALLOW IN    Anywhere
80                         ALLOW IN    Anywhere
2022/tcp (v6)              ALLOW IN    Anywhere (v6)
80 (v6)                    ALLOW IN    Anywhere (v6)

root@localhost:/var/log#
Run Code Online (Sandbox Code Playgroud)

rsyslog 配置:

root@localhost:/var/log# service rsyslog status
? rsyslog.service - System Logging Service
   Loaded: loaded (/lib/systemd/system/rsyslog.service; enabled; vendor preset: enabled)
   Active: active (running) since Tue 2017-02-21 18:43:33 CET; 5min ago
     Docs: man:rsyslogd(8) …
Run Code Online (Sandbox Code Playgroud)

ubuntu ufw ubuntu-16.04

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

DeferredResult 的 Spring MVC 单元测试不调用超时回调

我在 Java 7 上使用 Spring 4.3.18 和 Spring Boot 1.5.14。

我正在实现一个 RestController 端点,它返回DeferredResult带有超时回调的 a 。我正在尝试为超时回调编写单元测试,但无法获得MockMvc调用超时回调的单元测试。

为了测试的目的,我写了这个端点:

@PostMapping("/test")
public DeferredResult<String>
testit() {
    logger.info("testit called");
    final DeferredResult<String> rv = new DeferredResult<>(1000L);
    rv.onTimeout(new Runnable() {
        @Override
        public void run() {
            logger.info("run called");
            rv.setResult("timed out");
        }
    });
    return rv;
}
Run Code Online (Sandbox Code Playgroud)

和这个单元测试:

@Autowired
private MockMvc mockMvc;

@Test
public void testTest() throws Exception {
    MvcResult result = mockMvc.perform(post("/rest/tasks/test"))
        .andExpect(request().asyncStarted())
        .andReturn();
    result.getAsyncResult(1500);
    mockMvc.perform(asyncDispatch(result))
        .andExpect(status().isOk())
        ;
}
Run Code Online (Sandbox Code Playgroud)

(调用result.getAsyncResult(1500)基于https://jira.spring.io/browse/SPR-16869

当我运行此命令时,testit() …

java spring-mvc spring-test-mvc

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

获取外部网页图像的绝对路径

我正在使用bookmarklet,我正在使用HTML DOM解析器获取任何外部页面的所有照片(如前面的回答所提出的那样).我正确地提取照片并显示在我的书签中弹出.但我对照片的相对路径有问题.

例如,外部页面上的照片来源说http://www.example.com/dir/index.php

  1. 照片来源1:img source ='hostname/photos/photo.jpg' - 获取照片,因为它是绝对的

  2. 照片来源2:img source ='/ photos/photo.jpg' - 没有得到,因为它不是绝对的.

我通过当前的url工作,我的意思是使用dirname或pathinfo来获取当前url的目录.但导致host/dir /(主机作为父目录)和host/dir/index.php(host/dir作为父目录,这是正确的)之间的问题

请帮忙我如何获得这些相关照片?

html php dom

0
推荐指数
1
解决办法
1531
查看次数

Xcode应用程序有两个按钮.单击其中任何一个时,都会触发两者的操作.为什么会这样?

这是我在Apple开发者网站上完成教程后的一个示例Twitter应用程序.但我不知道我做错了什么.

接口:

@interface TWTViewController : UIViewController {
NSString* output;
}
@property (nonatomic, copy) NSString* output;
- (IBAction)doTweet:(id)sender;
- (IBAction)getTimeline:(id)sender;
@property (weak, nonatomic) IBOutlet UILabel *outputLabel;
@property (weak, nonatomic) IBOutlet UIButton *tweetButton;

@end
Run Code Online (Sandbox Code Playgroud)

执行:

@implementation TWTViewController
@synthesize output = _output;
@synthesize outputLabel;
@synthesize tweetButton;

...

- (IBAction)doTweet:(id)sender {
    TWTweetComposeViewController *twitter = [[TWTweetComposeViewController alloc] init];
    [twitter setInitialText:@"It's really that simple!"];
    [twitter addImage:[UIImage imageNamed:@"twitter.png"]];
    [self presentViewController:twitter animated:YES completion:nil];
    twitter.completionHandler = ^(TWTweetComposeViewControllerResult res) {
        if(res == TWTweetComposeViewControllerResultDone) {
            UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:@"Success!" …
Run Code Online (Sandbox Code Playgroud)

twitter xcode objective-c ios

0
推荐指数
1
解决办法
535
查看次数

Perl:查找char的最后一次出现"\"

我想从像这样的文件字符串中删除路径:

Root\ToOrganization\Service_b37189b3-8505-4395_Out_BackOffice.xml
Run Code Online (Sandbox Code Playgroud)

我试图找到最后一次出现的"\"的索引,所以我可以使用子串到那里.

但我不能在搜索中使用字符"\".我正在使用"\",但它不起作用......

我正在尝试的代码:

$file = "Root\ToOrganization\Service_b37189b3-8505-4395_Out_BackOffice.xml";
$tmp = rindex($file, "\\");
print $tmp;
Run Code Online (Sandbox Code Playgroud)

我得到的输出:

-1
Run Code Online (Sandbox Code Playgroud)

我能做什么?

regex perl substring escaping indexof

0
推荐指数
1
解决办法
491
查看次数

Apache-camel Seda 端点,BlockWhenFull 未确认

from("seda:myqueue?size=2&blockWhenFull=true").process(sleep());



private Processor sleep() {
                return new Processor() {                    
                    @Override
                    public void process(Exchange exchange) throws Exception {
                        String body = exchange.getIn().getBody(String.class);
                        System.out.println(curTime() + " Going for sleep sleepid=" + body );
                        Thread.sleep(5000l);                        
                        System.out.println(curTime() + " Done sleep sleepid=" + body );
                    }
                };



for (Integer i = 0; i <5; i++) {            
            Exchange exchange = new DefaultExchange(context);
            exchange.setPattern(ExchangePattern.InOnly);
            exchange.getIn().setHeader("header", i);
            exchange.getIn().setBody(i.toString());
           System.out.println("sending msg to seda");
           Exchange send = template.send("seda:myqueue",exchange);
           System.out.println("done:"+i);

        }
Run Code Online (Sandbox Code Playgroud)

BlockWhenFull”未确认,即如果大小设置为 2 并且我在循环中发送 3 条消息,正文为“1”、“2”和“3”,那么我只收到“1”和“2”的睡眠消息,我猜即使我将“ BlockWhenFull”设置为 …

apache-camel

0
推荐指数
1
解决办法
1348
查看次数

警告:忽略'realloc'的返回值,使用属性warn_unused_result声明

我很好奇,我正在用PuTTy 编写C语言,有谁知道我怎么能摆脱这个警告?

警告:忽略'realloc'的返回值,使用属性warn_unused_result声明[-Wunused-result] realloc(strp-> data,nbytes);

                        ^
Run Code Online (Sandbox Code Playgroud)

它想要'警告'我的线的相关代码:

         //If the previously allocated size is > 0 then we can reallocate
         //otherwise we have to make a new allocation in memory
         if(strp->length > 0)
         {
           realloc(strp->data, nbytes);
         }
         else
         {
           *strp = kstralloc(nbytes);
         }
Run Code Online (Sandbox Code Playgroud)

提前致谢

c warnings compiler-warnings

0
推荐指数
1
解决办法
3880
查看次数

Active MQ无法在Apache Camel下运行

尝试连接到Active MQ上的队列时,我收到以下错误消息.

Failed to create route ...because of Failed to resolve endpoint: amq://queue:ROBOMQ.TO.MPM due to: Password must also be provided when using username/password as credentials.
Run Code Online (Sandbox Code Playgroud)

下面的Camel XML中的AMQ bean声明.已经工作了好几个月但现在已经停止了.

<bean id="amq" class="org.apache.activemq.camel.component.ActiveMQComponent">
    <property name="brokerURL" value="tcp://127.0.0.1:61616" />
    <property name="userName" value="${username}" />
    <property name="password" value="${password}" />
</bean>
Run Code Online (Sandbox Code Playgroud)

有任何想法吗?

java activemq-classic apache-camel

0
推荐指数
1
解决办法
362
查看次数

Python:始终运行程序

我希望这段代码永远不会破坏.所以我创建了一个无限循环和一个"goto"到开头,以防它中断.但是,它仍然无法正常工作.

root@xxx:~# cat gmail2.py 
import imaplib, re
import os
import time
import socket
socket.setdefaulttimeout(60)

def again():
        conn = imaplib.IMAP4_SSL("imap.gmail.com", 993)
        conn.login("xx@example.com", "xxx")

        while(True):
                unreadCount = re.search("UNSEEN (\d+)", conn.status("INBOX", "(UNSEEN)")[1][0]).group(1)
                print unreadCount

                if int(unreadCount) > 20:
                        os.system('heroku restart --app sss-xxxx-203')
                #os.system('ls')
                #print "Restarting server...."

                time.sleep(60)

again() 


1
Traceback (most recent call last):
  File "gmail2.py", line 22, in <module>
    again()
  File "gmail2.py", line 12, in again
    unreadCount = re.search("UNSEEN (\d+)", conn.status("INBOX", "(UNSEEN)")[1][0]).group(1)
  File "/usr/lib/python2.6/imaplib.py", line 703, in status
    typ, dat = self._simple_command(name, …
Run Code Online (Sandbox Code Playgroud)

python gmail

-3
推荐指数
1
解决办法
1712
查看次数