真的很简单的问题.
是什么区别:
if a.b is 'something':
Run Code Online (Sandbox Code Playgroud)
和
if a.b == 'something':
Run Code Online (Sandbox Code Playgroud)
请原谅我的无知
我想在项目变得太大之前将角度代码移动到单独的文件中.
我试图移动app,controllers并services为独立的文件,但错误停止代码参考点(或他们太通用).
我决定将文件内容放在大<script>标签上,这样我就可以解决错误并使其正常工作.不幸的是我遇到过这个问题 (由于...无法实例化模块protonApp)并且不知道如何跟踪问题(我是角色的新手)
该
(function () {
'use strict';
...
}());
Run Code Online (Sandbox Code Playgroud)
我对代码进行了整理是因为我所做的(小)研究表明,当它们位于不同的文件中时,你应该将它们放在这些代码之间.
(function () {
'use strict';
var app = angular.module('protonApp',['ui.router','protonAppControllers','protonAppServices']);
app.config(['$stateProvider', '$urlRouterProvider', function($stateProvider, $urlRouterProvider) {
...
}]);
app.value('debug',true);
app.run(function($rootScope,$state,$http,debug,LeftMenuService) {
...
});
}());
(function () {
'use strict';
angular.module('protonAppControllers', ['$scope','$http','LeftMenuService']);
}());
(function () {
'use strict';
angular.module('protonAppServices', ['$rootScope','$http']);
}());
(function () {
'use strict';
angular.module('protonAppControllers').controller('loginController',['$scope','$http','$state',function($scope,$http,$state){
...
}]);
}());
(function () {
angular.module('protonAppControllers').controller('surveyListController',['$scope','$http','LeftMenuService',function($scope,$http,LeftMenuService){
...
}]);
}());
(function () { …Run Code Online (Sandbox Code Playgroud) 我正在寻找开发一些代码,从助记符创建比特币私钥和公钥.我目前对这个过程的理解是:
entropy > nmemonic > seed > public/private keys > public address
Run Code Online (Sandbox Code Playgroud)
我在我的代码中使用了Trezor的nmemonic库和moneywagon.
import string
from random import SystemRandom, randrange
from binascii import hexlify, unhexlify
from moneywagon import generate_keypair
from mnemonic import mnemonic
def gen_rand():
foo = SystemRandom()
length = 32
chars = string.hexdigits
return ''.join(foo.choice(chars) for _ in range(length))
mnemo = mnemonic.Mnemonic('english')
entropy = gen_rand()
# entropy = '00000000000000000000000000000000'
words = mnemo.to_mnemonic(unhexlify(entropy))
seed = hexlify(mnemo.to_seed(words, passphrase='apassphrase'))
address = generate_keypair('btc', seed)
print(words)
print(seed)
print(address['public']['address'])
print(address['private']['hex'])
Run Code Online (Sandbox Code Playgroud)
如果你注释掉上面的熵行,并运行代码,你会得到: …
我正在尝试创建一个 Minio/S3 容器,以便我可以在 github 上运行我的测试套件作为操作。我目前有以下内容:
name: Run Tests
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-18.04
services:
postgres:
...
minio:
image: minio/minio
volumes:
- /data
ports:
- 9000:9000
env:
MINIO_ACCESS_KEY: minio
MINIO_SECRET_KEY: minio123
options: --entrypoint "minio server /data" --health-cmd "curl -f http://localhost:9000/minio/health/live" --health-interval 10s --health-timeout 5s --health-retries 5
steps:
...
Run Code Online (Sandbox Code Playgroud)
我尝试了以下排列来使 minio 容器正常工作,但没有成功:
volumes:
- ./data:/data
volumes:
- ./:/data
volumes:
- .:/data
volumes:
- /data:/data
Run Code Online (Sandbox Code Playgroud)
我什至尝试过:
options: --entrypoint "mkdir /data; minio server /data" …Run Code Online (Sandbox Code Playgroud) 我是新来PostgreSQL和我有什么我认为是一个简单的命令中的问题DROP DATABASE和DROPDB.为什么以下命令不会删除我的数据库?
postgres=# drop database clientms
postgres-# \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+--------------+----------+-------------+-------------+-----------------------
clientms | clientmsuser | UTF8 | en_GB.UTF-8 | en_GB.UTF-8 |
postgres | postgres | UTF8 | en_GB.UTF-8 | en_GB.UTF-8 |
template0 | postgres | UTF8 | en_GB.UTF-8 | en_GB.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | en_GB.UTF-8 | en_GB.UTF-8 | =c/postgres +
| | …Run Code Online (Sandbox Code Playgroud) 有没有什么方法可以简单地从urls.py输出文本(而不是HTML)而不是调用函数(在views.py或其他方面)?
urlpatterns = patterns('',
url(r'^$', "Hello World"),
)
Run Code Online (Sandbox Code Playgroud) 我有两个实体文件,一个是user.php,另一个是usertype.php.现在我想显示一个包含3个字段的登录表单,即用户名,密码和usertype.usertype将是一个从usertype表中获取数据的选择.这是我在user.php中编写的代码,用于为usertype_id创建manytoone字段
/**
* @ORM\ManyToOne(targetEntity="Usertype")
*/
protected $usertype;
Run Code Online (Sandbox Code Playgroud)
下面是我的表单生成代码
class LoginForm extends AbstractType
{
public function buildForm(FormBuilder $builder, array $options)
{
$builder->add('login', 'text', array('label' => 'Username',));
$builder->add('password');
}
}
Run Code Online (Sandbox Code Playgroud)
现在我需要在表单构建器中添加一个字段,该字段将是usertype表的选择.
view.py
someForm = SomeForm(request.POST)
...
someForm.customSave(request.user)
Run Code Online (Sandbox Code Playgroud)
forms.py
class SomeForm(ModelForm):
class Meta:
model = Some
def customSave(self,user):
lv = self.save(commit=False)
lv.created_by = user
lv.save()
Run Code Online (Sandbox Code Playgroud)
如何获取我刚刚保存的模型(或模型)的ID someForm?
有人可以给我一个关于语义UI中评级小部件的onRate()回调函数(http://semantic-ui.com/modules/rating.html#/settings)的示例.我已经尝试了一切:(
$('.ui.rating').rating('onRate(rating_changed())');
$('.ui.rating').rating().onRate(rating_changed());
$('.ui.rating').rating().onRate('rating_changed()');
etc ...
Run Code Online (Sandbox Code Playgroud)
我不知道它是应该在javascript中使用还是在div中用于评级(<div class="ui rating">.任何帮助都会感激不尽.
我想将链接href属性绑定到我的控制器中的变量,但我也想将该url绑定到变量.我想使用内置绑定完成此操作,而无需手动监视更改并重新加载URL.这可能吗?
// In the controller
$scope.section = 'section1';
$scope.page = 'page1';
$scope.url = 'http://myurl/{{section}}/{{page}}';
<!-- In the template -->
<a ng-href="{{url}}">Page Link</a>
Run Code Online (Sandbox Code Playgroud)
这是我实际代码的简化.声明模板中的url模式会起作用,但我需要在传入的字符串中定义url.
python ×4
angularjs ×2
django ×2
bitcoin ×1
containers ×1
cryptography ×1
django-urls ×1
docker ×1
javascript ×1
jquery ×1
minio ×1
mnemonics ×1
postgresql ×1
psql ×1
semantic-ui ×1
symfony ×1
yaml ×1