我在使用threejs的例子(比如EffectComposer或Detector)来处理webpack和typescript时遇到了很多麻烦.
首先,相关*.d.ts文件都存在并通过安装tsd.我的问题是让webpack实际包含默认的threejs构建之外的文件(即内容examples/js/).
随着three从NPM安装我可以这样做
import THREE = require('three');
Run Code Online (Sandbox Code Playgroud)
哪个工作正常,但没有任何上述的好东西.在npm上有一些其他的三个包捆绑插件,但我认为它们不适用于typescript(因为require('three-js')(['EffectComposer'])被打字稿编译器拒绝了).
有没有人在这个包中得到一些东西(比如后期处理)来处理打字稿?
我刚刚开始将我的Swing应用程序从OS X移植到Windows,而且事情很痛苦JLabel.
我注意到setFont如果标签的文本是HTML ,则忽略指定的字体(这在Mac上不会发生).HTML格式对于复杂显示的可读性非常有用.
在正常情况下,我会在HTML标记中指定字体,但我使用的字体是在运行时使用Font.createFontJAR中的ttf 加载的.我尝试在字体标记中使用加载的字体名称,但这不起作用.
有什么方法可以在Windows上使用加载awt.Fonthtml-ified JLabel?
这是一个例子.我无法共享我的应用程序的字体,但我只是用这个(纯TTF)运行它,并发生相同的行为:
http://www.dafont.com/sophomore-yearbook.font
import java.awt.Font;
import java.io.File;
import javax.swing.*;
public class LabelTestFrame extends JFrame {
public LabelTestFrame() throws Exception {
boolean useHtml = true;
String fontPath = "C:\\test\\test_font.ttf";
JLabel testLabel = new JLabel();
Font testFont = Font.createFont(Font.TRUETYPE_FONT, new File(fontPath)).deriveFont(18f);
testLabel.setFont(testFont);
if (useHtml) testLabel.setText("<html>Some HTML'd text</html>");
else testLabel.setText("Some plaintext");
getContentPane().add(testLabel);
setSize(300,300);
}
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() …Run Code Online (Sandbox Code Playgroud) 我正在尝试构建一个启动其他完全独立进程的Python守护进程.
一般的想法是针对给定的shell命令,每隔几秒轮询一次并确保命令的k个实例正在运行.我们保持PID文件的目录,当我们轮询我们删除PID文件,其PID是不再运行和启动(并为PID文件)然而,许多流程,我们需要去ķ他们.
子进程也需要完全独立,这样如果父进程死掉,子进程就不会被杀死.根据我的阅读,似乎没有办法用subprocess模块做到这一点.为此,我使用了这里提到的片段:
http://code.activestate.com/recipes/66012-fork-a-daemon-process-on-unix/
我做了一些必要的修改(你会在附加的代码片段中看到注释掉的行):
这是我的spawn fn和测试:
import os
import sys
import subprocess
import time
def spawn(cmd, child_cwd):
"""
do the UNIX double-fork magic, see Stevens' "Advanced
Programming in the UNIX Environment" for details (ISBN 0201563177)
http://www.erlenstar.demon.co.uk/unix/faq_2.html#SEC16
"""
try:
pid = os.fork()
if pid > 0:
# exit first parent
#sys.exit(0) # parent daemon needs to stay alive to launch more in the future
return
except OSError, e:
sys.stderr.write("fork #1 failed: %d …Run Code Online (Sandbox Code Playgroud) 我有一个客户端/服务器应用程序,通过Java的SSLSocket远程连接到服务器.
我正在尝试实现一个可选模式,通过经过身份验证的SOCKS v5代理启用连接.
我尝试使用相关的教程,但没有具体提及有关SSL的任何内容.
我已经尝试设置系统范围的属性("socksProxyHost"和"socksProxyPort")但它似乎没有做任何事情.
我的下一个方法是在SSLSocketFactory中使用工厂方法:
String proxyHost = Config.prefs.get("PROXY_NAME", "localhost");
int proxyPort = Config.prefs.getInt("PROXY_PORT", 1080);
InetSocketAddress proxyAddr = new InetSocketAddress(proxyHost, proxyPort);
Socket underlying = new SSLSocket(new Proxy(Proxy.Type.SOCKS, proxyAddr));
underlying.connect(new InetSocketAddress(getHost(), getPort()));
socket = (SSLSocket) factory.createSocket(
underlying,
getHost(),
getPort(),
true);
Run Code Online (Sandbox Code Playgroud)
但是这种方法的问题是createSocket方法要求底层套接字已经连接,而我的服务器不接受非SSL连接.
使用SOCKS连接到远程服务器的最佳方法是什么?此外,我接下来不知道如何在此系统中为经过身份验证的SOCKS提供用户名/密码.
谢谢!