我有一组angular2组件,应该都会注入一些服务.我的第一个想法是,最好创建一个超级类并在那里注入服务.然后我的任何组件都会扩展该超类,但这种方法不起作用.
简化示例:
export class AbstractComponent {
constructor(private myservice: MyService) {
// Inject the service I need for all components
}
}
export MyComponent extends AbstractComponent {
constructor(private anotherService: AnotherService) {
super(); // This gives an error as super constructor needs an argument
}
}
Run Code Online (Sandbox Code Playgroud)
我可以通过MyService在每个组件中注入并使用该参数进行super()调用来解决这个问题,但这肯定是某种荒谬的.
如何正确组织我的组件,以便他们从超类继承服务?
我正在使用https://code.google.com/p/apns-php/上提供的apns php服务器.
我已经设置了推送通知证书但我的代码仍然在连接时抛出错误.
这有什么问题?以下是我获取设备令牌的方法:
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)devToken {
#if !TARGET_IPHONE_SIMULATOR
// Prepare the Device Token for Registration (remove spaces and < >)
NSString *deviceToken = [[[[devToken description]
stringByReplacingOccurrencesOfString:@"<"withString:@""]
stringByReplacingOccurrencesOfString:@">" withString:@""]
stringByReplacingOccurrencesOfString: @" " withString: @""];
NSLog(@"%@", deviceToken);
#endif
}
Run Code Online (Sandbox Code Playgroud)
这是我运行服务器时的错误:
Sat, 11 May 2013 13:37:53 -0700 ApnsPHP[18198]: INFO: Trying
ssl://gateway.push.apple.com:2195...
Sat, 11 May 2013 13:37:54 -0700 ApnsPHP[18198]: INFO: Connected to ssl://gateway.push.apple.com:2195.
Sat, 11 May 2013 13:37:54 -0700 ApnsPHP[18198]: INFO: Sending messages queue, run #1: 1 message(s) …Run Code Online (Sandbox Code Playgroud) php objective-c push-notification apple-push-notifications apns-php
我试图使用此代码从网页获取内容:
HttpClient http = new HttpClient();
var response = await http.GetByteArrayAsync("www.nsfund.ir/news?p_p_id=56_INSTANCE_tVzMoLp4zfGh&_56_INSTANCE_tVzMoLp4zfGh_mode=news&_56_INSTANCE_tVzMoLp4zfGh_newsId=3135919&p_p_state=maximized");
String source = Encoding.GetEncoding("utf-8").GetString(response, 0, response.Length - 1);
source = WebUtility.HtmlDecode(source);
HtmlDocument resultat = new HtmlDocument();
resultat.LoadHtml(source);
Run Code Online (Sandbox Code Playgroud)
但我得到这个错误:
提供了无效的请求URI.请求URI必须是绝对URI或必须设置BaseAddress.
我正在使用FeedWordpress从子网页上将新闻导入母公司的新闻栏.
这里可以看到特定项目的RSS摘录:Pastebin
正如您所看到的,我将我需要的图像放入RSS文件中,进入描述块的开头,以及内容:编码块:
<img
width="2400"
height="1350"
src="http://shh.local:8888/content/uploads/2015/10/Skogskullen-2-01.jpg"
class="attachment-full wp-post-image"
alt="Skogskullen 2 01 nyheter"
/>
Run Code Online (Sandbox Code Playgroud)
FeedWordpress正确解析图像并找到它.但这很奇怪,因为导入的内容是相同的图像,但是使用"-150x150"标志调整大小.原来无处可见.
我迫切需要导入才能使用原始图像分辨率.我已经查看了插件的来源,但我不能为我的生活找到任何提及150x150.
我是这两个站点的唯一开发人员,因此我可以使用这两个代码库.我很感激任何帮助或提示,我可以看出来解决这个问题.
我的HTTP响应头中有"Server:Apache",并希望将其删除.我按照说明添加到httpd.conf:
ServerSignature Off
ServerTokens Prod
Header unset Server
Run Code Online (Sandbox Code Playgroud)
但最后一行没有效果.前两行改变了标题的内容(之前它还包含有关OS和PHP的信息),但我需要完全删除它.这该怎么做?
我已经创建了 facebook 应用程序。当我访问它时,我收到以下消息。
在我的应用程序设置中,已经添加了有效的电子邮件 ID,并且我已将应用程序设置为公开。
客户端 OAuth 登录、Web OAuth 登录和嵌入式浏览器 OAuth 登录也设置为“是”。
你能告诉我我在做什么错吗?
假设我有 2 个列表:
L1 = [2,4,1,6]
L2 = [1,5,2,3]
Run Code Online (Sandbox Code Playgroud)
输出应该是一个新列表,其中包含根据 L1 或 L2 的位置找到的最大数字。
示例输出:
L3 = [2, 5, 2, 6]
Run Code Online (Sandbox Code Playgroud)
怎么做 ?
我不明白为什么这不起作用,我已经在互联网上搜索并找不到任何与我正在使用的特定命令相匹配的内容。
我基本上是在尝试从 Amazon S3 生成一个预先签名的 URL,并且我正在按照文档中的说明进行操作,但它不起作用。像这样的数组:['Key' => 'Value'] ...我在这里看到了另一个问题,其中解决的答案是使用 array() .... 但它不会改变任何东西。
它仍然给出这个错误:
[01-Jan-2016 13:28:56 America/Los_Angeles] PHP Catchable 致命错误:传递给 Guzzle\Service\Client::getCommand() 的参数 2 必须是数组类型,给定的对象,在 /Users/alex 中调用/Development/theshrineofdionysus-com/vendor/guzzle/guzzle/src/Guzzle/Service/Client.php 在第 76 行并在 /Users/alex/Development/theshrineofdionysus-com/vendor/guzzle/guzzle/src/Guzzle/Service 中定义/Client.php 第 79 行
这是我使用的与 S3 部分相关的代码。当我看到有关密钥、区域和存储桶的常量是正确的时,请相信我,因为我在其他地方使用它们的其他 S3 代码可以完美运行。
<?php
$s3 = Aws\S3\S3Client::factory(array(
'key' => AWS_ACCESS_KEY,
'secret' => AWS_SECRET_KEY,
'region' => AWS_REGION,
));
$cmd = $s3->getCommand('GetObject', array(
'Bucket' => AWS_BUCKET,
'Key' => $row['video_id']
));
$request = $s3->createPresignedRequest($cmd, '+120 minutes');
$url = (string) $request->getUri();
?>
Run Code Online (Sandbox Code Playgroud)
我也知道 $row['video_id'] 等于一个现有的文件名,因为那里没有这个代码,我把它回显出来它是正确的文件名。
这是我的 composer.json:
{
"require": …Run Code Online (Sandbox Code Playgroud) 我试图通过在我的ViewWillAppear()函数中以编程方式调用它来伪造点击按钮的行为.
onclick函数在我的ViewDidLoad()中定义,您可以看到我正在尝试使用Perform Selector手动调用该按钮.
该按钮似乎没有运行.有任何想法吗?
public override void ViewDidLoad()
{
base.ViewDidLoad();
idButtonScanLoad.TouchUpInside += async (sender, ea) =>
{
System.Console.WriteLine("Scan button pressed");
};
}
[Export("TouchUpInsideEvent:")]
private void TouchUpInsideEvent(NSObject sender)
{
Console.WriteLine("yay!");
}
public override void ViewWillAppear(bool animated)
{
base.ViewWillAppear(animated);
this.PerformSelector(new ObjCRuntime.Selector("TouchUpInsideEvent:"), this as NSObject, 10f);
}
Run Code Online (Sandbox Code Playgroud) 我有一个代码块,只要扩展名为小写jpg,就可以上传图像并创建缩略图,但如果图像是大写的JPG,则不会上传图像.当我重命名图像时,例如example.JPG到example.jpg,它将上传.但是example.JPG不会上传,我没有错误.这对我没有任何意义.有没有人对此有解释?这是我的代码:
<?php
function createThumbnail($filename) {
require 'config.php';
if(preg_match('/[.](jpg)$/', $filename)) {
$im = imagecreatefromjpeg($filename.$path_to_image_directory);
} else if (preg_match('/[.](gif)$/', $filename)) {
$im = imagecreatefromgif($path_to_image_directory . $filename);
} else if (preg_match('/[.](png)$/', $filename)) {
$im = imagecreatefrompng($path_to_image_directory . $filename);
}
$ox = imagesx($im);
$oy = imagesy($im);
$nx = $final_width_of_image;
$ny = $final_height_of_image;
$nm = imagecreatetruecolor($nx, $ny);
imagecopyresampled($nm, $im, 0,0,0,0,$nx,$ny,$ox,$oy);
if(!file_exists($path_to_thumbs_directory)) {
if(!mkdir($path_to_thumbs_directory)) {
die("There was a problem. Please try again!");
}
}
imagejpeg($nm, $path_to_thumbs_directory . $filename);
$tn = '<img src="' . $path_to_thumbs_directory . $filename …Run Code Online (Sandbox Code Playgroud) php ×4
c# ×2
amazon-s3 ×1
angular ×1
apache ×1
apache2 ×1
apns-php ×1
centos ×1
facebook ×1
http ×1
http-headers ×1
httpclient ×1
inheritance ×1
inject ×1
ios ×1
list ×1
oauth ×1
objective-c ×1
python ×1
rss ×1
typescript ×1
uibutton ×1
upload ×1
wordpress ×1
xamarin ×1