如何将本地副本上的所有文件还原为某个提交?
commit 4a155e5b3b4548f5f8139b5210b9bb477fa549de
Author: John Doe <Doe.John.10@gmail.com>
Date: Thu Jul 21 20:51:38 2011 -0500
Run Code Online (Sandbox Code Playgroud)
这是我想恢复的提交.任何帮助都将成为救星!
我正在尝试将表示组件与容器组件分开.我有一个SitesTable和一个SitesTableContainer.容器负责触发redux操作以基于当前用户获取适当的站点.问题是在最初呈现容器组件之后,异步获取当前用户.这意味着容器组件不知道它需要在其componentDidMount函数中重新执行代码,这将更新要发送给的数据SitesTable.我想我需要在其中一个props(用户)更改时重新呈现容器组件.我该怎么做?
class SitesTableContainer extends React.Component {
static get propTypes() {
return {
sites: React.PropTypes.object,
user: React.PropTypes.object,
isManager: React.PropTypes.boolean
}
}
componentDidMount() {
if (this.props.isManager) {
this.props.dispatch(actions.fetchAllSites())
} else {
const currentUserId = this.props.user.get('id')
this.props.dispatch(actions.fetchUsersSites(currentUserId))
}
}
render() {
return <SitesTable sites={this.props.sites}/>
}
}
function mapStateToProps(state) {
const user = userUtils.getCurrentUser(state)
return {
sites: state.get('sites'),
user,
isManager: userUtils.isManager(user)
}
}
export default connect(mapStateToProps)(SitesTableContainer);
Run Code Online (Sandbox Code Playgroud) 我正在开发一个带有laravel后端的ember.js应用程序.如果出现问题,我正试图用php返回http错误代码.我注意到,当发出PUT请求并返回400状态代码时,我的conf文件会被我的conf文件忽略,这会破坏我的前端.我不知道为什么PUT/400代码组合让nginx忽略我的conf.任何帮助将非常感激.
server {
listen *:80 ;
server_name userchamp.com;
access_log /var/log/nginx/embertest.com.access.log;
location / {
root /var/www/embertest/public;
try_files $uri $uri/ /index.php?$args ;
index index.html index.htm index.php;
}
location ~ \.php$ {
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain charset=UTF-8';
add_header 'Content-Length' 0;
return 204;
}
if ($request_method = 'POST') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, …Run Code Online (Sandbox Code Playgroud) 我知道你可以在mock上设置几个不同的对象.防爆.
when(someObject.getObject()).thenReturn(object1,object2,object3);
Run Code Online (Sandbox Code Playgroud)
你能以某种方式用间谍物体做同样的事情吗?我在没有运气的间谍上尝试了上述内容.我在文档中读到了doReturn()如下所示的间谍
doReturn("foo").when(spy).get(0);
Run Code Online (Sandbox Code Playgroud)
但deReturn()只接受一个参数.我想在间谍上按特定顺序返回不同的对象.这可能吗?
我有一个类似下面的类,我正在尝试测试它.我想测试myClass,而不是anotherClass
public class myClass{
//class code that needs several instances of `anotherClass`
public anotherClass getObject(){
return new anotherClass();
}
}
Run Code Online (Sandbox Code Playgroud) 在Jave中,您可以public static final在类中定义变量.PHP中是否有相同的功能?
我想做以下事情:
<?php
class MyClass{
public final static $finalVariable = "something";
}
MyClass::$finalVariable
Run Code Online (Sandbox Code Playgroud)
而且不必担心$finalVariable每次实例化时都要更改并没有新实例MyClass
如何让作曲家使用我安装的更新版本的php?我已下载并在所有本地服务器上使用php 5.4,但是当我下载作曲家时,它指向我的mac的默认#!/ usr/local/bin/env版本,即5.3.15.我尝试编辑composer可执行文件并更改使用的php,但它破坏了可执行文件.
我正在尝试使用composer来安装Laravel,并因此而下载了错误的版本.
这就是我的作曲家可执行文件的顶部看起来像但是下面有一堆奇怪的字符.
#!/usr/bin/env php
<?php
/*
* This file is part of Composer.
*
* (c) Nils Adermann <naderman@naderman.de>
* Jordi Boggiano <j.boggiano@seld.be>
*
* For the full copyright and license information, please view
* the license that is located at the bottom of this file.
*/
Phar::mapPhar('composer.phar');
define('COMPOSER_DEV_WARNING_TIME', 1366931166);
require 'phar://composer.phar/bin/composer';
Run Code Online (Sandbox Code Playgroud)
作为laravel项目的composer.json
{
"require": {
"laravel/framework": "4.0.*@dev"
},
"autoload": {
"classmap": [
"app/commands",
"app/controllers",
"app/models",
"app/database/migrations",
"app/database/seeds",
"app/tests/TestCase.php"
]
},
"scripts": {
"post-update-cmd": "php artisan optimize" …Run Code Online (Sandbox Code Playgroud) 我正在开发一个phonegap/cordova应用程序.有没有办法在浏览器视图中打开手机的原生导航应用程序?或者是否有从html5应用程序打开本机地图应用程序的最佳做法?或者它们都是特定于平台的?
我已经阅读了以下适用于某些Android版本的一些地方
<a href="geo:some address here" />Navigate to here</a>
Run Code Online (Sandbox Code Playgroud)
这适用于iOS
<a href="http://maps.apple.com/?daddr=San+Francisco,+CA&saddr=cupertino">Directions</a>
Run Code Online (Sandbox Code Playgroud)
我很惊讶Phonegap没有实现这样的东西.
您如何对相关数据的请求进行分页?例如,如果我的人员有一千个任务模型,如果我执行以下操作,那么在RESTful思考中,我会得到所有这些模型.
var tasks = person.get('tasks');
Run Code Online (Sandbox Code Playgroud)
这将是太多的数据.如何强制一些查询参数到幕后工作的请求?理想情况下,端点上有这样的东西附加到它的末尾.
?&offset=3&limit=3
这是一个小提琴来说明我想要完成的事情IndexController.我不知道使用ember-data执行分页请求的"ember方式"是什么.
我一直在阅读jsonapi的文档,我无法理解这是如何实用的.根据该文件的添加注释到文章的评论必须已经存在.
POST /articles/1/relationships/comments HTTP/1.1
Content-Type: application/vnd.api+json
Accept: application/vnd.api+json
{
"data": [
{ "type": "comments", "id": "123" }
]
}
Run Code Online (Sandbox Code Playgroud)
这只是一个糟糕的例子,或者规范是否真的希望您在发出上述请求以将其与总共2个请求相关联之前发出创建与实体无关的注释的请求?
您似乎更希望发出如下请求:
POST /comments HTTP/1.1
Content-Type: application/vnd.api+json
Accept: application/vnd.api+json
{
"data": {
"type": "comments",
"attributes": {
"body": "blah blah blah"
},
"relationships": {
"article": {
"data": { "type": "articles", "id": "45" }
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
或者更好的是:
POST /articles/45/relationships/comments HTTP/1.1
Content-Type: application/vnd.api+json
Accept: application/vnd.api+json
{
"data": [
{
"type": "comments",
"attributes": {
"body": "blah blah …Run Code Online (Sandbox Code Playgroud) 我有一个私人网络虚拟机,可以在我的Mac上进行开发.我希望我的Android设备能够与我的mac上的VM通信.目前我可以在我的Mac上访问我的Vagrantfile 10.10.10.10中定义的IP并且访问它很好但我无法通过我的手机在同一个wifi上访问它.
我需要做些什么才能使其在我的本地网络上可用并通过wifi看到我的手机?
这是我的Vagrantfile
Vagrant.configure("2") do |config|
config.vm.box = "precise64"
config.vm.box_url = "http://files.vagrantup.com/precise64.box"
config.vm.network :private_network, ip: "10.10.10.10"
config.ssh.forward_agent = true
config.vm.provider :virtualbox do |v|
v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
v.customize ["modifyvm", :id, "--memory", 1024]
v.customize ["modifyvm", :id, "--name", "PHPBoxWith54"]
end
nfs_setting = RUBY_PLATFORM =~ /darwin/ || RUBY_PLATFORM =~ /linux/
config.vm.synced_folder "./", "/var/www", id: "vagrant-root" , :nfs => nfs_setting
config.vm.provision :shell, :inline =>
"if [[ ! -f /apt-get-run ]]; then sudo apt-get update && sudo touch /apt-get-run; fi"
config.vm.provision :shell, :inline …Run Code Online (Sandbox Code Playgroud)