在ubuntu 12.04上,我得到了以下内容.
sudo apt-get install libxml2 libxml2-dev libxslt libxslt-dev
sudo gem install nokogiri
Building native extensions. This could take a while...
ERROR: Error installing nokogiri:
ERROR: Failed to build gem native extension.
/usr/bin/ruby1.9.1 extconf.rb
/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- mkmf (LoadError)
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from extconf.rb:5:in `<main>'
Gem files will remain installed in /var/lib/gems/1.9.1/gems/nokogiri-1.5.9 for inspection.
Results logged to /var/lib/gems/1.9.1/gems/nokogiri-1.5.9/ext/nokogiri/gem_make.out
Run Code Online (Sandbox Code Playgroud)
这是我的红宝石版本
ruby --version
ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-linux]
Run Code Online (Sandbox Code Playgroud)
我正在尝试安装使用刀-ec2为厨师.
我正在努力使用rc5的angular2-jwt文档
这是我的NgModule
import { AuthHttp } from 'angular2-jwt';
@NgModule({
imports: [ BrowserModule,
routing,
HttpModule,
FormsModule,
],
declarations: [
AppComponent,
LoginComponent,
NavbarComponent,
DashboardComponent,
ModelsComponent
],
providers: [AuthGuard,
ModelService,
AuthHttp
],
bootstrap: [ AppComponent ]
})
export class AppModule { }
Run Code Online (Sandbox Code Playgroud)
这是我的服务
import { Injectable } from '@angular/core';
import {Http} from '@angular/http';
import 'rxjs/add/operator/map';
import { Model } from './model';
import { AuthHttp } from 'angular2-jwt';
import {Observable} from "rxjs/Rx";
@Injectable()
export class ModelService {
private _url = "http://127.0.0.1:8050/test/model";
constructor(private _http: Http,private …Run Code Online (Sandbox Code Playgroud) Python请求有问题:
rs = requests.get(STREAM_URL, stream=True,headers=headers)
Process Process-1:
Traceback (most recent call last):
File "/usr/lib/python2.7/multiprocessing/process.py", line 258, in _bootstrap
self.run()
File "/usr/lib/python2.7/multiprocessing/process.py", line 114, in run
self._target(*self._args, **self._kwargs)
File "oanda_streaming_pairs_server.py", line 287, in multistreamer
rs = requests.get(STREAM_URL, stream=True,headers=headers)
File "/usr/local/lib/python2.7/dist-packages/requests-2.12.0-py2.7.egg/requests/api.py", line 70, in get
return request('get', url, params=params, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests-2.12.0-py2.7.egg/requests/api.py", line 56, in request
return session.request(method=method, url=url, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests-2.12.0-py2.7.egg/requests/sessions.py", line 488, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests-2.12.0-py2.7.egg/requests/sessions.py", line 609, in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests-2.12.0-py2.7.egg/requests/adapters.py", …Run Code Online (Sandbox Code Playgroud) Angular2..为什么以及如何?
如何在angular2中执行以下if条件
<td *ngFor="let val of rows;let j=index">
IF J==0
<label>{{val}}</label>
ELSE:
<label style="color:#000000;font-size:12px;padding-top: 5px">{{val}}</label>
</td>
Run Code Online (Sandbox Code Playgroud) 如何在python中将StringIO中的图像读入PIL?我将有一个stringIO对象.如何从中读取图像?我无法从文件中读取图像.哇!
from StringIO import StringIO
from PIL import Image
image_file = StringIO(open("test.gif",'rb').readlines())
im = Image.open(image_file)
print im.format, "%dx%d" % im.size, im.mode
Traceback (most recent call last):
File "/home/ubuntu/workspace/receipt/imap_poller.py", line 22, in <module>
im = Image.open(image_file)
File "/usr/local/lib/python2.7/dist-packages/Pillow-2.3.1-py2.7-linux-x86_64.egg/PIL/Image.py", line 2028, in open
raise IOError("cannot identify image file")
IOError: cannot identify image file
Run Code Online (Sandbox Code Playgroud) 如果用户从具有脏表单的页面导航,我成功使用canDeactivate提供警告消息:
我正在使用的代码在这里:
is_submit = false;
canDeactivate() {
//https://scotch.io/courses/routing-angular-2-applications/candeactivate
if (this.myForm.dirty == true && this.is_submit==false){
return window.confirm('Discard changes?');
} //end if
return true
} // end canDeactivate
Run Code Online (Sandbox Code Playgroud)
这是我得到代码的地方:
https://scotch.io/courses/routing-angular-2-applications/candeactivate
但是我想使用angular2对话框.这是我的代码:
//ts for the main component
is_submit = false;
canDeactivate() {
if (this.myForm.dirty == true && this.is_submit==false){
const config = new MdDialogConfig();
config.disableClose=true;
let dialogRef = this.dialog.open(DialogCanDeactive,config);
dialogRef.afterClosed().subscribe(result => {
if (result=='cancel'){
return false;
}
if (result=='save'){
return true;
}
if (result=='discard'){
return true;
}
}); //end dialogRef
} //end if
return …Run Code Online (Sandbox Code Playgroud) 我只是想运行一个简单的测试示例,但我得到以下错误.我该如何解决?
import asyncio
import uvloop
import concurrent.futures
import time
asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())
async def do_some_work(x):
while True:
print("Waiting " + str(x))
await asyncio.sleep(x)
if __name__ == '__main__':
loop = asyncio.new_event_loop()
tasks = [asyncio.ensure_future(do_some_work(2)),
asyncio.ensure_future(do_some_work(5))]
loop.run_until_complete(asyncio.gather(*tasks))
Traceback (most recent call last):
File "/Users/worker_why.py", line 23, in <module>
loop.run_until_complete(asyncio.gather(*tasks))
File "uvloop/loop.pyx", line 1181, in uvloop.loop.Loop.run_until_complete (uvloop/loop.c:25184)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/asyncio/tasks.py", line 508, in ensure_future
raise ValueError('loop argument must agree with Future')
ValueError: loop argument must agree with Future
Run Code Online (Sandbox Code Playgroud) 我使用以下内容删除route53记录.我没有收到任何错误消息.
conn = Route53Connection(aws_access_key_id, aws_secret_access_key)
changes = ResourceRecordSets(conn, zone_id)
change = changes.add_change("DELETE",sub_domain, "A", 60,weight=weight,identifier=identifier)
change.add_value(ip_old)
changes.commit()
Run Code Online (Sandbox Code Playgroud)
所有必填字段都存在且匹配..权重,标识符,ttl = 60等.\
例如
test.com. A 111.111.111.111 60 1 id1
test.com. A 111.111.111.222 60 1 id2
Run Code Online (Sandbox Code Playgroud)
我想删除111.111.111.222和记录集.
那么,删除记录集的正确方法是什么?
对于记录集,我将有多个值,这些值由唯一标识符区分.当ip地址变为活动状态时,我想从route53中删除.我使用的是一个可怜的勒芒负载平衡.
Here is the meta of the record want to delete.
{'alias_dns_name': None,
'alias_hosted_zone_id': None,
'identifier': u'15754-1',
'name': u'hui.com.',
'resource_records': [u'103.4.xxx.xxx'],
'ttl': u'60',
'type': u'A',
'weight': u'1'}
Traceback (most recent call last):
File "/home/ubuntu/workspace/rtbopsConfig/classes/redis_ha.py", line 353, in <module>
deleteRedisSubDomains(aws_access_key_id, aws_secret_access_key,platform=platform,sub_domain=sub_domain,redis_domain=redis_domain,zone_id=zone_id,ip_address=ip_address,weight=1,identifier=identifier)
File "/home/ubuntu/workspace/rtbopsConfig/classes/redis_ha.py", line 341, in deleteRedisSubDomains …Run Code Online (Sandbox Code Playgroud) 1)我有一个数据包如下:
"zookeeper":{
"server1":"111.111.111.111",
"server2":"222.222.222.222"
},
Run Code Online (Sandbox Code Playgroud)
2)在我的食谱中,我得到哈希如下.
data_bag("mydb")
db = data_bag_item("mydb", "rtb")
ZOOKEEPER = db['zookeeper']
Run Code Online (Sandbox Code Playgroud)
3)同样在我的食谱中我有一个模板如下:
template "/etc/zookeeper/conf/zoo.cfg" do
path "/etc/zookeeper/conf/"
source "zoo.cfg.erb"
owner "root"
group "root"
mode "0644"
variables :zookeeper => #{ZOOKEEPER}
end
Run Code Online (Sandbox Code Playgroud)
4)我需要让我的模板看起来像这样
server.1=111.111.111.111:2888:3888
server.2=222.222.222.222:2888:3888
Run Code Online (Sandbox Code Playgroud)
我的问题是这个.如何将哈希传递给模板,以便循环哈希并创建temlplate?我不是一个强大的红宝石编码器.
例如:
count = 1
for server, ipaddress in zookeeper:
server.count=ipaddress:2888:3888
count = count + 1
Run Code Online (Sandbox Code Playgroud) 我只想在python中发送带附件的电子邮件
import smtplib, os
from email.MIMEMultipart import MIMEMultipart
from email.MIMEBase import MIMEBase
from email.MIMEText import MIMEText
from email.Utils import COMMASPACE, formatdate
from email import Encoders
def send_mail(send_from, send_to, subject, text, files=[], server="localhost"):
assert type(send_to)==list
assert type(files)==list
msg = MIMEMultipart()
msg['From'] = send_from
msg['To'] = COMMASPACE.join(send_to)
msg['Date'] = formatdate(localtime=True)
msg['Subject'] = subject
msg.attach( MIMEText(text) )
for f in files:
part = MIMEBase('application', "octet-stream")
part.set_payload( open(f,"rb").read() )
Encoders.encode_base64(part)
part.add_header('Content-Disposition', 'attachment; filename="%s"' % os.path.basename(f))
msg.attach(part)
smtp = smtplib.SMTP('smtp.gmail.com:587')
smtp.login('fu@gmail.com','fu')
smtp.sendmail(send_from, send_to, msg.as_string())
smtp.close() …Run Code Online (Sandbox Code Playgroud) python ×5
angular ×3
ruby ×2
angular2-jwt ×1
boto ×1
chef-infra ×1
email ×1
gem ×1
nokogiri ×1
python-2.7 ×1
python-3.6 ×1
smtp ×1
smtplib ×1