我有以下html页面,我正在尝试展示一个类,用于演示本地存储的mp3音频可视化器:
<!doctype html>
<html>
<head>
<header name = "Access-Control-Allow-Origin" value = "*" />
<style type = "text/css">
div#mp3_player{ width: 500px; height: 60px; background: #000; padding: 5px; margin: 50px auto;}
div#mp3_player > div > audio{ width: 500px; background: #000; float: left; }
div#mp3_player > canvas { width: 500px; height: 30px; background: #002D3C; float: left;}
</style>
<script>
//create new instance of audio
var audio = new Audio();
audio.src = 'C:/Users/Adam/Desktop/1901.m4a';
audio.controls = true;
audio.loop = true;
audio.autoplay = true;
var canvas, ctx, …
Run Code Online (Sandbox Code Playgroud) 我正在使用SQL Server Management Studio并具有以下架构:
CREATE TABLE tmp(
id int NOT NULL IDENTITY(1,1)PRIMARY KEY,
toleranceRegion DECIMAL
)
Run Code Online (Sandbox Code Playgroud)
然后我执行以下插入:
INSERT INTO tmp VALUES(3.2);
INSERT INTO tmp VALUES(5.678);
INSERT INTO tmp VALUES(1.95);
Run Code Online (Sandbox Code Playgroud)
预期产量:
id toleranceRegion
-- ---------------
1 3.2
2 5.678
3 1.95
Run Code Online (Sandbox Code Playgroud)
实际产量:
id toleranceRegion
-- ---------------
1 3
2 6
3 2
Run Code Online (Sandbox Code Playgroud)
为什么插入的toleranceRegion值被舍入为最接近的整数?
我在 Jest 中有以下组件的测试套件。我已经成功地为其他几个遵循类似结构的组件编写了单元测试:
import { createLocalVue, mount } from '@vue/test-utils'
import Vuex from 'vuex'
import storeMock from '@mocks/store'
import RequestProposalsContainer from '@/components/RequestProposals/RequestProposalsContainer'
describe('ProviderComparison component', () => {
let localVue, store, wrapper, storeSetup
beforeEach(() => {
localVue = createLocalVue()
localVue.use(Vuex)
storeSetup = storeMock()
store = new Vuex.Store(storeSetup)
/* wrapper is undefined and I'm not sure why */
wrapper = mount(RequestProposalsContainer, {
localVue,
store
})
})
it('renders correct structure', () => {
/* undefined */
console.log('wrapper: ', wrapper)
})
})
Run Code Online (Sandbox Code Playgroud)
通过检查,正在安装的组件、store 和 …
我正在尝试通过 Sendgrid 向已注册第一个的用户发送电子邮件验证。按照此处找到的 v3_mail 示例,我创建了以下实现:
const querystring = require('querystring');
const helper = require('sendgrid').mail;
const https = require('https');
const url = "http://<mywebsite.com>/users/reset/passwordLoggedOut?";
let sg = require('sendgrid')(process.env.SENDGRID_API_KEY);
const emails = {};
function sendMail(mail){
const request = sg.emptyRequest({
method: 'POST',
path: '/v3/mail/send',
body: mail.toJSON(),
});
sg.API(request, function(error, response) {
console.log(response.statusCode);
console.log(response.body);
console.log(response.headers);
console.log(error);
});
}
emails.sendActivationEmail = function(user){
let qso = {username: user.username, activationCode: user.activationCode};
let qs = querystring.stringify(qso);
let from = new helper.Email('Thomas.Talhelm@chicagobooth.edu');
let to = new helper.Email(user.username);
let subject …
Run Code Online (Sandbox Code Playgroud) 我正在为 VueJS 组件编写单元测试,并查阅了Vue Test Utils Common Tips的“应用全局插件和 Mixins”部分。我有一个依赖于 Vuex 存储的组件,因此出于我的目的,我将转置该部分下的示例是有意义的。
这是该组件的特定 .spec.js 文件的代码:
import { createLocalVue, mount } from '@vue/test-utils'
import AppFooter from '@/components/AppFooter/AppFooter'
import store from '@/store'
describe('AppFooter component', () => {
const localVue = createLocalVue()
localVue.use(store)
it('AppFooter should have header slot', () => {
const AppFooterComponent = mount(AppFooter, {
localVue
})
/* TODO: Replace with a more appropriate assertion */
expect(true).toEqual(true)
})
})
Run Code Online (Sandbox Code Playgroud)
这非常忠实于上面链接中提供的示例。但是,当我运行测试套件时收到的错误如下:
我应该以不同的方式安装 Vue 商店吗?
我正在尝试使用以下调用的命令行安装Composer for Windows:
php -r"readfile(https://getcomposer.org/installer);" | PHP
但是,我收到此错误消息:
警告:readfile():无法找到包装器"https" - 您是否忘记在配置PHP时启用它?在第1行的命令行代码中
调用堆栈:0.0010 224336 1. {main}()命令行代码:0 0.0010 224488 2. readfile()命令行代码:1
警告:readfile(https://getcomposer.org/installer):无法打开流:第1行的命令行代码中的无效参数
调用堆栈:0.0010 224336 1. {main}()命令行代码:0 0.0010 224488 2. readfile()命令行代码:1
我已经取消注释了php5.5.12目录中的"; extension = php_openssl.dll"行,重新启动了浏览器,并尝试了其他变种.当我运行命令而只删除https中的's'时,我得到:
机器上的某些设置使Composer无法正常工作.确保您已修复下面列出的问题并再次运行此脚本:
缺少openssl扩展,这意味着无法进行安全的HTTPS传输.如果可能,您应该启用它或使用--with-openssl重新编译php
我已经尝试在各个地方包含这个--with-openssl标志,但它似乎没有做到这一点.
假设我有一个类似于以下示例的元组列表:
[(5, "a"), (1, "c"), (7, "d")]
Run Code Online (Sandbox Code Playgroud)
在Elm中,我该如何按照其第一元素的升序对列表进行排序,以便获得以下结果?
[(1, "c"), (5, "a"), (7, "d")]
Run Code Online (Sandbox Code Playgroud)
使用Elm List文档,看来sortBy
和sortWith
函数在这种情况下将很有用。我的实现尝试如下:
maxTuples : Tuple(a, b) -> Tuple(a, b) -> Tuple(a, b)
maxTuples t1 t2 =
case compare t1 t2 of
((Tuple.first t1) >= (Tuple.first t2)) -> GT
_ -> LT
sortByFirst : List (Tuple (a, b)) -> List (Tuple (a, b))
sortByFirst lst =
List.sortWith maxTuples lst
Run Code Online (Sandbox Code Playgroud)
但是,我遇到了以下性质的编译器错误:
I ran into something unexpected when parsing your code!
99| ((Tuple.first …
Run Code Online (Sandbox Code Playgroud) 在Sublime中,我试图像这样在Octave文件中对行向量进行转置:
y = [4, 5, 6];
y_transpose = y';
Run Code Online (Sandbox Code Playgroud)
但是,每当我尝试在Octave中运行此命令时,就好像转置运算符(')的引入是字符串的开头,并且忽略了以下代码行。我该如何补救?
我正在尝试从同一个表中加入几个不同的值.我试图从不同的时间范围返回查询中的打印率(在月/日/年/周等打印了多少),当我执行下面的查询时,我收到1064错误.可以解释的是什么?
SELECT t1.station_name, t1.yearpages, t2.monthpages
FROM (
SELECT station_name, SUM(print_pages) yearpages
FROM `file_prints`
WHERE year(print_date) = 2014;
) t1
INNER JOIN (
SELECT station_name, sum(print_pages) monthpages
FROM `file_prints`
WHERE month(print_date) = 2;
) ON t1.station_name = t2.station_name;
Run Code Online (Sandbox Code Playgroud)
然后,如果我要添加多个连接,查询是否会像这样?
SELECT t1.station_name, t1.station_name as db_name, t1.yearpages, t2.monthpages, t3.daypages, t4.weekpages
FROM (
SELECT station_name, sum(print_pages) yearpages
FROM `file_prints`
WHERE year(print_date) = $year;
GROUP BY station_name
) t1
INNER JOIN (
SELECT station_name, sum(print_pages) monthpages
FROM `file_prints`
WHERE month(print_date) = $month;
GROUP BY station_name …
Run Code Online (Sandbox Code Playgroud) 在我的小型 Vue 应用程序中,我试图从另一个方法 (buttonClick) 中使用不同的参数调用相同的方法 (emptyDivision)。我为该方法的第一次调用设置了 5 秒超时,但是当我通过执行 buttonClick 触发这两个函数时,无法识别此延迟。
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.1.10/vue.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vuex/2.1.1/vuex.min.js"></script>
</head>
<body>
<div id="app">
<button v-on:click="buttonClick">Simulate Placement</button>
<h1>Random Division 1</h1>
<p>{{A.One}}</p>
<p>{{A.Two}}</p>
<h1>Random Division 2</h1>
<p>{{B.One}}</P>
<p>{{B.Two}}</p>
</div>
<script type="text/javascript">
new Vue({
'el': '#app',
'data': {
'A': {'One': "", 'Two': "" },
'B': {'One': "", 'Two': "" },
'Division1': ["Steelers", "Ravens"],
'Division2': ["Broncos", "Raiders"],
},
'methods': {
'emptyDivision': function(division){
this.A[division] = this.popTeam(division)[0];
this.B[division] = this.popTeam(division)[0];
},
'popTeam': function(division) {
if (division === "One"){
return …
Run Code Online (Sandbox Code Playgroud) javascript ×3
vue.js ×3
vuejs2 ×3
unit-testing ×2
comparison ×1
composer-php ×1
cors ×1
elm ×1
email ×1
html ×1
html5-audio ×1
inner-join ×1
jestjs ×1
list ×1
mysql ×1
node.js ×1
octave ×1
php ×1
rounding ×1
sendgrid ×1
settimeout ×1
sorting ×1
sql ×1
sql-server ×1
ssms ×1
sublimetext2 ×1
vuex ×1
windows ×1