小编Pas*_*Kit的帖子

什么是缩放图像?如何在网页中提供图像?

我在google PageSpeed中运行测试页面.我发现了一些警告,例如服务缩放图像..

 http://man-vimal.net78.net/introduction/?intro/action=main

THe results were as such :
The following images are resized in HTML or CSS. Serving scaled images could save 449.3KiB (99% reduction).
http://man-vimal.net78.net/.../twitter-logo.png is resized in HTML or CSS from 367x367 to 20x20. Serving a scaled image could save 140.9KiB (99% reduction).
http://man-vimal.net78.net/introduction/views/images/fb.png is resized in HTML or CSS from 1,692x1,692 to 20x20. Serving a scaled image could save 115.9KiB (99% reduction).
http://man-vimal.net78.net/.../linkedin.jpg is resized in HTML or CSS from 1,024x768 to 20x20. Serving a scaled …
Run Code Online (Sandbox Code Playgroud)

html css

14
推荐指数
1
解决办法
4万
查看次数

如何从UInt16转换为NSNumber

我有一个UInt16变量,我想传递给需要NSNumber的遗留函数.

如果我尝试:

var castAsNSNumber : NSNumber = myUInt16
Run Code Online (Sandbox Code Playgroud)

我收到编译器错误 'UInt16' is not convertible to 'NSNumber'

我怎样才能将其改为NSNumber?

casting nsnumber swift

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

如何在 C# 中为 protobuf map<string, string> 属性设置值

我有以下 protoc3 消息:

message LocalizedString {
  map<string, string> translations = 1
}
Run Code Online (Sandbox Code Playgroud)

当编译成 C# 时,我得到以下自动生成的代码:

using pb = global::Google.Protobuf;
using pbc = global::Google.Protobuf.Collections;
using pbr = global::Google.Protobuf.Reflection;
using scg = global::System.Collections.Generic;
namespace PKIo {

  /// <summary>Holder for reflection information generated from io/common/localization.proto</summary>
  public static partial class LocalizationReflection {

    #region Descriptor
    /// <summary>File descriptor for io/common/localization.proto</summary>
    public static pbr::FileDescriptor Descriptor {
      get { return descriptor; }
    }
    private static pbr::FileDescriptor descriptor;

