我正在使用 Python 3.6 和最新版本的 vscode。
我的文件夹结构:
/folder
/src
src.py
/tests
src_test.py
Run Code Online (Sandbox Code Playgroud)
src.py:
class Addition:
def __init__(self, a, b):
self.a = a
self.b = b
def run(self):
return self.a + self.b
Run Code Online (Sandbox Code Playgroud)
src_test.py:
import unittest
from ..src.addition import Addition
class TestAddition(unittest.TestCase):
def test_addition(self):
inst = Addition(5, 10)
res = inst.run()
self.assertEqual(res, 16)
if( __name__ == "main"):
unittest.main()
Run Code Online (Sandbox Code Playgroud)
这是我的项目settings.json:
{
"python.testing.unittestArgs": [
"-v",
"-s",
".",
"-p",
"*_test.py"
],
"python.testing.pytestEnabled": false,
"python.testing.nosetestsEnabled": false,
"python.testing.unittestEnabled": true
}
Run Code Online (Sandbox Code Playgroud)
然后在项目根文件夹下:
python3 -m unittest 测试/src_test.py
File "/usr/lib/python3.6/unittest/loader.py", line …Run Code Online (Sandbox Code Playgroud) 我正在使用 nbconvert 将我的 jupyter notebook 转换为 html
jupyter nbconvert my.ipynb --to html
然后它说:
[NbConvertApp] 将 notebook my.ipynb 转换为 html [NbConvertApp] 将 407497 字节写入 my.html
然后在生成的my.html,我可以看到它需要custom.css:
<!-- Custom stylesheet, it must be in the same directory as the html file -->
<link rel="stylesheet" href="custom.css">
<!-- Loading mathjax macro -->
<!-- Load mathjax -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js?config=TeX-AMS_HTML"></script>
<!-- MathJax configuration -->
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
tex2jax: {
inlineMath: [ ['$','$'], ["\\(","\\)"] ],
displayMath: [ ['$$','$$'], ["\\[","\\]"] ],
processEscapes: true,
processEnvironments: …Run Code Online (Sandbox Code Playgroud) 我想用来scalax.io._操纵SBT的文件操作.
当我运行它时,我收到了错误消息scalax is not found.
>sbt run
import scalax.io._
[error] ^
[error] iotest.scala:49: not found: object scalax
Run Code Online (Sandbox Code Playgroud)
如何找到这个特定的库依赖?
一个更一般的问题,如何获取任何库的库依赖信息?例如,如果我需要在scala中使用actor,我需要指定一个库依赖项.如何找到库依赖?
更新:
它的行为与我的实际FB登录一致.当我退出我的Facebook然后点击我网站上的"登录"按钮时,它会将我重定向到Facebook登录页面并要求我登录.之后,我正确回到我网站上的"profile.html"网页.但是,当我从我的网站点击"退出"时,它会转到我网站的主页.这次,当我再次点击"登录"按钮时,它直接进入我网站的"profile.html".似乎最后一次"退出"根本不起作用."注销"只能在我退出我的Facebook帐户时才能使用.所以在我的网站上使用的会话依赖于facebook的会话.很奇怪!
我正在使用PassportJS来完成我的身份验证工作.但我发现req.logout()或req.session.destroy()根本不起作用.
// route for showing the profile page
app.get('/login', isLoggedIn, function(req, res) {
res.render('profile', {
user : req.user // get the user out of session and pass to template
});
});
// route middleware to make sure a user is logged in
function isLoggedIn(req, res, next) {
// if user is authenticated in the session, carry on
if (req.isAuthenticated()){
console.log("req is authenticated!");
return next();
}
// if they aren't redirect them to the home page
res.redirect('/');
}
// …Run Code Online (Sandbox Code Playgroud) 我需要多个线程来访问这个堆。所以我想确保使用 heapq 进行此类操作。
我正在尝试调整 Spark 的内存参数。我试过:
sparkSession.conf.set("spark.memory.storageFraction","0.1") //sparkSession has been created
Run Code Online (Sandbox Code Playgroud)
在我提交作业并检查 Spark UI 之后。我发现“存储内存”仍然和以前一样。所以上面的方法不起作用。
设置“spark.memory.storageFraction”的正确方法是什么?
我正在使用 Spark 2.0。
我知道我们可以在命令行中设置环境变量,如下所示:
firebase functions:config:set slack.id="XXXX" slack.secret="XXXX"
Run Code Online (Sandbox Code Playgroud)
但是如果我们有太多的环境变量需要设置,我们可以将其放入一个文件中并像这样导入:
firebase functions:config:set env_variables.json
Run Code Online (Sandbox Code Playgroud)
谢谢
我最近正在学习 WebRTC,在这里发现了“promise”的用法(https://github.com/mdn/samples-server/blob/master/s/webrtc-simple-datachannel/main.js)。
localConnection.createOffer()
.then(offer => localConnection.setLocalDescription(offer))
.then(() => remoteConnection.setRemoteDescription(localConnection.localDescription))
.then(() => remoteConnection.createAnswer())
.then(answer => remoteConnection.setLocalDescription(answer))
.then(() => localConnection.setRemoteDescription(remoteConnection.localDescription))
.catch(handleCreateDescriptionError);
Run Code Online (Sandbox Code Playgroud)
localConnection 和 removeConnection 是 RTCPeerConnection 对象。从这里https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection,
创建优惠:
void createOffer(RTCSessionDescriptionCallback successCallback, RTCPeerConnectionErrorCallback failureCallback, 可选的 MediaConstraints 约束);
createOffer 有 3 个参数。但是为什么上面的代码没有参数呢?参数在哪里?
我用"setx"为PATH环境变量添加了一个新路径.如何查看是否可以从PATH环境变量中删除新添加的路径?
$var =@( @{id="1"; name="abc"; age="1"; },
@{id="2"; name="def"; age="2"; } );
$properties = @("ID","Name","Age") ;
$format = @();
foreach ($p in $properties)
{
$format += @{label=$p ; Expression = {$_.$p}} #$_.$p is not working!
}
$var |% { [PSCustomObject]$_ } | ft $format
Run Code Online (Sandbox Code Playgroud)
在上面的例子中,我想通过一个变量名访问每个对象的属性。但它不能按预期工作。所以就我而言,如何制作
Expression = {$_.$p}
Run Code Online (Sandbox Code Playgroud)
在职的?
powershell ×2
apache-spark ×1
closures ×1
css ×1
es6-promise ×1
express ×1
firebase ×1
firebase-cli ×1
html ×1
javascript ×1
nbconvert ×1
node.js ×1
passport.js ×1
python ×1
python-3.6 ×1
sbt ×1
scriptblock ×1
session ×1
webrtc ×1