小编Dan*_*eny的帖子

为什么Docker没有将文件添加到我的容器中?

我正在玩谷歌的Dart docker图像.我正在尝试构建一个侦听端口80的Hello World应用程序.我在Azure上的Ubuntu Server 14上运行它.

如果我运行google/dart-hello,它一切正常,我可以连接端口8080.

google/dart-hello图像是基于对google/dart-runtime图像,其又,根据google/dart.基础图像添加了Dart; google/dart-runtime添加一个Dockerfile,它希望执行bin/server.dart并公开端口8080,并google/dart-hello提供bin/server.dart(和pubspec.yaml)使其工作.google/dart-runtime它本身没用,因为它不包含bin/server.dartpubspec.yaml.

所以,google/dart-runtime是一个很好的基础,如果你的服务器是在bin/server.dart 你想在8080端口上监听,因为我想为侦听端口80,我使用的google/dart图像为基础,希望能压扁什么在google/dart-runtimegoogle/dart-hello进入我的容器,但改为80端口.

您可以在此处找到三个Google图片的来源回购:

所以,我从中获取了Dockerfile google/dart-runtime和来自的文件google/dart-hello,所以我有以下内容:

FROM google/dart

WORKDIR /app
ONBUILD ADD pubspec.yaml /app/
ONBUILD ADD pubspec.lock /app/
ONBUILD RUN pub get
ONBUILD ADD . /app …
Run Code Online (Sandbox Code Playgroud)

dart docker

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

单击时,自定义annotationView图像将恢复为引脚

我正在使用下面的代码在地图上显示自定义图像(而不是默认引脚).但是,当我点击某个项目(并显示标注)时,图像将恢复为默认的红色图钉.即使显示标注,如何保留自定义图像?

