我刚刚使用以下命令安装了 Node 和 Yarn:
brew install node
brew install yarn --without-node
node -v
v11.8.0
-a node
node is /usr/local/bin/node
yarn -v
1.13.0
type -a yarn
yarn is /usr/local/bin/yarn
Run Code Online (Sandbox Code Playgroud)
但是,如果我在终端中写的npm是“zsh:找不到命令:npm”
在我的:~/.zshrc我有:
ZSH=$HOME/.oh-my-zsh
# You can change the theme with another one:
# https://github.com/robbyrussell/oh-my-zsh/wiki/themes
ZSH_THEME="robbyrussell"
# Useful plugins for Rails development with Sublime Text
plugins=(gitfast last-working-dir common-aliases sublime zsh-syntax-highlighting history-substring-search)
# Prevent Homebrew from reporting - https://github.com/Homebrew/brew/blob/master/share/doc/homebrew/Analytics.md
export HOMEBREW_NO_ANALYTICS=1
# Actually load Oh-My-Zsh
source "${ZSH}/oh-my-zsh.sh"
unalias rm # …Run Code Online (Sandbox Code Playgroud) 我正在尝试提取文件的内容(作为字符串/文本).pst。
我尝试了不同的答案,但没有找到任何相关的解决方案。
使用 pypff / libpff 导出 PST 和 OST
我主要关注libpff库(https://github.com/libyal/libpff),但我认为该库对于提取 pst 文本没有帮助。
我的代码:
import pypff
pst = pypff.file()
pst.open("my_pst_file.pst")
Run Code Online (Sandbox Code Playgroud)
该代码打开 pst,但我不知道如何将其内容提取为 txt。
我正在创建一个网站,用户可以在其中在搜索栏中键入他要查找的内容。
最初,我onChange对用户搜索后面的一个字符这一事实有疑问。例如,如果用户搜索“banana”,则搜索结果为“banan”。我知道问题来自于setState异步的事实。
onChange 是延迟的一个字符 - Hooks
为了避免这个问题,我useEffect在我的代码中引入了这个组件。有用。
但是现在,如果用户键入一些词,他键入的词不会立即显示在搜索栏中。它们会在几分钟后显示,就好像用户输入的内容和显示的内容之间存在延迟。
我的搜索栏组件
export default function SearchBar({handlerSearchBar}) {
const classes = useStyles();
const [searchBarQuery, setSearchBarQuery] = React.useState([""])
function handleChange(event) {
setSearchBarQuery(event.target.value);
console.log(searchBarQuery)
}
useEffect(() => {
console.log("Search message inside useEffect: ", searchBarQuery);
handlerSearchBar(searchBarQuery)
});
return (
<form className={classes.container} noValidate autoComplete="off">
<TextField
required
id="standard-full-width"
label="Searchbar"
style={{ marginLeft: 40, marginRight: 40 }}
placeholder="Write your query"
// helperText="The results will appear below!"
fullWidth
margin="normal"
InputLabelProps={{
shrink: true,
}}
onChange={handleChange}
/> …Run Code Online (Sandbox Code Playgroud) 我正在使用 TypeScript ( Version 3.8.3) 和 React 构建一个小型网站。
我有一个名为 的组件MyComponent。它以 function 作为 prop handleChange。但是,我收到此错误:
Argument of type 'ChangeEvent<{}>' is not assignable to parameter of type 'ChangeEvent<HTMLSelectElement>'
Run Code Online (Sandbox Code Playgroud)
功能
const handleChange = (
event: ChangeEvent<HTMLInputElement>,
value: MyValue
) => {
setSelectedObj(value)
}
Run Code Online (Sandbox Code Playgroud)
我的组件
<Autocomplete
...
onChange={(event, value) => handleChange(event, value)}
...
/>
Run Code Online (Sandbox Code Playgroud)
我检查了以下类似问题,但没有取得太大成功。
我正在尝试从我的 GitHub 在 Netlify 上部署我的网站。
但是我坚持以下错误:
11:37:19 AM: failed during stage 'deploying site': Invalid filename 'node_modules/es5-ext/date/#/format.js'. Deployed filenames cannot contain # or ? characters
Run Code Online (Sandbox Code Playgroud)
我尝试删除并升级模块,es5-ext但错误仍然存在。
我正在使用 Typescript、Express、TypeORM、GraphQL 和 TypeGraphQL 来构建一个允许用户登录的小应用程序。
但是,当我bye在 GraphQL 操场上点击我的测试查询时,我得到:
Cannot read property 'context' of undefined
"TypeError: Cannot read property 'context' of undefined",
" at new exports.isAuth // isAuth is a JS file I wrote
Run Code Online (Sandbox Code Playgroud)
我的上下文.js
import { Request, Response } from "express";
export interface MyContext {
req: Request;
res: Response;
payload?: { userId: string };
}
Run Code Online (Sandbox Code Playgroud)
isAuth.js
import { MiddlewareFn } from "type-graphql";
import { verify } from "jsonwebtoken";
import { MyContext } from "./MyContext";
export const isAuth: MiddlewareFn<MyContext> …Run Code Online (Sandbox Code Playgroud) 我正在使用 apollo-server-lambda、Prisma ORM 和 graphql-codegen。
我有getBookById一个返回Book. Book包含一个名为 的枚举BookStatus。我希望能够在操场上以 ENUM 形式返回,但出现错误:
无法为不可为 null 的字段 Book.bookStatus 返回 null。
图书状态 - TypeDef
enum BookStatus {
OPEN
DRAFT
CLOSED
}
Run Code Online (Sandbox Code Playgroud)
书籍 - TypeDef
type Book {
id: ID!
title: String!
bookStatus: BookStatus!
}
Run Code Online (Sandbox Code Playgroud)
getBookById - TypeDef
type Query {
getBookById(getBookByIdInput: GetBookByIdInput): Book
}
Run Code Online (Sandbox Code Playgroud)
我遇到了一个我在Rails和ActiveRecord中不完全理解的函数(?).
我正在构建一个基本网站,其中用户(创建devise)可以上传document(字段是:title和attachment)因此,当用户前往时,www.website.com/documents/new他会出现一个simple_form,要求他写一个标题并附上PDF.确认后,文档将保存在数据库中并链接到用户.一切正常.
我的问题如下:当我运行rails console并运行Document.last.hash(或任何其他存储的文档)时,我返回一个数字字段,如:3130256425345013276
有人可以解释一下它是什么吗?它是一个哈希函数(如SHA-256 algorithm)来保护数据库中的加密吗?如果是,在所有哈希函数中,哪一个是ActiveRecord正在使用?
我必须将文件夹从本地移动到 s3。我想知道是否有办法做到这一点。
我的文件夹包含嵌套子文件夹,其中包含文件(通常为 .pdf 或 .doc 或 docx)。
s3fs我知道我可以使用(https://s3fs.readthedocs.io/en/latest/api.html )将单个文件从本地移动到 s3 :
S3FileSystem.put(filename, path, **kwargs) Stream data from local filename to file at path
Run Code Online (Sandbox Code Playgroud)
我的代码看起来像
def upload_data(filepath, file_name):
s3 = s3fs.S3FileSystem()
s3_path = f"name-of-my-bucket/{file_name}"
s3.put(filepath, s3_path)
Run Code Online (Sandbox Code Playgroud)
然而,这允许我上传单个文件。我想发送整个文件夹。
我可以递归地执行此操作,将每个文件一一添加,但是:
1)我认为如果我可以发送文件夹会更容易。
2)维护文件夹的结构会更困难。这意味着我的本地文件folders/subfolders/myfile.pdf将保存在 s3 中,而mypdf.pdf不是folders/subfolders/myfile.pdf
我想更新一个实体的firstName和。lastNameprofile
我希望用户能够更新它们两者或仅更新其中之一。
但是我不知道如何进行突变,使得参数 ( firstNameand lastName) 之一是可选的。
我的当前代码如果用户同时输入firstName和lastName
@Mutation(() => Boolean)
@UseMiddleware(isAuth)
async updateProfile(
@Ctx() {payload}: MyContext,
@Arg('firstName') firstName: string,
@Arg('lastName') lastName: string,
) {
try {
const profile = await Profile.findOne({where: { user: payload!.userId}})
if (profile) {
profile.firstName = firstName
profile.lastName = lastName
await profile.save();
return true
}
return false
} catch(err) {
return false
}
}
Run Code Online (Sandbox Code Playgroud)
如果我运行突变(不包括一个参数):
mutation{
updateProfile(firstName: "test")
}
Run Code Online (Sandbox Code Playgroud)
我收到错误:
"message": "String!" 类型的字段 "updateProfile" 参数 …
graphql ×2
python ×2
reactjs ×2
typegraphql ×2
activerecord ×1
amazon-s3 ×1
apollo ×1
express ×1
javascript ×1
netlify ×1
node.js ×1
npm ×1
prisma ×1
pst ×1
typescript ×1