我是第一次尝试码头工作,还没有"心理模型".初学者总数.
我正在查看的所有示例都包含要运行的-rm标志,例如
docker run -it --rm ...
docker container run -it --rm ...
Run Code Online (Sandbox Code Playgroud)
我的问题:为什么"--rm".我想如果我设置或下载容器中有好东西的麻烦,为什么要删除它,我想让它再次使用.
所以,我知道我对码头有错误的想法.
我正在努力让Gunicorn将Python3用于我想制作的Django应用程序.我正在使用Digital Ocean的Django图像开始.它安装和配置了Django,Gunicorn和Nginx.这个图像附带的默认Django项目似乎适用于Python 2.
我已经把apt-get这些包裹了.
为了避免任何问题,我也做到了这一点.
我做rm -rf了股票项目,并创建了一个新项目django-admin.py startproject django_project.django-admin.py使用Python 3(根据shebang).后来,我用它python3 manage.py startapp django_app来创建一个新的应用程序.
在这一点上,一切正常.就像默认的应用程序一样.然后,在django_app/views.py我这样做,它打破了.
from django.shortcuts import render
from django.http import HttpResponse
def index(request):
# Python 2 and 3 - works fine
# print('PRINTING')
# Python 3 only - crashes
print(1, 2, end=' ')
return HttpResponse("Hello, world! This is my first view.")
Run Code Online (Sandbox Code Playgroud)
错误页面说我正在使用Python 2.7.6.
好的,那么我想我可以通过pip为Python 3安装Gunicorn,所以我这样做.
但后来我最终得到了502 Bad …
我有一种情况,我想printf两次使用我的论点.
fmt.Printf("%d %d", i, i)
Run Code Online (Sandbox Code Playgroud)
有没有办法告诉fmt.Printf重用同样的东西i?
fmt.Printf("%d %d", i)
Run Code Online (Sandbox Code Playgroud) 我的项目结构是这样的.
packagetest/
main.go
lib.go
Run Code Online (Sandbox Code Playgroud)
在main.go,我有这个代码.
package main
import "fmt"
func main() {
fmt.Println("Hello from main.go.")
Test()
}
Run Code Online (Sandbox Code Playgroud)
在lib.go,我有这个代码.
package main
import "fmt"
func Test() {
fmt.Println("This is the Test function in lib.go.")
}
Run Code Online (Sandbox Code Playgroud)
当我尝试编译时go build main.go,我明白了./main.go:7: undefined: Test.这种构造我的代码的方式是否可行?
这是docker images我跑前的表现docker build.
$ docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
myapp latest a38da0bd9e0b 6 seconds ago 523.8 MB
golang onbuild b4997c557048 10 days ago 517.2 MB
Run Code Online (Sandbox Code Playgroud)
在对myapp源代码进行一些更改后,我运行docker build -t myapp .并最终得到了名为的图像<none>.
$ docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
myapp latest a38da0bd9e0b Less than a second ago ago 523.8 MB
<none> <none> e4209f97e819 10 minutes ago 523.8 MB
golang onbuild b4997c557048 10 days ago 517.2 …Run Code Online (Sandbox Code Playgroud) 我遇到的问题是我有一个10列的表.其中1列是HTML,因此非常长.它太长了以至于包裹了几条线并拧紧了其他有用的输出.通常,我一直在选择除了那个之外的所有列.但是,我开始加入另一个表,现在有20个列.
有没有办法指定最大列宽或在一定数量的字符后截断列?
我试过了\x.它有点帮助...但在大多数情况下,一切看起来仍然很混乱.
升级使用 golang 1.15.0-rc.1 的系统 (kubernetes) 后,我被困在此错误消息上:
"x509: certificate relies on legacy Common Name field, use SANs or temporarily enable Common Name matching with GODEBUG=x509ignoreCN=0".
Run Code Online (Sandbox Code Playgroud)
我使用通用名称(我知道的)的唯一地方是我为我的服务生成私钥时openssl req -new -key certs/foo-bar.pem -subj "/CN=foobar.mydomain.svc" -out certs/foo-bar.csr -config certs/foo-bar_config.txt。
如何将此命令转换为使用 SAN?
我有一个jar文件应该读取UTF-8编码的文件 - 我在Windows下的文本编辑器中写入 - 并将字符显示在屏幕上.在OS X和Linux下,它可以完美运行.我在Windows下工作时遇到了一些麻烦...我已经定义了一个像这样的读者和作者:
FileInputStream file = new FileInputStream(args[0]);
InputStreamReader reader = new InputStreamReader(file, "UTF8");
PrintStream writer = new PrintStream(System.out, true, "UTF8");
Run Code Online (Sandbox Code Playgroud)
我也按顺序将命令提示字体更改为Lucida Console和UTF-8的字符编码chcp 65001.
现在,当我跑步时java -jar Read.jar file.txt,提示挥霍了.
áéí
ñóú
[]óú
[]
Run Code Online (Sandbox Code Playgroud)
但是,如果我运行type file.txt,则提示正确显示文件的内容.
áéí
ñóú
Run Code Online (Sandbox Code Playgroud)
我尝试使用和不使用BOM保存我的文件,但这没有什么区别.(UTF-8甚至不需要BOM,因为它缺乏字节序,对吗?)我尝试过编译javac -encoding utf8 *.java,但同样的事情发生了.
我现在没有想法了.有人在乎帮忙吗?
我试图在标签上添加一些花哨的文本,但是我遇到了NSMutableAttributedString类的一些问题.我试图实现四个:1.更改字体,2.下划线范围,3.更改范围颜色,4.上标范围.
这段代码:
- (void)applicationDidFinishLaunching:(NSNotification*)aNotification
{
NSMutableAttributedString* display = [[NSMutableAttributedString alloc]
initWithString:@"Hello world!"];
NSUInteger length = [[display string]length] - 1;
NSRange wholeRange = NSMakeRange(0, length);
NSRange helloRange = NSMakeRange(0, 4);
NSRange worldRange = NSMakeRange(6, length);
NSFont* monoSpaced = [NSFont fontWithName:@"Menlo"
size:22.0];
[display addAttribute:NSFontAttributeName
value:monoSpaced
range:wholeRange];
[display addAttribute:NSUnderlineStyleAttributeName
value:[NSNumber numberWithInt:1]
range:helloRange];
[display addAttribute:NSForegroundColorAttributeName
value:[NSColor greenColor]
range:helloRange];
[display addAttribute:NSSuperscriptAttributeName
value:[NSNumber numberWithInt:1]
range:worldRange];
//@synthesize textLabel; is in this file.
[textLabel setAttributedStringValue:display];
}
Run Code Online (Sandbox Code Playgroud)
给我这个错误:
NSMutableRLEArray objectAtIndex:effectiveRange:: Out of bounds
Run Code Online (Sandbox Code Playgroud)
此外,我尝试搞乱范围,但当我尝试时变得更加困惑NSRange worldRange = NSMakeRange(4, 5); …
我正在使用Go(Golang)1.4.2和一个nginx 1.4.6反向代理后面的Gorilla WebSockets.大约一分钟打开页面后,我的WebSockets正在断开连接.Chrome和Firefox上也出现相同的行为.
起初,我在使用WebSockets连接服务器和客户端时遇到了问题.然后,我读到我需要调整我的nginx配置.这就是我所拥有的.
server {
listen 80;
server_name example.com;
proxy_pass_header Server;
location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forward-Proto $scheme;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_pass http://127.0.0.1:1234;
}
}
Run Code Online (Sandbox Code Playgroud)
我的Go代码基本上回应了客户端的消息.(为简洁起见省略了错误).这是我的HandleFunc.
var up = websocket.Upgrader{
ReadBufferSize: 1024,
WriteBufferSize: 1024,
}
ws, _ := up.Upgrade(resp, req, nil)
defer ws.Close()
var s struct {
Foo string
Bar string
}
for {
ws.ReadJSON(&s)
ws.WriteJSON(s)
}
Run Code Online (Sandbox Code Playgroud)
JavaScript也非常简单.
var ws = new WebSocket("ws://example.com/ws/");
ws.addEventListener("message", function(evnt) {
console.log(JSON.parse(evnt.data)); …Run Code Online (Sandbox Code Playgroud) go ×3
docker ×2
nginx ×2
django ×1
gorilla ×1
gunicorn ×1
java ×1
macos ×1
nsrange ×1
objective-c ×1
openssl ×1
postgresql ×1
printf ×1
psql ×1
python-2.7 ×1
python-3.x ×1
unicode ×1
utf-8 ×1
websocket ×1
windows ×1