- (MKAnnotationView *) mapView:(MKMapView *)map viewForAnnotation:(id <MKAnnotation>)annotation
{
    MKPinAnnotationView *pinAnnotation = nil;

    if (annotation != mapView.userLocation) 
    {
        static NSString *pinID = @"mapPin";
        pinAnnotation = (MKPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:pinID];
        if (pinAnnotation == nil)
            pinAnnotation = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:pinID] autorelease];

        // Set the image
        pinAnnotation.image = [UIImage imageNamed:@"TestIcon.png"];

        // Set ability to show callout
        pinAnnotation.canShowCallout = YES;

        // Set up the disclosure button on the right side
        UIButton *infoButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
        pinAnnotation.rightCalloutAccessoryView = infoButton;

        [pinID release];
    }

    return pinAnnotation;
    [pinAnnotation …
Run Code Online (Sandbox Code Playgroud)

iphone mapkit iphone-sdk-3.0

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

如果我在代码中设置一些值,我还可以使用UpdateModel()吗?

我正在尝试为ASP.NET MVC Web应用程序实现"创建"操作方法.我知道有一个辅助方法,并已成功地在其他页面上使用它,在表单和模型之间有完美的1:1匹配.我的问题涉及我要添加的新页面需要发布在表单中捕获的值和以编程方式设置的值的组合.这是一个例子.

MembershipUser user = Membership.GetUser(User.Identity.Name);
Guid guid = (Guid)user.ProviderUserKey;
review.UserID = guid;
review.BusinessID = Convert.ToInt16(Request.Form["BusinessID"]);
review.Comments = Request.Form["Comments"];
review.Rating = Convert.ToInt16(Request.Form["Rating"]);
reviewsRepository.AddNewReview(review);
reviewsRepository.Save();
Run Code Online (Sandbox Code Playgroud)

正如您在此示例中所看到的,UserID在代码中定义,其余值来自表单中的用户输入.

这是我的AdNewReview和Save方法的代码.

    public void AddNewReview(Review review)
    {
        db.Reviews.InsertOnSubmit(review);
    }

    //
    //Persist changes to database

    public void Save()
    {
        db.SubmitChanges();
    }
Run Code Online (Sandbox Code Playgroud)

我的问题如下:

  1. 我仍然可以在此方案中使用UpdateModel()辅助方法吗?如果是这样,请举例说明.或者所有的值都必须来自反射形式才能正常工作?
  2. 即使在这种情况下有一种方法可以使用辅助方法,我仍然希望学习以手动方式进行操作.我需要对上面的代码进行哪些更改才能使其正常工作?

.net c# asp.net asp.net-mvc

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

为什么这个 PowerShell 代码 (Invoke-WebRequest / getElementsByTagName) 在我的机器上慢得难以置信,而在其他机器上却没有?

我在 PowerShell 中编写了一些屏幕抓取代码,并惊讶于解析几个 HTML 表需要大约 30 秒。我把它拆开,试图弄清楚所有的时间都花在哪里了,它似乎在getElementsByTagName通话中。

我在下面包含了一个脚本,在我的家庭桌面、我的工作桌面和我的家庭平板上,每次迭代大约需要 1-2 秒(完整的结果粘贴在下面)。但是,PowerShell 社区中的其他人报告的时间要短得多(每次迭代只有几毫秒)。

我正在努力寻找缩小问题范围的任何方法,并且似乎没有 OS/PS/.NET/IE 版本的模式。

我目前运行的桌面是全新的 Windows 8 安装,仅安装了 PS3 和 .NET 4.5(以及所有 Windows 更新补丁)。没有 Visual Studio。没有 PowerShell 配置文件。

$url = "http://www.icy-veins.com/restoration-shaman-wow-pve-healing-gear-loot-best-in-slot"
$response = (iwr $url).ParsedHtml

# Loop through the h2 tags
$response.body.getElementsByTagName("h2") | foreach {

    # Get the table that comes after the heading
    $slotTable = $_.nextSibling

    # Grab the rows from the table, skipping the first row (column headers)
    measure-command { $rows = $slotTable.getElementsByTagName("tr") | select -Skip …
Run Code Online (Sandbox Code Playgroud)

powershell performance powershell-3.0

2
推荐指数
2
解决办法
6381
查看次数

获取简短的 JavaScript CustomEvent polyfill 以在 TypeScript 中编译?

我的印象是“所有有效的 JavaScript 都是有效的 TypeScript”;但是每次我尝试使用它时,我都会被困在尝试做一些简单的事情:(

在这种情况下,我试图将一些 .js 文件重命名为 .ts 并尽可能少地编译。我想逐步转换为 TypeScript;所以重点是让它编译而不是翻译所有的代码。

我从一些包含 CustomEvent polyfill 的代码开始:https : //developer.mozilla.org/en/docs/Web/API/CustomEvent

代码是这样的:

(function () {
  function CustomEvent ( event, params ) {
    params = params || { bubbles: false, cancelable: false, detail: undefined };
    var evt = document.createEvent( 'CustomEvent' );
    evt.initCustomEvent( event, params.bubbles, params.cancelable, params.detail );
    return evt;
   };

  CustomEvent.prototype = window.Event.prototype;

  window.CustomEvent = CustomEvent;
})();
Run Code Online (Sandbox Code Playgroud)

然后有一些代码调用它:

window.dispatchEvent(new CustomEvent('typeScriptIsTehCool', { detail: 1 }));
Run Code Online (Sandbox Code Playgroud)

但是,如果您将所有这些都粘贴到http://www.typescriptlang.org/Playground 中,您会发现一些问题:

  • window.Event 未在基本库中定义
  • document.createEvent不返回带有initCustomEvent函数的东西
  • window.CustomEvent …

javascript typescript

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

如何在Windows(8.1)中将自定义应用程序注册为Web浏览器?

我试图所以它出现在列表中,使用信息,我发现在Windows中选择AA默认浏览器中注册自己的应用程序周围 互联网.代码全部运行没有问题,似乎创建了正确的注册表项,但我的应用程序没有显示在Windows 8.1的浏览器选择选项中.

我没有在线设置UserChoice一些代码示例中显示的值,因为它看起来实际上设置了默认浏览器(只有一个值),我不是试图这样做,只是将其注册为一个选项.

相关代码在RegisterBrowser中,但为方便起见,我已经包含了完整的类.

using System;
using System.Reflection;
using Microsoft.Win32;

namespace MyApp
{
    class Program
    {
        const string AppID = "MyApp";
        const string AppName = "My App";
        const string AppDescription = "My App";
        static string AppPath = Assembly.GetExecutingAssembly().Location;
        static string AppIcon = AppPath + ",0";
        static string AppOpenUrlCommand = AppPath + " %1";
        static string AppReinstallCommand = AppPath + " --register";

        static void Main(string[] args)
        {
            if (args == null || args.Length != 1 …
Run Code Online (Sandbox Code Playgroud)

.net c# windows registry

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

为什么我的图像调整代码总是产生一个完全黑色的输出图像?

我正在尝试调整图像大小.我认为这是一项简单的任务......

这是我的代码(注意,这两个Save调用仅用于调试以说明问题):

    var newSize = new Size { Width = 450, Height = 250 };
    using (var img = (Bitmap)Image.FromFile(sourceImageFilename))
    {
        var outputImage = new Bitmap(newSize.Width, newSize.Height);

        // Save input image for debugging (screenshot below)
        img.Save(@"M:\Coding\Photos\Temp\input.jpg");

        using (Graphics gr = Graphics.FromImage(img))
        {
            gr.SmoothingMode = SmoothingMode.HighQuality;
            gr.InterpolationMode = InterpolationMode.HighQualityBicubic;
            gr.PixelOffsetMode = PixelOffsetMode.HighQuality;
            gr.DrawImage(outputImage, new Rectangle(0, 0, newSize.Width, newSize.Height));
        }

        // Save output image for debugging (screenshot below)
        outputImage.Save(@"M:\Coding\Photos\Temp\output.jpg");
    }
Run Code Online (Sandbox Code Playgroud)

这似乎是很多人使用的完全相同的代码(在许多答案中存在于SO中).但是,这是写入磁盘的两个图像的样子:

调整图像大小

原始图像为5344x3006,newSize(黑色输出图像)为450x250.

我的所有其他代码都工作正常(使用SetPixel读取输入图像中的像素等),只是这个调整大小已经坏了.使用Bitmap构造函数进行调整大小很好(但是调整质量很差).

.net c# image image-processing

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

如何以 Twitter API 期望的格式在 Dart 中进行 url 编码?

写了一些代码来用 C# 发布推文。绊倒我的一件事是数据的 url 编码,因为似乎有很多选择:

var input = "Hello Ladies + Gentlemen, a signed OAuth request!";
var expected = "Hello%20Ladies%20%2B%20Gentlemen%2C%20a%20signed%20OAuth%20request%21";

Console.WriteLine(WebUtility.UrlEncode(input) == expected); // False
Console.WriteLine(Uri.EscapeUriString(input) == expected); // False
Console.WriteLine(Uri.EscapeDataString(input) == expected); // True
Run Code Online (Sandbox Code Playgroud)

我现在正在尝试在 Dart 中做同样的事情。我已经尝试了 Uri 类中的所有编码方法,但似乎没有一个输出相同。

代码:(飞镖板

print(Uri.encodeQueryComponent("Hello Ladies + Gentlemen, a signed OAuth request!"));
print(Uri.encodeFull("Hello Ladies + Gentlemen, a signed OAuth request!"));
print(Uri.encodeComponent("Hello Ladies + Gentlemen, a signed OAuth request!"));
Run Code Online (Sandbox Code Playgroud)

输出:

Hello+Ladies+%2B+Gentlemen%2C+a+signed+OAuth+request%21
Hello%20Ladies%20+%20Gentlemen,%20a%20signed%20OAuth%20request!
Hello%20Ladies%20%2B%20Gentlemen%2C%20a%20signed%20OAuth%20request!
Run Code Online (Sandbox Code Playgroud)

最后一个 ( encodeComponent) 似乎最接近,只是感叹号是错误的。

是否有一种现有的方法可以按照我的要求进行这种编码(与 C# …

encoding dart uriencoding

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

如何在 VSCode 扩展中设置语言的缩进选项?

我正在为 Dart 开发 VS Code 扩展。Dart 的约定是用 2 个空格缩进(呃,我也讨厌这个),所以我想在用户打开 Dart 文件时自动设置它,而不是使用它们的默认值。

类中有一个insertSpaces属性,FormattingOptions但不清楚如何设置它,也不清楚如何设置它(例如,在语言级别设置它比在打开文档时继续设置它更好)。

dart visual-studio-code vscode-extensions

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