我正在使用符合JSONAPI的 API,其中一种格式要求是所有数据(传入和传出)必须包装在data对象中.所以我的请求看起来像:
{
"data": {
"email": "email@example.com",
"password": "pass",
"type": "sessions"
}
}
Run Code Online (Sandbox Code Playgroud)
我的回答如下:
{
"data": {
"user_id": 13,
"expires": 7200,
"token": "gpKkNpSIzxrkYbQiYxc6us0yDeqRPNRb9Lo1YRMocyXnXbcwXlyedjPZi88yft3y"
}
}
Run Code Online (Sandbox Code Playgroud)
在我的控制器中,当发出新的会话请求时,我有:
$scope.signin = ->
session = new Session
email: $scope.user.email
password: $scope.user.password
session.$save()
console.log session
console.log session.token
if not session.token
alert 'Invalid Login'
else
$rootScope.session_token = session.token
$state.go 'app.dashboard'
Run Code Online (Sandbox Code Playgroud)
而我Session的工厂看起来像:
angular.module('webapp').factory 'Session', [
'$resource'
($resource) ->
$resource 'http://localhost:9500/v1/sessions',
id: '@id'
,
save:
method: 'POST'
transformRequest: (data) ->
result =
data: …Run Code Online (Sandbox Code Playgroud) 具体来说,如果我有一些json:
var myData = [ 'some info', 'some more info' ]
var myOtherData = { someInfo: 'some more info' }
Run Code Online (Sandbox Code Playgroud)
这是什么正确的CoffeeScript语法?
我找不到任何包来做这件事.我知道PHP有大量的PDF库(比如http://www.fpdf.org/),但是有什么东西可以用于Node吗?
如果是内部CMS,那么它不是公开的.我有我需要通过PayPal支付的发布商.我希望能够点击一个链接,它会直接进入PayPal页面,其中填写了电子邮件地址和特定值.
这可能吗?
'use strict';
module.exports = function(grunt) {
// Project Configuration
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
watch: {
jade: {
files: ['app/views/**'],
options: {
livereload: true,
},
},
js: {
files: ['!public/build.js', 'gruntfile.js', 'server.js', 'app/**/*.js', 'public/js/**', 'test/**/*.js'],
tasks: ['uglify', 'jshint'],
options: {
livereload: true,
},
},
html: {
files: ['public/views/**'],
options: {
livereload: true,
},
},
css: {
files: ['public/css/**'],
options: {
livereload: true
}
}
},
jshint: {
all: {
src: ['!public/build.js', 'gruntfile.js', 'server.js', 'app/**/*.js', 'public/js/**', 'test/**/*.js'],
options: {
jshintrc: true
}
} …Run Code Online (Sandbox Code Playgroud) 我的代码是:
const port: Number = process.env.PORT || 3000;
[ts]
Type 'string | 3000' is not assignable to type 'Number'.
Type 'string' is not assignable to type 'Number'.
Run Code Online (Sandbox Code Playgroud)
我试过
const port: Number = parseInt(process.env.PORT, 10) || 3000;
Run Code Online (Sandbox Code Playgroud)
但它给了我另一个错误:
Argument of type 'string | undefined' is not assignable to parameter of type 'string'.
Type 'undefined' is not assignable to type 'string'.
(property) NodeJS.Process.env: NodeJS.ProcessEnv
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?
我的中间件代码是:
exports.isAuthenticated = (req, res, context) => {
return new Promise((resolve, reject) => {
return passport.authenticate('jwt',{session: false}, (err, user, info) => {
if(err) {
res.status(500).send({message: 'Internal Server Error'})
return resolve(context.stop);
}
if(user) {
return resolve(context.continue);
} else {
res.status(401).send({message: 'Unauthorized'})
return resolve(context.stop)
}
})(req, res);
});
}
Run Code Online (Sandbox Code Playgroud)
我的结语代码是:
// Data plan REST API
const dataplan = epilogue.resource({
model: global.db.DataPlan,
endpoints: ['/api/dataplan', '/api/dataplan/:id']
});
dataplan.all.auth(middleware.isAuthenticated)
dataplan.use(require('./epilogue/dataplan.js'))
Run Code Online (Sandbox Code Playgroud)
而我的dataplan.js是:
module.exports = {
list: {
auth: async function (req, res, context) { …Run Code Online (Sandbox Code Playgroud) 我正在尝试构建一个小型LSTM,可以通过在现有的Python代码上进行训练来学习编写代码(即使是垃圾代码)。我将几千行代码连接在一个文件中,跨越数百个文件,每个文件都<eos>以“序列结束”结尾。
例如,我的训练文件如下所示:
setup(name='Keras',
...
],
packages=find_packages())
<eos>
import pyux
...
with open('api.json', 'w') as f:
json.dump(sign, f)
<eos>
Run Code Online (Sandbox Code Playgroud)
我正在使用以下单词创建令牌:
file = open(self.textfile, 'r')
filecontents = file.read()
file.close()
filecontents = filecontents.replace("\n\n", "\n")
filecontents = filecontents.replace('\n', ' \n ')
filecontents = filecontents.replace(' ', ' \t ')
text_in_words = [w for w in filecontents.split(' ') if w != '']
self._words = set(text_in_words)
STEP = 1
self._codelines = []
self._next_words = []
for i in range(0, len(text_in_words) - self.seq_length, STEP):
self._codelines.append(text_in_words[i: i …Run Code Online (Sandbox Code Playgroud) 我有一个清单:
code = ['<s>', 'are', 'defined', 'in', 'the', '"editable', 'parameters"', '\n', 'section.', '\n', 'A', 'larger', '`tsteps`', 'value', 'means', 'that', 'the', 'LSTM', 'will', 'need', 'more', 'memory', '\n', 'to', 'figure', 'out']
Run Code Online (Sandbox Code Playgroud)
我想转换为一种热编码。我试过:
to_categorical(code)
Run Code Online (Sandbox Code Playgroud)
我收到一个错误: ValueError: invalid literal for int() with base 10: '<s>'
我究竟做错了什么?
我有一个MelSpectrogram生成自:
eval_seq_specgram = torchaudio.transforms.MelSpectrogram(sample_rate=sample_rate, n_fft=256)(eval_audio_data).transpose(1, 2)
Run Code Online (Sandbox Code Playgroud)
所以eval_seq_specgram现在有一个sizeof torch.Size([1, 128, 499]),其中 499 是时间步数,128 是n_mels.
我正在尝试反转它,所以我正在尝试使用GriffinLim,但在此之前,我想我需要反转melscale,所以我有:
inverse_mel_pred = torchaudio.transforms.InverseMelScale(sample_rate=sample_rate, n_stft=256)(eval_seq_specgram)
Run Code Online (Sandbox Code Playgroud)
inverse_mel_pred拥有size的torch.Size([1, 256, 499])
然后我尝试使用GriffinLim:
pred_audio = torchaudio.transforms.GriffinLim(n_fft=256)(inverse_mel_pred)
Run Code Online (Sandbox Code Playgroud)
但我收到一个错误:
Traceback (most recent call last):
File "evaluate_spect.py", line 63, in <module>
main()
File "evaluate_spect.py", line 51, in main
pred_audio = torchaudio.transforms.GriffinLim(n_fft=256)(inverse_mel_pred)
File "/home/shamoon/.local/share/virtualenvs/speech-reconstruction-7HMT9fTW/lib/python3.8/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
result = self.forward(*input, **kwargs)
File "/home/shamoon/.local/share/virtualenvs/speech-reconstruction-7HMT9fTW/lib/python3.8/site-packages/torchaudio/transforms.py", line 169, …Run Code Online (Sandbox Code Playgroud) python ×3
coffeescript ×2
keras ×2
angularjs ×1
epilogue ×1
gruntjs ×1
json ×1
jwt ×1
lstm ×1
ms-word ×1
node.js ×1
npm ×1
passport-jwt ×1
passport.js ×1
paypal ×1
pdf ×1
pytorch ×1
tensorflow ×1
torchaudio ×1
typescript ×1