    static LocalizationReflection() {
      byte[] descriptorData = global::System.Convert.FromBase64String(
          string.Concat(
            "Chxpby9jb21tb24vbG9jYWxpemF0aW9uLnByb3RvEgJpbyKDAQoPTG9jYWxp",
            "emVkU3RyaW5nEjsKDHRyYW5zbGF0aW9ucxgBIAMoCzIlLmlvLkxvY2FsaXpl", …
Run Code Online (Sandbox Code Playgroud)

c# protocol-buffers protobuf-csharp-port grpc

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

iOS UTF-8标签字符串

我有一个UTF-8编码字符串,我想在标签中显示.

当我设置一个断点并检查持有字符串的变量时,所有看起来都很好.但是,当我尝试输出到日志或标签时,我得到拉丁编码.

Xcode截图

我已经尝试了几乎所有关于SO及其他的建议,但我无法正确显示字符串.

这是我的代码:

NSString *rawString = [NSString stringWithFormat:@"%@",m_value];

const char *utf8String = [rawString UTF8String];
NSLog (@"%@", [NSString stringWithUTF8String:utf8String]);
NSLog (@"%s", utf8String);
NSLog (@"%@", rawString);

self.resultText.text = [NSString stringWithUTF8String:utf8String];
Run Code Online (Sandbox Code Playgroud)

m_value是一个NSString,在调试窗口中,它还显示正确的编码.

m_value NSString *  0x006797b0 @"???..."
    NSObject    NSObject    
    isa Class   0x3bddd8f4
    [0] Class   
Run Code Online (Sandbox Code Playgroud)

我正在使用iOS 6.1 SDK.

objective-c utf-8 ios

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

UIWebView Delegate获取MIME类型

UIWebView不会自动支持处理Passbook .pkpass文件.

在本技术说明中,Apple建议通过UIWebViewDelegate方法实现检查,以嗅探MIME类型并相应地处理它.

要使用UIWebView添加传递,请实现相应的UIWebViewDelegate方法,以确定视图何时加载MIME类型为application/vnd.apple.pkpass的数据

但是,我在UIWebView委托协议参考中找不到能够提供MIME类型的任何内容.

我可以使用NSURLConnection委托直接下载和处理文件,没有任何问题,但我希望实现的是,如果用户在UIWebView中浏览时单击"添加到存折"按钮,则可以正确处理传递.由于我不知道链接,并且许多提供商没有使用.pkpass扩展名后缀,因此遵循Apple的检查MIME类型的建议似乎是最好的方法.

我尝试添加以下内容

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)newRequest 
                                                 navigationType:(UIWebViewNavigationType)navigationType 
{

   NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:[newRequest URL]];

   // Spoof iOS Safari headers for sites that sniff the User Agent
   [req addValue:@"Mozilla/5.0 (iPhone; CPU iPhone OS 6_1 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5376e Safari/8536.25" forHTTPHeaderField:@"User-Agent"];

   NSURLConnection *conn = [NSURLConnection connectionWithRequest:newRequest delegate:self];

   return YES;
} 
Run Code Online (Sandbox Code Playgroud)

我的NSURLConnection代表:

- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
{
    NSString *mime = [response MIMEType]; …
Run Code Online (Sandbox Code Playgroud)

objective-c uiwebview nsurlconnection ios6

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

如何访问NSIndexPath节值?

我无法理解为什么在以下代码indexPath.section中重新调整null值.

override func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell? {
    NSLog("Index Path %@", indexPath)
    // Index Path <NSIndexPath: 0x1666d1d0> {length = 2, path = 0 - 0}

    NSLog("Index Path Section %@", indexPath.section)
    // Index Path Section (null)
Run Code Online (Sandbox Code Playgroud)

这个问题之后,我也尝试了以下方法来访问section值:

if let section = indexPath?.section {
    NSLog("Index Path Section %@", section)
}
Run Code Online (Sandbox Code Playgroud)

我有一个包含2个部分的表,每个部分有1行.在第一次迭代中path = 0 - 0,日志显示Index Path Section (null).在path = 1 - 0程序崩溃的第二次迭代中.

我不是想做任何复杂的事情,我只需要访问section值,这样我就可以有条件地返回正确类型的单元格.

nsindexpath ios swift

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

使用 mTLS 进行 GKE gRPC 入口运行状况检查

我正在尝试使用双向 TLS 身份验证在 GKE (v1.11.2-gke.18) 上实现 gRPC 服务。

当不强制执行客户端身份验证时,GKE 自动创建的 HTTP2 运行状况检查会响应,并且一切都连接问题。

当我打开相互身份验证时,运行状况检查失败 - 大概是因为它无法完成连接,因为它缺少客户端证书和密钥。

与往常一样,文档很简单而且相互矛盾。我需要一个完全编程的解决方案(即没有控制台调整),但除了手动将运行状况检查更改为 TCP 之外,我一直无法找到解决方案。

从我所见,我猜我要么需要:

  • 实施自定义 mTLS 运行状况检查,以防止 GKE 自动创建 HTTP2 检查
  • 找到一种替代方法在不使用service.alpha.kubernetes.io/app-protocols: '{"grpc":"HTTP2"}'专有注释的容器上进行 SSL 终止
  • 找到某种方法为健康检查提供所需的凭据
  • 改变我的 go 实现,以某种方式在不需要 mTLS 的情况下进行健康检查,同时在所有其他端点上强制执行 mTLS

或者也许还有其他我没有考虑过的东西?下面的配置非常适用于带有 TLS 的 REST 和 gRPC,但会与 mTLS 中断。

服务.yaml

apiVersion: v1
kind: Service
metadata:
  name: grpc-srv
  labels:
    type: grpc-srv
  annotations:
    service.alpha.kubernetes.io/app-protocols: '{"grpc":"HTTP2"}'
spec:
  type: NodePort
  ports:
  - name: grpc
    port: 9999
    protocol: TCP
    targetPort: 9999
  - name: http
    port: 8080
    protocol: …
Run Code Online (Sandbox Code Playgroud)

mutual-authentication google-kubernetes-engine grpc kubernetes-health-check kubernetes-ingress

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

com.microsoft.sqlserver.jdbc.SQLServerException: 'GO' 附近的语法不正确

我有一个疑问:

IF  EXISTS (SELECT * FROM sys.procedures WHERE name ='stProcedure')
DROP PROCEDURE stProcedure
GO
CREATE PROCEDURE stProcedure
AS
CREATE TABLE [core_schema].MyTable(
firstcolumn  int,
secondcolumn int
);
Run Code Online (Sandbox Code Playgroud)

我有 id Java 代码:

entityManager.createNativeQuery(createProcedureQueryString).executeUpdate();
Run Code Online (Sandbox Code Playgroud)

如何替代 GO 或使其工作?在 MS SQL Server 2008 中它可以工作,但是当我想通过 java 代码使其工作时,我得到一个

errorcom.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near 'GO'
Run Code Online (Sandbox Code Playgroud)

java velocity sql-server-2008

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