我想在Java中使用具有基本身份验证(用户名,密码)的代理进行连接(并且只有此连接).以下代码适用于HTTP URL(例如" http://www.google.com "):
URL url = new URL("http://www.google.com");
HttpURLConnection httpURLConnection = null;
InetSocketAddress proxyLocation = new InetSocketAddress(proxyHost, proxyPort);
Proxy proxy = new Proxy(Proxy.Type.HTTP, proxyLocation);
httpURLConnection = (HttpURLConnection) url.openConnection(proxy);
// Works for HTTP only! Doesn't work for HTTPS!
String encoded = new sun.misc.BASE64Encoder().encodeBuffer((proxyUserName + ":" + proxyPassword).getBytes()).replace("\r\n", "");
httpURLConnection.setRequestProperty("Proxy-Authorization", "Basic " + encoded);
InputStream is = httpURLConnection.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
int data = isr.read();
while(data != -1){
char c = (char) data;
data = isr.read();
System.out.print(c);
}
isr.close(); …Run Code Online (Sandbox Code Playgroud) 当我从Facebook Realtime API(webhooks)收到"消息接收回调"事件时,我想要获取对话中的先前消息.为此,我需要会话线程的ID.
https://developers.facebook.com/docs/messenger-platform/webhook-reference/message?locale=en_US
该事件不包含有关会话线程ID(t_id)的任何信息.它只包含消息ID(mid).
https://developers.facebook.com/docs/graph-api/reference/v2.8/conversation
有没有办法获得对话线程ID?
我已经下载了Google的"Noto Color Emoji"字体,但无法使其正常工作.我对"Noto Sans Regular"等字体没有任何问题.但是使用"Noto Color Emoji"字体,我在Firefox中遇到以下错误(在Windows 10上):
downloadable font: no supported glyph shapes table(s) present (font-family: "NotoColorEmoji" style:normal weight:normal stretch:normal src index:0)
downloadable font: rejected by sanitizer (font-family: "NotoColorEmoji" style:normal weight:normal stretch:normal src index:0)
Run Code Online (Sandbox Code Playgroud)
它也不适用于Windows 10上的Chrome,Internet Explorer和Edge或Ubuntu Linux上的Firefox.
这是我的代码:
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
@font-face {
font-family: 'NotoColorEmoji';
src: url('NotoColorEmoji.ttf') format('truetype');
}
</style>
</head>
<body>
<span style="font-family: 'NotoColorEmoji'">Emojis: </span>
</body>
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?表情符号字体是否以不同的方式使用?
我有一个带有一组不同x值的点的图:x = 0.5为5点,x = 0.6为5点,x = 1.4为5点,x = 1.6为5点.
现在我想为每个x值创建一个boxplot.但不知何故,我所有的箱图都在x = 0.5.我希望在正确的x值下创建箱图.2 x值之间的距离可以不同.我当前的x值是0.5,0.6,0.7,0.8,0.9,1.0,1.2,1.4和1.6,但它们对于不同的图也可以是不同的.我该怎么办?
这是我的观点的GNUPlot脚本:https://dl.dropboxusercontent.com/u/26464165/Points.gnu
这是我的箱图的GNUPlot脚本:https://dl.dropboxusercontent.com/u/26464165/Boxplots.gnu
谢谢你的时间!
我是 JS 新手,我不确定函数何时执行。
示例 A:
<html>
<head>
<title>A</title>
<script src="myScript.js"></script>
</head>
<body onload="myFunction()">
[Content here...]
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
示例 B:
<html>
<head>
<title>B</title>
<script src="myScript.js"></script>
</head>
<body>
[Content here...]
<script>
myFunction();
</script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
从我到目前为止所读到的内容来看,该函数在解析器到达时执行。这不会使示例 A 和 B 相同吗?当在 B 中调用 myFunction() 时,页面的所有内容(例如带有文本的表格)是否在屏幕上可见?
我有一个配置文件,其中包含我想用于计算的一些因素.
public class Config {
public static final double factor = 67/300; // ~0,2233...
}
Run Code Online (Sandbox Code Playgroud)
我访问这样的因素:
public class Calculate {
public static calc() {
...
result *= Config.factor;
...
Run Code Online (Sandbox Code Playgroud)
当我这样做时,Config.factor等于0,所以我的结果也是0.如果我将因子设置为0.2233,我没有那个问题,但那不会那么准确.为什么不将它设置为67/300工作?
我有一个像'abbba'这样的字符串,并希望替换该字符串中的每个'b',该字符串在具有不同字符的字符之前和之后具有空格.我怎么能用正则表达式做到这一点?我的想法是这样的:
'x a y a x'.replace(new RegExp(' a ', 'g'), ' b '); // is: x b y b x, should: x b y b x (correct)
'x a a a x'.replace(new RegExp(' a ', 'g'), ' b '); // is: x b a b x, should: x b b b x (wrong)
'x aa x'.replace(new RegExp(' a ', 'g'), ' b '); // is: x aa x, should: x aa x (correct)
Run Code Online (Sandbox Code Playgroud)
但是,只有在角色的另一个出现旁边出现不超过1个字符时,该正则表达式才有效.我怎么能写正则表达式以获得正确的行为?