我的网站中有一个子域名,例如:
http://example.ca
http://blog.example.ca
Run Code Online (Sandbox Code Playgroud)
博客只有拥有网址的人才能访问,也就是说,它不是公共或常识.我有一堆与此域名相关的路由,要求您登录.
我已经说过nav.blade.php,如果用户登录,则应该有一个下拉列表,如果没有,则不应该有下拉列表.
这一切都有效,http://blog.example.ca但是当我去的时候,http://example.ca我不再被认证了.
是否有任何方法可以让我在所有子域中进行身份验证?不只是那些需要我进行身份验证的控制器操作的人?
我搜索过这个问题,似乎没有现成的答案.考虑以下:
[
{ 'August 17th 2016': [75] }, // 75 is the length of the array which contains up to 75 objects ...
{ 'August 1st 2016': [5] },
{ 'August 28th 2016': [5] },
...
]
Run Code Online (Sandbox Code Playgroud)
按日期排序此数组中对象的最佳方法是什么,并保持其键的"英语"表示?
注意:该键用作图表标签.
我看到的每个地方都array.sort被使用,但那是对象的关键所在created_at.
结果应该是:
[
{ 'August 1st 2016': [5] },
{ 'August 17th 2016': [75] }
{ 'August 28th 2016': [5] },
...
]
Run Code Online (Sandbox Code Playgroud)
我不知道该怎么办,所以我没有什么可展示的.
React 16.8(使用类而不是钩子)
if在一个称为的函数中考虑以下语句onClick
if (this.state.opponentIsDead) {
this.setState({
disableAttack: 'disabled',
}, () => {
this.timer = setTimeout(() => {
this.props.postFightData({
train_exp: 100,
drop_chance: this.state.monster.drop_chance,
gold_rush_chance: this.state.monster.gold_rush_chance,
gold_drop: this.state.monster.gold_drop,
});
}, 1000);
});
}
Run Code Online (Sandbox Code Playgroud)
我想做的是,如果您赢得了比赛,则在发布战斗数据之前请稍等片刻,超时是可行的。但是如您所见,我正在更新状态以禁用该按钮。
我当时想做的就是将超时转移到componentDidUpdate方法上,那样组件将重新呈现并且按钮将被禁用,无论我怎么觉得那是错误的方法。
我知道您可以将其包装setState在异步函数中,但是我也想知道这是否是最好的方法。
目标是禁用按钮,然后等待1秒钟并发布数据。最好的方法是什么?
对于可能不知道的人,setState将调用来更新状态,但是无需重新渲染它,而是调用回调函数,因此在计时器递减计数时不会禁用该按钮。
它会在计时器之后(而不是之前)被禁用,而在我想要的位置之前而不是之后。
我有以下脚本,我正在尝试在 bash 中测试它,使用curl 做几件事,一是创建一个新的存储库,第二个 - 尚未实现 - 是从 json 中获取 git_url返回,我不确定我的parse_json函数是否允许我这样做,然后最终将示例提交消息推送到该存储库。
脚本如下:
#!/usr/bin/env bash
set -eux
# Json Function: parse_json 'json string' key
function parse_json()
{
echo $1 | sed -e 's/[{}]/''/g' | awk -F=':' -v RS=',' "\$1~/\"$2\"/ {print}" | sed -e "s/\"$2\"://" | tr -d "\n\t" | sed -e 's/\\"/"/g' | sed -e 's/\\\\/\\/g' | sed -e 's/^[ \t]*//g' | sed -e 's/^"//' -e 's/"$//'
}
git_create_repo() {
read -e -p "Please enter your API Key: " …Run Code Online (Sandbox Code Playgroud) 我的 phpunit.xml
<phpunit
bootstrap="bootstrap.php"
backupGlobals="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
>
<testsuites>
<testsuite>
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>
<logging>
<log type="coverage-html" target="coverage" lowUpperBound="75" highUpperBound="100" />
</logging>
</phpunit>
Run Code Online (Sandbox Code Playgroud)
我的bootstrap.php:
<?php
/** ---------------------------------------------------- **/
// Require the vendors autoload file.
/** ---------------------------------------------------- **/
require_once 'vendor/autoload.php';
/** ---------------------------------------------------- **/
// We neeed WordPress Bootstrap files for its test.
/** ---------------------------------------------------- **/
define('WP_TEST_DIR', parse_ini_file('test-config.ini')['test-location']);
// Include the bootstrap file.
require_once WP_TEST_DIR . 'includes/bootstrap.php';
// Include the Functions file
require_once WP_TEST_DIR . 'includes/functions.php';
Run Code Online (Sandbox Code Playgroud)
当我在取消注释日志记录部分的情况下运行它时,我得到:
vagrant@vagrant-ubuntu-trusty-64:/vagrant/Freya/Routes$ …Run Code Online (Sandbox Code Playgroud) 我很好奇,因为我得到"未定义不是函数"错误.考虑以下课程:
var FlareError = require('../flare_error.js');
class Currency {
constructor() {
this._currencyStore = [];
}
static store(currency) {
for (var key in currency) {
if (currency.hasOwnProperty(key) && currency[key] !== "") {
if (Object.keys(JSON.parse(currency[key])).length > 0) {
var currencyObject = JSON.parse(currency[key]);
this.currencyValidator(currencyObject);
currencyObject["current_amount"] = 0;
this._currencyStore.push(currencyObject);
}
}
}
}
currencyValidator(currencyJson) {
if (!currencyJson.hasOwnProperty('name')) {
FlareError.error('Currency must have a name attribute in the json.');
}
if (!currencyJson.hasOwnProperty('description')) {
FlareError.error('Currency must have a description attribute in the json.');
}
if (!currencyJson.hasOwnProperty('icon')) {
FlareError.error('Currency …Run Code Online (Sandbox Code Playgroud) 有没有一种简单的方法可以从 Postgres 表中选择所有重复项?不需要连接或任何花哨的东西。我在堆栈上找到的所有内容都与涉及表上多个字段的连接和重复有关。
我只需要 select * from table where table contains duplicate entries
有任何想法吗?
scotchbox=# \d+ eve_online_market_groups
Table "public.eve_online_market_groups"
Column | Type | Modifiers | Storage | Stats target | Description
------------+--------------------------------+-----------------------------------------------------------------------+----------+--------------+-------------
id | integer | not null default nextval('eve_online_market_groups_id_seq'::regclass) | plain | |
name | character varying(255) | not null | extended | |
item_id | integer | not null | plain | |
slug | character varying(255) | not null | extended | |
created_at | …Run Code Online (Sandbox Code Playgroud) 因此,关于这个同一个网站的业务有很多问题,但当涉及到Laravel Websockets时我找不到任何答案。他们的文档中没有任何关于此的内容。
所以我想我应该在这里问一下,看看你们有什么想法。
考虑以下配置:
import Echo from 'laravel-echo'
window.Pusher = require('pusher-js');
window.Echo = new Echo({
broadcaster: 'pusher',
key: process.env.MIX_PUSHER_APP_KEY,
wsHost: window.location.hostname,
wsPort: 6001,
wssPort: 6001,
disabledStats: true,
encrypted: false,
enabledTransports: ['ws', 'wss'],
namespace: 'App',
auth: {
headers: {
'X-CSRF-TOKEN': token.content
}
}
});
Run Code Online (Sandbox Code Playgroud)
根据他们的文档,他们使用了 Pusher 库 - 但没有迹象表明它实际上到达了 Pusher 网站。我不需要任何推送者凭据,因为这些都是伪造的。
问题很简单:
与http://support.pusher.com/上的跨站点资源关联的 cookie设置时没有该
SameSite属性。Chrome 的未来版本将仅在设置了SameSite=None和 的情况下通过跨站点请求传递 cookieSecure。您可以在开发者工具中的“应用程序”>“存储”>“Cookies”下查看 Cookie,并在https://www.chromestatus.com/feature/5088147346030592和https://www.chromestatus.com/feature/5633521622188032上查看更多详细信息。
这都是堆栈溢出。
我disableSats是的,虽然 websockets 仍然运行并且工作正常,但最终 chrome 会说“不”。所以我不知道这是否是推送器问题、laravel …
我正在使用Laravel Excel创建包含多个工作表的 Excel 文档。我一直在遵循他们的示例,了解他们是如何做到这一点的,但是当我去下载文件时,它是:
Excel 无法打开文件“kingdoms (1).xlsx”,因为文件格式或文件扩展名无效。验证文件未损坏并且文件扩展名与文件格式匹配。
我不确定为什么。
所以我是这样做的:
public function export() {
return Excel::download(new KingdomsExport, 'kingdoms.xlsx', \Maatwebsite\Excel\Excel::XLSX);
}
Run Code Online (Sandbox Code Playgroud)
class KingdomsExport implements WithMultipleSheets {
use Exportable;
/**
* @return array
*/
public function sheets(): array {
$sheets = [];
$sheets[] = new BuildingsSheet;
// .. other commented out sheets.
return $sheets;
}
}
Run Code Online (Sandbox Code Playgroud)
class BuildingsSheet implements FromView, WithTitle, ShouldAutoSize {
/**
* @return View
*/
public function view(): View {
return view('admin.exports.kingdoms.sheets.buildings', [
'buildings' => …Run Code Online (Sandbox Code Playgroud) pub struct Character {
name: String,
hp: i32,
level: i32,
xp: i32,
xp_needed: i32,
gold: i32
}
impl Character {
pub fn new(name: String) -> Character {
let mut rng = thread_rng();
let hp: i32 = rng.gen_range(12, 75);
let gold: i32 = rng.gen_range(10, 50);
Character { name: name, hp: hp, level: 1, xp: 0, gold: gold, xp_needed: 100 }
}
pub fn get_name(&self) -> String {
self.name
}
// ...
}
Run Code Online (Sandbox Code Playgroud)
我到底是怎么违反规则的呢?
在高层次上,这对Rust来说是违规的.你不能转让借来的东西的所有权,因为你不拥有它.
嗯,不是吗?我有其他功能,如:
pub fn get_hp(&self) -> i32 { …Run Code Online (Sandbox Code Playgroud) javascript ×3
laravel ×2
php ×2
arrays ×1
bash ×1
class ×1
curl ×1
date-parsing ×1
duplicates ×1
ecmascript-6 ×1
excel ×1
git ×1
github ×1
github-api ×1
laravel-5 ×1
laravel-5.2 ×1
laravel-8 ×1
phpunit ×1
postgresql ×1
pusher ×1
pusher-js ×1
reactjs ×1
rust ×1
session ×1
sorting ×1
sql ×1
subdomain ×1
websocket ×1