我最近试图进入OOP,而我在使用SOLID原则和设计模式方面遇到了麻烦.我明白为什么人们会使用它们,我也真的想要使用它们,但我不能完全按照规范开发我的类.我真的很感激有助于我理解这一点的任何事情.
我有一个设置了PHP-FPM的Nginx HTTP服务器,几乎一切正常.我希望能够去path/to/file,它给了我index.php?url=path/to/file,它做到了.但是,它会下载实际的PHP,它不会在浏览器中执行它.我不确定是什么原因造成的.
Nginx配置:
server {
listen 80;
server_name sandbox.domain.tld;
access_log /path/to/domain/log/sandbox.access.log;
error_log /path/to/domain/log/sandbox.error.log;
location / {
root /path/to/sandbox;
index index.php;
if (!-e $request_filename) {
rewrite ^/beta/(.+)$ /beta/index.php?url=$1 break;
}
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include /usr/local/nginx/conf/fastcgi_params;
fastcgi_param SCRIPT_FILENAME /path/to/sandbox$fastcgi_script_name;
}
Run Code Online (Sandbox Code Playgroud) 我有一些代码对我没有多大意义.我有一个字符串数组,我正在使用二进制搜索在foreach()循环中计算它们.除了排序之外,我尝试输出时的代码完全相同.我不知道为什么我得到了我得到的结果.我认为它应该只计算数组的值,两次都是相同的.有帮助吗?
码:
using System;
public class Driver {
public static void Main(string [] args) {
String [] s = {"Bob", "Jane", "Will", "Bill", "Liz"};
Console.WriteLine("Before Sorting:\n----------");
foreach(string item in s) {
Console.WriteLine("{0}. {1}", Array.BinarySearch(s, item) + 1, item);
}
Console.WriteLine("Will is at position {0}", Array.BinarySearch(s, "Will") + 1);
Console.WriteLine("\n\nAfter Sorting:\n----------");
Array.Sort(s);
foreach(string item in s) {
Console.WriteLine("{0}. {1}", Array.BinarySearch(s, item) + 1, item);
}
Console.WriteLine("Will is at position {0}", Array.BinarySearch(s, "Will") + 1);
}
}
Run Code Online (Sandbox Code Playgroud)
输出:
Before Sorting:
----------
1. …Run Code Online (Sandbox Code Playgroud) 假设我有一个我正在研究的项目,那就是博客.在这篇博客中,我有一个包含敏感信息的配置文件.当我决定将此项目推送到Github时,我希望配置文件填充示例数据而不是我的敏感数据.实现这一目标的最佳,最广泛使用的方法是什么?
我理解自动执行匿名函数是什么,但我无法理解我将在何处使用它们以及为什么.这可能是因为我经常使用jQuery.你能提供好用例的例子吗?
我正在学习Ruby并做了一个课程来帮助:
class WhatImDoing
def initialize
puts "not doing anything"
end
end
Run Code Online (Sandbox Code Playgroud)
输出:
not doing anything
#<WhatImDoing:0xb74b14e8>
Run Code Online (Sandbox Code Playgroud)
我很好奇,第二行是什么?它是我创建的WhatImDoing对象的引用位置吗?我可以通过这个位置访问对象(如指针或其他东西)吗?等等......一般来说,只是想要更好地理解Ruby.
谢谢.
参考:https : //github.com/dotnet/corefx/blob/master/src/System.Net.Mail/src/System/Net/Mail/SmtpClient.cs#L583
此方法被标记为异步但返回无效。它实际上是异步的,只是不是基于任务的?如果是这样,它是如何异步的?
我现在正在浏览python.org的python教程.我在10.9,我正在尝试使用zlib库来压缩字符串.但是,len(compressedString)并不总是小于len(originalString).我的翻译代码如下:
>>> import zlib
>>> s = 'the quick brown fox jumps over the lazy dog'
>>> len(s)
43
>>> t = zlib.compress(s)
>>> len(t)
50
>>> t
'x\x9c+\xc9HU(,\xcdL\xceVH*\xca/\xcfSH\xcb\xafP\xc8*\xcd-(V\xc8/K-R(\x01J\xe7$VU*\xa4\xe4\xa7\x03\x00a<\x0f\xfa'
>>> len(zlib.decompress(t))
43
>>> s2 = "something else i'm compressing"
>>> len(s2)
30
>>> t2 = zlib.compress(s2)
>>> len(t2)
37
>>> s3 = "witch which has which witches wrist watch"
>>> len(s3)
41
>>> t3 = zlib.compress(s3)
>>> len(t3)
37
Run Code Online (Sandbox Code Playgroud)
有谁知道为什么会这样?
c# ×2
async-await ×1
asynchronous ×1
compression ×1
git ×1
github ×1
javascript ×1
nginx ×1
oop ×1
php ×1
python ×1
ruby ×1
task ×1
theory ×1
zlib ×1