是否有任何方法可以从紧凑型控制器Laravel-5获取变量.
示例:我有以下代码:
$langs = Language::all();
return View::make('NAATIMockTest.Admin.Language.index',compact('langs'));
Run Code Online (Sandbox Code Playgroud)
我可以获得这个lang并将其传递给JavaScript吗?我已经使用过PHP-Vars-To-Js-Transformer.但是当我在控制器中使用JavaScript :: put两个函数时.它没用.有帮助吗?
这是我使用PHP-Vars-To-Js-Transformer的代码:
LanguageController:这是我的创建和编辑功能:
public function create()
{
$names = $this->initLang();
Javascript::put([
'langs' => $names
]);
return View::make('NAATIMockTest.Admin.Language.create',compact('names'));
}
public function edit($id)
{
//
$lang = Language::findOrFail($id);
$names = $this->initLang();
Javascript::put([
'langs' => $names
]);
return View::make('NAATIMockTest.Admin.Language.edit', compact('lang'));
// return View::make('NAATIMockTest.Admin.Language.edit');
}
Run Code Online (Sandbox Code Playgroud)
这是我的View创建:
@extends('AdLayout')
@section('content')
< script type="text/javascript">
var app = angular.module('myApp', []);
app.controller('langCtrl', function($scope) {
$scope.languages = langs;
});
</script>
<div class="container-fluid" ng-app="myApp" ng-controller="langCtrl">
<div class="row">
<div class="col-md-8 col-md-offset-2">
<div class="panel …
Run Code Online (Sandbox Code Playgroud) 我正在尝试从我在AWS中运行的Hadoop进程中读取一些日志.日志存储在S3文件夹中,并具有以下路径.
bucketname = name key = y/z/stderr.gz这里Y是集群ID,z是文件夹名称.这两者都充当AWS中的文件夹(对象).所以完整路径就像x/y/z/stderr.gz.
现在我想解压缩.gz文件并读取文件的内容.我不想将此文件下载到我的系统想要将内容保存在python变量中.
这是我到现在为止所尝试的.
bucket_name = "name"
key = "y/z/stderr.gz"
obj = s3.Object(bucket_name,key)
n = obj.get()['Body'].read()
Run Code Online (Sandbox Code Playgroud)
这给了我一种不可读的格式.我也试过了
n = obj.get()['Body'].read().decode('utf-8')
Run Code Online (Sandbox Code Playgroud)
这给出了错误utf8'编解码器无法解码位置1中的字节0x8b:无效的起始字节.
我也试过了
gzip = StringIO(obj)
gzipfile = gzip.GzipFile(fileobj=gzip)
content = gzipfile.read()
Run Code Online (Sandbox Code Playgroud)
这将返回错误IOError:不是gzip压缩文件
不确定如何解码此.gz文件.
编辑 - 找到解决方案.需要传递n并使用BytesIO
gzip = BytesIO(n)
Run Code Online (Sandbox Code Playgroud) 我使用此命令"go mod init database"在"database"文件夹中的"GOPATH"之外创建了一个库作为个人使用的模块,我不知道:
操作系统:Windows 7,Go:v1.11
我正在使用redux-form.我在州的输入字段中显示初始值.当我单击重置时,输入字段仍显示初始值.
如何重置输入字段?
这是我的代码:
const mapStateToProps = (state) => {
return {
initialValues: {
name:state.userInfo.data.name,
email:state.userInfo.data.email,
phone:state.userInfo.data.phone,
city:state.userInfo.data.city.name,
}
};
}
Run Code Online (Sandbox Code Playgroud)
这就是我在输入字段中调用初始值的方法.
const renderField = ({ input, label, type, meta: { touched, error } }) => (
<div>
<input className="form-control control_new" {...input} placeholder={label} type={type}/>
{touched && ((error && <span>{error}</span>))}
</div>
)
<Field type="text" {...name} name="name" component={renderField} label="Enter Your Name" />
Run Code Online (Sandbox Code Playgroud)
谢谢
当我运行./gradlew assembleRelease
构建失败时出现此错误:
Run Code Online (Sandbox Code Playgroud)Error:Execution failed for task ':app:bundleReleaseJsAndAssets. > A problem occurred starting process 'command 'node'
我在互联网上搜索并找到了一些关于它的主题,但我无法解决我的问题.
React-Native版本:0.54.0
编辑:
现在我./gradlew assembleRelease --info
从终端而不是Android Studio运行,我得到不同的错误.
结果如下:
> Task :app:processReleaseResources
Putting task artifact state for task ':app:processReleaseResources' into context took 0.007 secs.
file or directory '**/android/app/libs', not found
file or directory '**/node_modules/appcenter-crashes/android/libs', not found
file or directory '**/node_modules/appcenter-analytics/android/libs', not found
file or directory '**/node_modules/appcenter/android/libs', not found
file or directory '**/node_modules/react-native-interactable/lib/android/libs', not found
file or directory '**/node_modules/react-native-navigation/android/app/libs', not found
file or …
Run Code Online (Sandbox Code Playgroud) 我们已经实现了模式拼接,其中GraphQL服务器从两个远程服务器获取模式并将它们拼接在一起.当我们只使用Query和Mutations时,一切都运行正常,但现在我们有一个用例,我们甚至需要缝合订阅,远程模式已经通过它实现了auth.
我们很难搞清楚如何通过网关将connectionParams中收到的授权令牌从客户端传递到远程服务器.
这就是我们如何反省架构:
API网关代码:
const getLink = async(): Promise<ApolloLink> => {
const http = new HttpLink({uri: process.env.GRAPHQL_ENDPOINT, fetch:fetch})
const link = setContext((request, previousContext) => {
if (previousContext
&& previousContext.graphqlContext
&& previousContext.graphqlContext.request
&& previousContext.graphqlContext.request.headers
&& previousContext.graphqlContext.request.headers.authorization) {
const authorization = previousContext.graphqlContext.request.headers.authorization;
return {
headers: {
authorization
}
}
}
else {
return {};
}
}).concat(http);
const wsLink: any = new WebSocketLink(new SubscriptionClient(process.env.REMOTE_GRAPHQL_WS_ENDPOINT, {
reconnect: true,
// There is no way to update connectionParams dynamically without resetting connection
// connectionParams: () => …
Run Code Online (Sandbox Code Playgroud) apollo graphql apollo-server graphql-subscriptions graphql-tools
我在Angular(1.2)和Laravel(4.2)中有简单的crud应用程序.对于简单的crud操作,我使用高效的Eloquent方法:
$product->fill(Input::all());
Run Code Online (Sandbox Code Playgroud)
从请求有效负载中获取所有字段,但是当我需要使用空字段更新模型时会出现问题.
在编辑操作中,我有一个表单,其中填充了我的服务的$ resource get方法的响应:
adminModule.factory 'Product', ($resource) ->
$resource '/admin/products/:id', { id: '@id' }, {
query: { method: 'GET', isArray: false }
update: { method: 'PUT' }
}
Run Code Online (Sandbox Code Playgroud)
控制器:
adminModule.controller 'ProductFormEditController', ($scope, Product, $stateParams) ->
$scope.formData = Product.get({id: $stateParams.id})
Run Code Online (Sandbox Code Playgroud)
和HTML:
<input type="text" data-ng-model="formData.name" name="name" class="form-control" id="name"
placeholder="Nazwa" data-server-error required>
Run Code Online (Sandbox Code Playgroud)
如果我清除此字段值并提交$ scope.formData的值设置为undefined并且PUT请求中没有包含,那么Laravel模型填充方法无论如何都看不到该字段并且不设置为空验证的值,但采用模型的原始值.
问题是:如何从ngModel而不是undefined发送空字符串?
ps如果输入类型是Textarea,$ resource发送空""字符串: - /,所以我很困惑......
我是 VueJs 的新手,我正在处理一个表单,我只想Save
在模型发生更改时启用该按钮。
我最初的想法是compute
将初始模型与当前模型进行比较的脏函数。
注意:此代码未经测试,此处仅作为示例。
var app = new Vue({
el: '#app',
data: {a:0, b:'', c:{c1:null, c2:0, c3:'test'}},
initialData: null,
mounted():{ initialData = JSON.parse(JSON.stringify(data));},
computed: {
isDirty: function () {
return JSON.stringify(data) === JSON.stringify(initialData)
}
}
});
Run Code Online (Sandbox Code Playgroud)
有没有更好的方法来做到这一点,或者您可以对上述代码提出任何改进建议吗?
我尝试使用 boto3 将 XML 文件上传到 S3。按照亚马逊的建议,我想发送数据的 Base64 编码 MD5-128 位摘要(Content-MD5)。
https://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectPUT.html https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/s3.html#S3.Object 。放
我的代码:
with open(file, 'rb') as tempfile:
body = tempfile.read()
tempfile.close()
hash_object = hashlib.md5(body)
base64_md5 = base64.encodebytes(hash_object.digest())
response = s3.Object(self.bucket, self.key + file).put(
Body=body.decode(self.encoding),
ACL='private',
Metadata=metadata,
ContentType=self.content_type,
ContentEncoding=self.encoding,
ContentMD5=str(base64_md5)
)
Run Code Online (Sandbox Code Playgroud)
当我尝试这个时 str(base64_md5) 创建一个像 'b'ZpL06Osuws3qFQJ8ktdBOw==\n'' 的字符串
在这种情况下,我收到此错误消息:
An error occurred (InvalidDigest) when calling the PutObject operation: The Content-MD5 you specified was invalid.
出于测试目的,我只复制了前面没有 'b' 的值:'ZpL06Osuws3qFQJ8ktdBOw==\n'
然后我收到此错误消息:
botocore.exceptions.HTTPClientError: An HTTP Client raised and unhandled exception: Invalid header value b'hvUe19qHj7rMbwOWVPEv6Q==\n'
任何人都可以帮助我如何将上传文件保存到 …
我正在尝试解析包含汽车属性的网站(154种属性).我有一个巨大的列表(名称是 liste_test),包含280.000二手车公告网址.
def araba_cekici(liste_test,headers,engine):
for link in liste_test:
try:
page = requests.get(link, headers=headers)
.....
.....
Run Code Online (Sandbox Code Playgroud)
当我开始这样的代码时:
araba_cekici(liste_test,headers,engine)
Run Code Online (Sandbox Code Playgroud)
它起作用并获得结果.但大约在1小时内,我只能获得1500个URL的属性.它非常慢,我必须使用多处理.
我在这里找到了一个带有多处理的结果.然后我申请了我的代码,但不幸的是,它没有用.
import numpy as np
import multiprocessing as multi
def chunks(n, page_list):
"""Splits the list into n chunks"""
return np.array_split(page_list,n)
cpus = multi.cpu_count()
workers = []
page_bins = chunks(cpus, liste_test)
for cpu in range(cpus):
sys.stdout.write("CPU " + str(cpu) + "\n")
# Process that will send corresponding list of pages
# to the function perform_extraction
worker = …
Run Code Online (Sandbox Code Playgroud) python ×3
amazon-s3 ×2
boto3 ×2
javascript ×2
laravel ×2
android ×1
angularjs ×1
apollo ×1
go ×1
go-modules ×1
gradle ×1
graphql ×1
laravel-5 ×1
react-native ×1
reactjs ×1
redux ×1
redux-form ×1
vuejs2 ×1