你会如何除以3为数字,没有使用*,/,+,-,%,运营商?
号码可以是签名或未签名.
我在下面使用MongoDb的Node.js应用程序:
var MongoClient = require('mongodb').MongoClient;
var demoPerson = { name:'John', lastName:'Smyth' };
var findKey = { name: 'John' };
MongoClient.connect('mongodb://127.0.0.1:27017/demo', { useNewUrlParser: true }, function(err, client) {
const db = client.db('demo');
if(err) throw err;
console.log('Successfully connected');
//console.log(db);
var collection = db.collection('people');
collection.insert(demoPerson, function(err, docs) {
console.log('Inserted', docs[0]);
console.log('ID:', demoPerson._id);
collection.find(findKey).toArray(function(err, results) {
console.log('Found results:', results);
collection.remove(findKey, function(err, results) {
console.log('Deleted person');
db.close();
});
});
});
});
Run Code Online (Sandbox Code Playgroud)
当我运行它时,我收到此错误:
TypeError: db.close is not a function
Run Code Online (Sandbox Code Playgroud)
我不明白为什么这不起作用.有人可以帮忙吗?
我有一个Node.js应用程序.当我尝试运行时,npm install它会挂起:
loadIdealTree:loadAllDepsIntoIdealTree: sill install loadIdealTree
Run Code Online (Sandbox Code Playgroud)
npm install --verbose 给了我一些额外的信息:
npm info it worked if it ends with ok
npm verb cli [ '/usr/local/bin/node',
npm verb cli '/usr/local/bin/npm',
npm verb cli 'install',
npm verb cli '--verbose',
npm verb cli 'aws-sdk-js' ]
npm info using npm@5.8.0
npm info using node@v8.9.2
npm verb npm-session ea38310110279de7
npm http fetch GET 404 https://registry.npmjs.org/aws-sdk-js 2211ms
npm verb stack Error: 404 Not Found: aws-sdk-js@latest
npm verb stack at fetch.then.res (/usr/local/lib/node_modules/npm/node_modules/pacote/lib/fetchers/registry/fetch.js:42:19)
npm verb stack at …Run Code Online (Sandbox Code Playgroud) 我开始阅读"学习Spring Boot 2.0 - 第二版:简化基于微服务和反应式编程的快速闪存应用程序的开发",并且遇到了第一个示例程序之一的问题.
当我http://localhost:8080/chapters对它进行GET 返回时:
[
{},
{},
{}
]
Run Code Online (Sandbox Code Playgroud)
代替:
[
{"id": 1,
"name": "Quick Start with Java"},
{"id":,
"name": "Reactive Web with Spring Boot"},
{"id": 3,
"name": ... and more!"}
]
Run Code Online (Sandbox Code Playgroud)
这是我的代码(减去进口):
@Data
@Document
public class Chapter {
@Id
private String id;
private String name;
public Chapter(String name) {
this.name = name;
}
}
public interface ChapterRepository extends ReactiveCrudRepository<Chapter, String>{
}
@Configuration
public class LoadDatabase {
@Bean
CommandLineRunner init(ChapterRepository repository) {
return args -> …Run Code Online (Sandbox Code Playgroud) 我有这个文本框:
<Typography component="p" className={classes.text}>
{this.props.post.text}
</Typography>
Run Code Online (Sandbox Code Playgroud)
我希望能够包含段落,但输入的所有文本都打印在一行上。
文档表明这paragraph是默认的,false所以我必须将它设置为“true”。
我尝试了以下方法:
<Typography component="p" className={classes.text} paragraph="true">
Run Code Online (Sandbox Code Playgroud)
我也试过:
<Typography component="p" className={classes.text} paragraph={true}>
Run Code Online (Sandbox Code Playgroud)
两者都不起作用,所以我所有的文本仍然打印到一行。
如何让段落显示?
附加信息:
据我所知,Typography 中的段落={true} 属性只是为整个文本添加了一个下边距。IE 我的一个文本块是一个段落。如果我想要另一个段落,我将不得不添加另一个Typography. 就像是:
<Typography component="p" className={classes.text} paragraph={true}>
{this.props.post.text}
</Typography>
<Typography component="p" className={classes.text} paragraph={true}>
{this.props.post.text2}
</Typography>
Run Code Online (Sandbox Code Playgroud)
这不正是我想要的。也许我的目标是让我的输入文本中的返回字符得到识别。这是正确的,如果是,它是如何完成的?
我试过这个:
<pre>
<Typography component="p" className={classes.text}>
{this.props.post.text}
</Typography>
</pre>
Run Code Online (Sandbox Code Playgroud)
标签按原样保留标签内的空格和换行符。
不过这不合适。如果我有很长的行,文本不会以卡片宽度换行。相反,超出卡片宽度的任何内容都会被截断。显然我想要这一切。我希望我的文本能够包裹在卡片中,并支持新的行和段落。这是怎么做的?
我有这门课:
import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
// tag::code[]
@Data
@Document
public class Image {
@Id final private String id;
final private String name;
}
// end::code[]
Run Code Online (Sandbox Code Playgroud)
我的理解是@Data默认情况下应该为所有最终字段创建一个构造函数。但是,当我运行我的应用程序时,出现此错误:
error: variable id not initialized in the default constructor
@Id final private String id;
Run Code Online (Sandbox Code Playgroud)
为什么会发生这种情况?
在我的Laravel 5.7应用程序中,我想使用elasticsearch,我发现了这篇 https://michaelstivala.com/learning-elasticsearch-with-laravel/文章.首先,我想从我想用于elasticsearch的表中导入所有数据1)我创建了一个包装文件app/Elastic.php,其内容来自githubusercontent.这个文件的正确目录是什么?
2)在我的模型app/Vote.php中我添加了功能
public static function bulkVotesToElastic(){
$elastic = app(App\Elastic\Elastic::class);
Vote::chunk(100, function ($Votes) use ($elastic) {
foreach ($Votes as $Vote) {
$elastic->index([
'index' => 'select_vote',
'type' => 'vote',
'id' => $Vote->id,
'body' => $Vote->toArray()
]);
}
});
Run Code Online (Sandbox Code Playgroud)
}
因为我有播种器填充init数据.但是调用这个方法我得到了错误:
Class App\App\Elastic\Elastic does not exist
Run Code Online (Sandbox Code Playgroud)
为什么错误以及如何解决?
实际上这一行
$elastic = app(App\Elastic\Elastic::class);
Run Code Online (Sandbox Code Playgroud)
在我的laravel expierence背后...
谢谢!
在 Mac 上使用 sshfs 后,我无法再看到我的用户目录。
当我打开终端窗口时,我看到以下内容:
Last login: Mon May 22 10:54:30 on ttys003
mkdir: /Users/<username>/.bash_sessions: Device not configured
-bash: /Users/<username>/.bash_profile: Device not configured
touch: /Users/<username>/.bash_sessions/35166655-583B-47CC-9BCF-5E785DD5E46E.historynew: Device not configured
Run Code Online (Sandbox Code Playgroud)
有没有什么办法解决这一问题?
干杯保罗
Strava API 文档提供了以下示例代码,我复制并输入了我自己的访问令牌和俱乐部 ID:
from __future__ import print_statement
import time
import swagger_client
from swagger_client.rest import ApiException
from pprint import pprint
# Configure OAuth2 access token for authorization: strava_oauth
swagger_client.configuration.access_token = 'MY_ACCESS_TOKEN'
# create an instance of the API class
api_instance = swagger_client.ClubsApi()
id = MY_CLUB_ID # Integer | The identifier of the club.
page = 56 # Integer | Page number. (optional)
perPage = 56 # Integer | Number of items per page. Defaults to 30. (optional) (default to 30) …Run Code Online (Sandbox Code Playgroud) 我使用 Spring Initializr 创建了一个项目。
当我在 IntelliJ 中打开它时,我在构建中看到以下错误:
java.lang.RuntimeException: org.codehaus.plexus.component.repository.exception.ComponentLookupException: com.google.inject.ProvisionException: 无法配置,请参阅以下错误:
- 注入构造函数时出错,java.lang.NoSuchMethodError:org.apache.maven.model.validation.DefaultModelValidator:在org.jetbrains.idea.maven.server.embedder.CustomModelValidator.(来源未知)中找不到方法“void()”定位 org.jetbrains.idea.maven.server.embedder.CustomModelValidator 在 ClassRealm[maven.ext, 父级: ClassRealm[plexus.core, 父级: null]] (通过模块: org.eclipse.sisu.wire.WireModule -> org .eclipse.sisu.plexus.PlexusBindingModule),同时找到用 @com.google.inject.name.Named(value="ide") 注释的 org.apache.maven.model.validation.ModelValidator
1个错误角色:org.apache.maven.model.validation.ModelValidator角色提示:ide
我还注意到,如果我尝试添加运行配置,则找不到主类。这里可能出了什么问题?
java ×3
spring-boot ×3
node.js ×2
c ×1
constructor ×1
divide ×1
division ×1
eclipse ×1
javascript ×1
laravel-5 ×1
lombok ×1
macos-sierra ×1
material-ui ×1
math ×1
maven ×1
mongodb ×1
npm ×1
python ×1
python-3.x ×1
reactjs ×1
spring ×1
ssh-tunnel ×1
strava ×1
swagger ×1
tunnel ×1
typeerror ×1
typography ×1
user-profile ×1