我正在运行其网站中提到的这个kafka生产者示例
代码:
public class TestProducer {
public static void main(String[] args) {
long events = Long.parseLong(args[0]);
Random rnd = new Random();
Properties props = new Properties();
props.put("metadata.broker.list", "host.broker-1:9093, host.broker-2:9093, host.broker-3:9095");
props.put("serializer.class", "kafka.serializer.StringEncoder");
props.put("partitioner.class", "test.app.SimplePartitioner");
props.put("request.required.acks", "1");
ProducerConfig config = new ProducerConfig(props);
Producer<String, String> producer = new Producer<String, String>(config);
for (long nEvents = 0; nEvents < events; nEvents++) {
long runtime = new Date().getTime();
String ip = "192.168.2." + rnd.nextInt(255);
String msg = runtime + ",www.example.com," + ip;
KeyedMessage<String, String> data …Run Code Online (Sandbox Code Playgroud) 嗨我有一个问题,在iOS8中旋转Modal呈现的ViewController.这一切在iOS7及更低版本上运行良好.
应用结构:
我的问题是当我提出模态控制器时旋转设备时,模态控制器的视图没有调整到景观框架.
看起来像这样:
调用了旋转方法,当我手动将视图的框架设置为横向时,右侧(屏幕灰色侧)的用户交互不起作用.
RootController代码:
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationPortrait;
}
- (NSUInteger) supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}
Run Code Online (Sandbox Code Playgroud)
模态控制器代码:
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskAll;
}
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
duration:(NSTimeInterval)duration
{
if (self.presentingViewController != nil) {
[self.presentingViewController willAnimateRotationToInterfaceOrientation:toInterfaceOrientation
duration:duration];
}
}
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
duration:(NSTimeInterval)duration
{
if (self.presentingViewController != nil) {
[self.presentingViewController willRotateToInterfaceOrientation:toInterfaceOrientation
duration:duration];
}
}
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
if (self.presentingViewController != nil) {
[self.presentingViewController didRotateFromInterfaceOrientation:fromInterfaceOrientation];
}
}
- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator
{
[super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
[coordinator animateAlongsideTransition:^(id<UIViewControllerTransitionCoordinatorContext> context) {
} …Run Code Online (Sandbox Code Playgroud) 我有这两个代码片段似乎应该产生相同的结果,但后者导致错误.
1:
my $href = undef;
my @values = values %{ $href };
# OK - @values is empty
Run Code Online (Sandbox Code Playgroud)
2:
my $href = undef;
my %hash = %{ $href }; # <-- Error here
my @values = values %hash;
# ERROR: Can't use an undefined value as a HASH reference
Run Code Online (Sandbox Code Playgroud)
为什么values在同一行中允许它工作?我宁愿他们都抛出错误,因为使用未定义的值作为哈希引用显然是一个错误.我没有更新的perl版本可供测试,但这在5.8.8和5.10.1中是可重现的.
所以,我只是追踪了一个可以在这个简单的子程序中演示的错误:
sub foo {
my $bar = shift or die "Missing bar", # <--- not a semicolon
my @items = ();
push @items, $bar;
return @items;
}
Run Code Online (Sandbox Code Playgroud)
显然,错误是子程序的第一行以逗号结尾.这有一些相当不寻常的后果,可以看出:
say foo(1); # 1
say foo(1); # 11
say foo(1); # 111
say foo(1); # 1111
Run Code Online (Sandbox Code Playgroud)
现在,我知道这不是语法错误,因为逗号运算符的工作原理.据我所知,@items没有设定,()因为or没有达到右侧.我的问题是,如何my在子程序内部声明的变量允许数据在子程序调用之间持续存在?看起来好像my变成了our某种程度.
Jquery是否有更简单/更短的方式来编写这样的if语句:
if(number === "0" ) { degrees = "-160"; }
if(number === "1" ) { degrees = "-158"; }
if(number === "2" ) { degrees = "-156"; }
if(number === "3" ) { degrees = "-154"; }
if(number === "4" ) { degrees = "-152"; }
if(number === "5" ) { degrees = "-150"; }
if(number === "6" ) { degrees = "-148"; }
if(number === "7" ) { degrees = "-146"; }
if(number === "8" ) { degrees = …Run Code Online (Sandbox Code Playgroud) 我想分割字符串中的每个字符并将其输出为逗号或制表符分隔字符:我需要使用file_inandfile_out因为我有很多行。
输入
TTTGGC
TTTG
TGCAATGG
....
....
Run Code Online (Sandbox Code Playgroud)
输出
T,T,T,G,G,C
T,T,T,G
T,G,C,A,A,T,G,G
Run Code Online (Sandbox Code Playgroud)
我已经使用过这个,但它垂直打印每个字符:
/usr/bin/perl
use strict;
use warnings;
my $data = 'Becky Alcorn';
my @values = split(undef,$data);
foreach my $val (@values) {
print "$val\n";
}
exit 0;
Run Code Online (Sandbox Code Playgroud) 1064:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''models'( 'model_id' INT NOT NULL AUTO_INCREMENT PRIMARY KEY, 'model_usernam' at line 1
Run Code Online (Sandbox Code Playgroud)
我尝试创建sql表时出现此错误.
这是代码..请帮忙..
$sql = "CREATE TABLE IF NOT EXISTS 'models'(
'model_id' INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
'model_username' VARCHAR(250) NOT NULL,
'model_gender' ENUM('f','m','s','c') NOT NULL,
'model_show' ENUM('public','private','group','away') NOT NULL,
'model_age' INT NOT NULL,
'model_time' INT NOT NULL,
'model_new' TINYINT(1) NOT NULL default '0', …Run Code Online (Sandbox Code Playgroud) perl ×3
apache-kafka ×1
if-statement ×1
ios ×1
ios8 ×1
javascript ×1
jquery ×1
objective-c ×1
php ×1
r ×1
rotation ×1
scope ×1
sql ×1
variables ×1