我试图找出为什么我的virtualenv和/或virtualenv包装 - 使用pip使用homebrew- 安装无法找到.我认为这是因为它没有添加到我的路径中:
$ which virtualenv
$
Run Code Online (Sandbox Code Playgroud)
和:
$ virtualenv someDir
$ -bash: virtualenv: command not found
Run Code Online (Sandbox Code Playgroud)
我安装使用PIP homebrew和virtualenv使用pip,没有任何问题.我尝试重新安装virtualenv,但这也无效.我如何知道要添加的路径PATH?只是virtualenv.py似乎安装的路径?这似乎是:
/usr/local/lib/python2.7/site-packages/virtualenv.py
Run Code Online (Sandbox Code Playgroud)
我也找到了这个指南,它暗示了这一点:
$ ln -s ../Cellar/python/2.7/Frameworks/Python.framework/Versions/2.7/bin/virtualenv virtualenv
Run Code Online (Sandbox Code Playgroud)
但是,它并没有帮我跑virtualenv.我在Mac OSX 10.7.5(Lion)上.
我遇到了来自Angular-ui-bootstrap的模态服务的问题.我根据以下示例设置了模式:http://angular-ui.github.io/bootstrap/但如果我从模态内容中删除列表项并替换它们,我无法从模态返回结果具有文本区域和不同的ng模型.我会设置一个jsfiddle,但我不知道如何包含显示我想要的特定库(如angular-ui-bootstrap).我有我的模态的截图:http://d.pr/i/wT7G.
以下是我的主控制器,主视图,模态控制器和模态视图中的代码:
主视图代码
<button type="button" class="btn btn-success" ng-click="importSchedule()">import schedule (JSON)</button>
Run Code Online (Sandbox Code Playgroud)
主控制器
$scope.importSchedule = function() {
var modalInstance = $modal.open({
templateUrl: 'views/importmodal.html',
controller: 'ModalInstanceCtrl'
});
modalInstance.result.then(function (result) {
console.log('result: ' + result);
// $scope.schedule = angular.fromJson(scheduleJSON);
}, function () {
console.info('Modal dismissed at: ' + new Date());
});
};
Run Code Online (Sandbox Code Playgroud)
模态视图
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title">Import schedule(JSON)</h4>
</div>
<div class="modal-body">
<textarea class="form-control" rows="15" ng-model="schedule"></textarea>
<pre>form = {{schedule | json}}</pre>
</div> …Run Code Online (Sandbox Code Playgroud) modal-dialog twitter-bootstrap angularjs angular-ui-bootstrap
我有一个项目,我使用node-webkit.node-webkit允许npm包用于开发桌面应用程序.我利用grunt来构建我的应用程序.
我的文件夹结构目前看起来像这样:
project root
node_modules/ (1)
package.json (1)
App/
node_modules/ (2)
package.json (2)
bower.json
bower_components/
...
controllers/
filters/
...
app.js
Run Code Online (Sandbox Code Playgroud)
应用程序本身的npm依赖项保存在App文件夹中,但构建项目的dev依赖项与应用程序源代码无关,因此我将它们保存在根文件夹内的node_modules(1)中.我也知道在package.json文件中,可以表达依赖关系和dev依赖关系,正是出于这个原因.我宁愿在根目录中有一个表示所有依赖项的package.json文件,包括dev依赖项,但我宁愿在文件夹级别上分离这些依赖项.
出现两个问题:
这是组织我的npm依赖项的好方法吗?如果是的话,太棒了?如果不是,我期望:
什么是组织我的依赖项的更好方法?是否可以指定dev依赖项进入文件夹a,"常规"依赖项进入文件夹b?如果是这样,我该怎么做?
如果有人想知道,这是我正在谈论的项目:
https://github.com/michahell/pinbored-webkit
[为了清晰起见,更新了包含app.js的文件夹结构]
所以我使用Haxe NME(HTML5 target ofc)构建了一个简单的websocket客户端实现.
它连接到
ws://echo.websocket.org (sorry no link, SO sees this as an invalid domain)
Run Code Online (Sandbox Code Playgroud)
哪作得很好!(我正在使用xirsys_stdjs haxelib来使用HTML5 websocket的东西.)
我希望有一个本地(在我自己的机器上)运行websocket 服务器.我现在正在使用Socket.io,因为我无法找到更简单/更简单的解决方案.
我目前正在尝试使用socket.io作为套接字服务器,但是使用"标准"javascript套接字实现作为客户端(Haxe HTML5),而不使用socket.io库clientside.
有谁知道这是否应该可行?因为我无法让它发挥作用.这是我的socket.io代码:
var app = require('http').createServer(handler)
, io = require('socket.io').listen(app)
, fs = require('fs')
app.listen(1337);
function handler (req, res) {
fs.readFile(__dirname + '/client.html',
function (err, data) {
if (err) {
res.writeHead(500);
return res.end('Error loading index.html');
}
res.writeHead(200);
res.end(data);
});
}
// WEBSOCKET IMPLEMENTATION
io.sockets.on('connection', function (socket) {
console.log("webSocket connected...");
socket.on('message', function () …Run Code Online (Sandbox Code Playgroud) 我想知道如何仅通过其 URL 插入图像(用户从其他网站获取)。我需要在 CKEditor 5 中实现一个简单的img src=""。问题是,默认情况下,编辑器要求我上传图像,而我需要插入外部 url。
我已经阅读了许多相关主题(1、2、3),但没有发现与我类似的问题。我什至不需要特殊按钮,也许我可以以某种方式在 CKEditor 中输入img src="myurl"(直接在编辑器中输入它对我不起作用)然后让它在我之后被感知为一个 html 代码将@Html.Raw(Model.Text)应用于我从 CKeditor textarea 存储在数据库中的整个文本。
这就是我将数据从编辑器插入网页后得到的结果。我认为这是因为出于安全原因,标签被视为文本。
PS Stack 溢出图像插入工具允许当我在对话框中单击来自网络的链接时通过其 url 上传图像。所以我想要 CKEditor 5 中类似的东西。
将非常感谢任何帮助!
注意使用相关代码段进行编辑
我遇到了一个奇怪的问题,在发出router.navigate时进入了无限重定向循环。
设定
LoginViewComponent具有两个行为:
重定向仅通过以下逻辑位发出:
this.router.navigate(["foo"])
const routes: Routes = [
{
path: "",
redirectTo: "login",
pathMatch: "full"
},
{
path: "login",
component: LoginViewComponent
},
{
path: "foo",
component: FooComponentView
}
];
@NgModule({
imports: [RouterModule.forRoot(routes, { useHash: true, enableTracing: true})],
exports: [RouterModule]
})
export class AppRoutingModule { }
Run Code Online (Sandbox Code Playgroud)
问题
对 SO 的一些搜索让我相信没有好的(简单的)方法来实现标题中的问题。以下线程都非常相关:
从最后一个线程 ^ 来看,实现这一点的唯一方法似乎是使用withLatestFrom()or combineLatest()。
以下不可能是确保您只收到 1 件商品且该商品是最新商品的唯一方法:
of('terribleLatestValueHack').pipe(
withLatestFrom(this.store.select(itemSelector))
).subscribe((stringAndItem: [string, Item]) => {
const [, item] = stringAndItem;
// do something with item
});
Run Code Online (Sandbox Code Playgroud)
鉴于从商店中选择一件最新商品
我真的很想知道为什么现有的支持(显然 - 在 NGRX v2 中 - 根据How to get current value of State object with @ngrx/store?)已被删除。
在单元测试中只创建(实例化)具有DomSanitizer依赖关系的组件,如何模拟/存根这种依赖关系?
因为DomSanitizer是一个Abstract类,我不知道方法签名究竟是什么bypassSecurityTrustHtml样的.
如果它不打算模拟/存根DomSanitizer,那么应该如何继续注入抽象类的实际实现呢?
组件中的实际语句如下所示:
this.trustedString = <string>this.domSanitizer.bypassSecurityTrustHtml(trustedHTML);
Run Code Online (Sandbox Code Playgroud)
TestBed 设置看起来像:
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
BrowserModule,
// other modules
],
providers: [
{
provide: DomSanitizer,
useValue: {
bypassSecurityTrustHtml: () => 'safeString'
}
},
// more providers
],
declarations: [ TheComponent ],
schemas: [ NO_ERRORS_SCHEMA ]
})
.compileComponents();
}));
Run Code Online (Sandbox Code Playgroud)
我在Chrome中的Karma(而不是无头)中遇到的具体错误是:
TypeError: view.root.sanitizer.sanitize is not a function
error属性:Object({ngDebugContext:DebugContext _({view:Object({def:Object({factory:Function,nodeFlags:16793601,rootNodeFlags:1,nodeMatchedQueries:0,flags:0,nodes:[Object({nodeIndex:0 ,parent:null,renderParent:null,bindingIndex:0,outputIndex:0,checkIndex:0,flags:1,childFlags:16793601,directChildFlags:16777217,childMatchedQueries:0,matchedQueries:Object({}),matchedQueryIds:0,references :Object({}),ngContentIndex:null,childCount:5,bindings:[],bindingFlags:0,outputs:[],element:Object({ns:null,name:null,attrs:[],template:null ,componentProvider:null,componentView:null,componentRendererType:null,publicProviders:null({}),allProviders:null({}),handleEvent:Function}),provider:null,text:null,query:null,ngContent:null }),Object({nodeIndex:1,parent:Object({nodeIndex:0,parent:null,renderParent:null,bindingIndex:0,outputIndex:0,checkIndex:0,flags:1,childFlags:16793601,directChildFlag s:16777217 ... at setElementProperty(webpack:///./node_modules/@angular/core/fesm5/core.js?:8237:61)at checkAndUpdateElementValue(webpack:///./node_modules/@angular/在checkAndUpdateNodeInline(webpack:///. /node_modules/@angular/core/fesm5/core.js?:10477:20)在checkChendAndUpdateNode上的checkAndUpdateNode(webpack:///./node_modules/@angular/core/fesm5/core.js?:10443:16) webpack:///./node_modules/@angular/core/fesm5/core.js?:11076:38)在debugCheckRenderNodeFn(webpack:///./node_modules/@angular/core/fesm5/core.js?:11062 :13)在Object.eval [as …
我想知道,在阅读了关于改进你的Python中的生成器:'yield'和Generators Explained,但尚未对它们进行实验之后,为什么生成器函数的句法符号与常规函数的语法符号没有区别.在我的思想实验中,最明显的选择是:
generator generator_name(param):
# ...
yield some_other_value
Run Code Online (Sandbox Code Playgroud)
代替:
def generator_name(param):
# ...
yield some_value
Run Code Online (Sandbox Code Playgroud)
现在,当一个人正在阅读Python代码时,似乎在理解某些函数是生成器函数之前,首先需要搜索"yield"这个词.或者,是否有一个Python约定要求生成器函数具有指示性名称?喜欢generate_some_value_from_y?
作为一名 Rust 初学者,正在研究 Exercism/Rust 上的第一个问题(https://exercism.org/tracks/rust/exercises/assemble-line),
我想知道是否可以将整数输入限制在一个范围内在编译时
能够拥有一组干净的match expression案例。
以下是我当前的实现production_rate_per_hour:
pub fn production_rate_per_hour(mut speed: u8) -> f64 {
speed = cmp::max(speed, 10);
let cars_per_hour: u8 = 221;
match speed {
0 => 0.0,
1 ..= 4 => (speed * cars_per_hour) as f64,
5 ..= 8 => (speed * cars_per_hour) as f64 * 0.9,
9 | 10 => (speed * cars_per_hour) as f64 * 0.77
}
}
Run Code Online (Sandbox Code Playgroud)
我正在尝试编写一个方法,该方法接受名为的单个mutable u8参数speed,然后将其限制在范围内,0..=10如下所示:
speed …
angular ×2
python ×2
angularjs ×1
asp.net-core ×1
ckeditor ×1
ckeditor5 ×1
generator ×1
haxe ×1
image ×1
javascript ×1
macos ×1
modal-dialog ×1
ngrx ×1
node-webkit ×1
node.js ×1
npm ×1
office-js ×1
path ×1
pep ×1
pip ×1
rust ×1
rxjs ×1
sanitization ×1
socket.io ×1
syntax ×1
unit-testing ×1
virtualenv ×1
websocket ×1