我正在玩谷歌的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.dart或pubspec.yaml.
所以,google/dart-runtime是一个很好的基础,如果你的服务器是在bin/server.dart 和你想在8080端口上监听,因为我想为侦听端口80,我使用的google/dart图像为基础,希望能压扁什么在google/dart-runtime和google/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) 我正在使用下面的代码在地图上显示自定义图像(而不是默认引脚).但是,当我点击某个项目(并显示标注)时,图像将恢复为默认的红色图钉.即使显示标注,如何保留自定义图像?
- (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) 我正在尝试为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)
我的问题如下:
我在 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) 我的印象是“所有有效的 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 …我试图所以它出现在列表中,使用信息,我发现在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) 我正在尝试调整图像大小.我认为这是一项简单的任务......
这是我的代码(注意,这两个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构造函数进行调整大小很好(但是调整质量很差).
我写了一些代码来用 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# …
我正在为 Dart 开发 VS Code 扩展。Dart 的约定是用 2 个空格缩进(呃,我也讨厌这个),所以我想在用户打开 Dart 文件时自动设置它,而不是使用它们的默认值。
类中有一个insertSpaces属性,FormattingOptions但不清楚如何设置它,也不清楚如何设置它(例如,在语言级别设置它比在打开文档时继续设置它更好)。
.net ×3
c# ×3
dart ×3
asp.net ×1
asp.net-mvc ×1
docker ×1
encoding ×1
image ×1
iphone ×1
javascript ×1
mapkit ×1
performance ×1
powershell ×1
registry ×1
typescript ×1
uriencoding ×1
windows ×1