Visual Studio Code SFTP to multiple servers - visual-studio-code

In PhpStorm, there is a way to configure multiple SFTP endpoints and chose which server you want to upload to. I'm looking for this functionality in Visual Studio Code. I have installed SFTP VS Code extension and I am able to configure it for one endpoint. What if I want to upload a file to multiple servers? How can I configure that? Or is there another extension that does that?

Hi you can add multiple ftp servers to config. Just The context must not be same.
[
{
"name": "server1",
"context": "/project/build",
"host": "host",
"username": "username",
"password": "password",
"remotePath": "/remote/project/build"
},
{
"name": "server2",
"context": "/project/src",
"host": "host",
"username": "username",
"password": "password",
"remotePath": "/remote/project/src"
}
]

You can use "profiles" with the SFTP extension now. https://github.com/liximomo/vscode-sftp#profiles
{
"name": "My Project",
"protocol": "sftp",
"remotePath": "/",
"port": 22,
"profiles": {
"dev": {
"host": "server1.example.com",
"username": "username",
"password": "password"
},
"prod": {
"host": "server2.example.com",
"username": "other-username",
"password": "other-password"
}
},
"defaultProfile": "dev"
}

You can set up remotePath for each of your profiles like that: (I saw that such question was asked by #Charlie Parker in the second answer to that question)
{
"name": "ExampleName",
"protocol": "sftp",
"port": 22,
"profiles": {
"profile1": {
"host": "connection1",
"username": "user1",
"remotePath":"/path1"
},
"profile2": {
"host": "connection2",
"username": "user2",
"remotePath":"/path2"
},
"profile3": {
"host": "connection3",
"username": "user3",
"remotePath":"/path3"
},
}
}
And with Ctrl+Sifht+P > Set Profile you can change your profile.

There are lot of add-ins that will work for your requirements. Below are a list of few
https://marketplace.visualstudio.com/items?itemName=mkloubert.vs-deploy
https://marketplace.visualstudio.com/items?itemName=mkloubert.vscode-deploy-reloaded
https://marketplace.visualstudio.com/items?itemName=humy2833.ftp-simple

Try this:
[
{
"name": "project 1",
"context": "/project/project1",
"host": "",
"username": "",
"password": "",
"protocol": "ftp",
"post": 21,
"remotePath": "/",
"uploadOnSave": true
},
{
"name": "project 2",
"context": "/project/project2",
"host": "",
"username": "",
"password": "",
"protocol": "ftp",
"post": 21,
"remotePath": "/",
"uploadOnSave": true
}
]

[
{
"name": "server1",
"context": "/project/build",
"host": "host",
"username": "username",
"password": "password",
"remotePath": "/remote/project/build"
},
{
"name": "server2",
"context": "/project/src",
"host": "host",
"username": "username",
"password": "password",
"remotePath": "/remote/project/src"
}
]

Related

Loopback 3: Multiple HasOne relation on one model

So, I opened an issue here, coz in my opinion it should work as I think... but might be wrong so looking for another way
So, pretty much I have two models, Wedding and Person. The Wedding one has these relations set:
"people": {
"type": "hasMany",
"model": "person",
"foreignKey": "",
"options": {
"nestRemoting": true
}
},
"partner1": {
"type": "hasOne",
"model": "person",
"foreignKey": ""
},
"partner2": {
"type": "hasOne",
"model": "person",
"foreignKey": ""
}
And one of my wedding documents looks like this (I am using mongoDB if you cannot tell):
{
"_id": "5de78c76f89d1a8ad4091ca5",
"date": "2019-12-04T10:37:42.000Z",
"userId": "5de78c76f89d1a8ad4091ca4",
"created": "2019-12-04T10:37:42.720Z",
"partner1Id": "5de78c77f89d1a8ad4091ca6",
"partner2Id": "5de78c77f89d1a8ad4091ca7"
}
So, when I set include filter and do:
{ "include": ["partner1", "partner2"]}
in my loopback API explorer on
http://localhost:3000/api/weddings/5de78c76f89d1a8ad4091ca5
I get:
{
"date": "2019-12-04T10:37:42.000Z",
"id": "5de78c76f89d1a8ad4091ca5",
"userId": "5de78c76f89d1a8ad4091ca4",
"created": "2019-12-04T10:37:42.720Z",
"partner1Id": "5de78c77f89d1a8ad4091ca6",
"partner2Id": "5de78c77f89d1a8ad4091ca7",
"partner1": {
"id": "5de78c77f89d1a8ad4091ca7",
"fullName": "Jessica Alba",
"spouse": "spouse2",
"contacts": [],
"verified": false,
"created": "2019-12-04T10:37:43.292Z",
"updated": "2019-12-04T10:37:43.292Z",
"userId": "5de78c76f89d1a8ad4091ca4",
"weddingId": "5de78c76f89d1a8ad4091ca5"
},
"partner2": {
"id": "5de78c77f89d1a8ad4091ca7",
"fullName": "Jessica Alba",
"spouse": "spouse2",
"contacts": [],
"verified": false,
"created": "2019-12-04T10:37:43.292Z",
"updated": "2019-12-04T10:37:43.292Z",
"userId": "5de78c76f89d1a8ad4091ca4",
"weddingId": "5de78c76f89d1a8ad4091ca5"
}
}
But, I am expecting this:
{
"date": "2019-12-04T10:37:42.000Z",
"id": "5de78c76f89d1a8ad4091ca5",
"userId": "5de78c76f89d1a8ad4091ca4",
"created": "2019-12-04T10:37:42.720Z",
"partner1Id": "5de78c77f89d1a8ad4091ca6",
"partner2Id": "5de78c77f89d1a8ad4091ca7",
"partner1": {
"id": "5de78c77f89d1a8ad4091ca6",
"fullName": "Michael Knight",
"spouse": "spouse1",
"contacts": [],
"verified": false,
"created": "2019-12-04T10:37:43.292Z",
"updated": "2019-12-04T10:37:43.292Z",
"userId": "5de78c76f89d1a8ad4091ca4",
"weddingId": "5de78c76f89d1a8ad4091ca5"
},
"partner2": {
"id": "5de78c77f89d1a8ad4091ca7",
"fullName": "Jessica Alba",
"spouse": "spouse2",
"contacts": [],
"verified": false,
"created": "2019-12-04T10:37:43.292Z",
"updated": "2019-12-04T10:37:43.292Z",
"userId": "5de78c76f89d1a8ad4091ca4",
"weddingId": "5de78c76f89d1a8ad4091ca5"
}
}
Any ideas as of why? why do I get the same two records for partner1 and partner2?
Instead of using "hasOne", use "belongsTo".

Kafka mirrormaker jmxtrans configuration file format

I use jmxtrans to monitor kafka mirrormaker but my json format seems to have problems, the data can not be displayed
how to write this json file, thank
{
"servers": [{
"port": "5448",
"host": "10.10.21.10",
"queries": [{
"obj": "kafka.consumer:type=ConsumerTopicMetrics,name=BytesInPerSec,topic=mirror_group-*",
"attr": ["Count", "MeanRate", "OneMinuteRate"],
"resultAlias": "mirror_group-*",
"outputWriters": [{
"#class": "com.googlecode.jmxtrans.model.output.InfluxDbWriterFactory",
"url": "http://10.10.21.10:8086",
"username": "root",
"password": "123",
"database": "jmxDB",
"tags": {
"application": "BytesInPerSec"
}
}]
},
{
"obj": "kafka.consumer:type=ConsumerTopicMetrics,name=MessagesInPerSec,topic=mirror_group-*",
"attr": ["Count", "MeanRate", "OneMinuteRate"],
"resultAlias": "mirror_group-*",
"outputWriters": [{
"#class": "com.googlecode.jmxtrans.model.output.InfluxDbWriterFactory",
"url": "http://10.10.21.10:8086",
"username": "root",
"password": "123",
"database": "jmxDB",
"tags": {
"application": "MessagesInPerSec"
}
}]
},
{
"obj": "kafka.producer:type=ProducerRequestMetrics,name=ProducerRequestRateAndTimeMs,topic=mirror_group-*",
"attr": ["Count", "Max", "Min", "50thPercentile", "75thPercentile", "95thPercentile"],
"resultAlias": "mirror_group-*",
"outputWriters": [{
"#class": "com.googlecode.jmxtrans.model.output.InfluxDbWriterFactory",
"url": "http://10.10.21.10:8086",
"username": "root",
"password": "123",
"database": "jmxDB",
"tags": {
"application": "ProducerRequestRateAndTimeMs"
}
}]
},
{
"obj": "kafka.producer:type=ProducerRequestMetrics,name=ProducerRequestSize,topic=mirror_group-*",
"attr": ["Count", "Max", "Min", "50thPercentile", "75thPercentile", "95thPercentile"],
"resultAlias": "mirror_group-*",
"outputWriters": [{
"#class": "com.googlecode.jmxtrans.model.output.InfluxDbWriterFactory",
"url": "http://10.10.21.10:8086",
"username": "root",
"password": "123",
"database": "jmxDB",
"tags": {
"application": "ProducerRequestSize"
}
}]
}
]
}]
}
I can't get the data from grafana

How to display JSON hash content using rails

Hello I'm new to ruby rails and I'm trying to hardcode to display into my browser the "searched_count" from the phrase "java" from my json hash that I got using an url, which is the following
{
"results": [
{
"_class": "search_log",
"id": 88,
"phrase": "java",
"searched_count": 3758269,
"url": "/courses/search/?q=java"
},
{
"_class": "search_log",
"id": 296,
"phrase": "javascript",
"searched_count": 2385833,
"url": "/courses/search/?q=javascript"
},
{
"_class": "search_log",
"id": 642,
"phrase": "java programming",
"searched_count": 371310,
"url": "/courses/search/?q=java+programming"
},
{
"_class": "search_log",
"id": 6192,
"phrase": "java for complete beginners",
"searched_count": 193568,
"url": "/courses/search/?q=java+for+complete+beginners"
},
{
"_class": "course",
"id": 478878,
"title": "Java Maven: Introduccion paso a paso para no expertos",
"url": "/java-maven/",
"type_label": "curso"
},
{
"_class": "course",
"id": 1325394,
"title": "Java a Profundidad - Temas Avanzados y Desarrollo Web.",
"url": "/java-a-profundidad/",
"type_label": "curso"
},
{
"_class": "course",
"id": 1187500,
"title": "Java EE 7 & Frameworks - JSF2, Spring 4, Struts 2 y EJB3",
"url": "/java-ee-7-frameworks-jsf2-spring-4-struts-2-y-ejb3/",
"type_label": "curso"
},
{
"_class": "course",
"id": 490376,
"title": "Java para Administradores de Sistemas",
"url": "/java-sysadmin/",
"type_label": "curso"
},
{
"_class": "user",
"id": 28097854,
"title": "Javascript Lab",
"name": "Javascript",
"display_name": "Javascript Lab",
"url": "/user/javascript-lab/",
"type_label": "instructor"
},
{
"_class": "user",
"id": 17677946,
"title": "Lara Javalyn",
"name": "Lara",
"display_name": "Lara Javalyn",
"url": "/user/lara-javalyn/",
"type_label": "instructor"
},
{
"_class": "user",
"id": 7708594,
"title": "Ashay Javadekar",
"name": "Ashay",
"display_name": "Ashay Javadekar",
"url": "/user/ashayjavadekar/",
"type_label": "instructor"
},
{
"_class": "user",
"id": 23997368,
"title": "Alex Javad",
"name": "Alex",
"display_name": "Alex Javad",
"url": "/user/alex-javad-2/",
"type_label": "instructor"
}
]
}
I have two methods to try to accomplish this:
require 'sinatra'
require 'net/http'
require 'json'
require 'openssl'
OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
def get_search_count(term)
url = 'https://www.udemy.com/api-2.0/search-suggestions?q=java'
uri = URI(url)
response = Net::HTTP.get(uri)
return JSON.parse(response)
end
get '/' do
#result = get_search_count "java"
#searchedCount = #result["results"][0]["searched_count"]
"Searched count: #{#searched_count}"
end
When I load my localhost all I get is the phrase "Searched count:" with nothing following, any help identifying my mistakes is greatly appreciated thanks in advance!
You have a typo in the string. You're reading #searched_count rather than #searchedCount

Typical ormconfig.json file for Google Cloud SQL?

I have been trying for hours. What should be the ormconfig.json file for Google Cloud SQL working with TypeORM? I managed to get it working with the IP of the DB locally (with mysql workbench and Google cloud proxy and whitelisting my ip) but I don't know what the connection details should be for app engine.
{
"name": "default",
"type": "mysql",
"host": "/cloudsql/[project:region:instance]",
"port": "3306",
"username": "root",
"password": "xxxx",
"database": "yyy",
"synchronize": true,
"logging": false,
"entities": [
"modules/**/*.entity.js"
]
}
or
{
"name": "default",
"type": "mysql",
"extra": {
"socketPath": "/cloudsql/[project:region:instance]"
},
"username": "root",
"password": "xxxx",
"database": "yyy",
"synchronize": true,
"logging": false,
"entities": [
"modules/**/*.entity.js"
]
}
or anything else?
Thanks a lot!
For those interested, here is the solution:
{
"name": "default",
"type": "mysql",
"extra": {
"socketPath": "/cloudsql/[project:region:instance]"
},
"username": "root",
"password": "xxxx",
"database": "yyy",
"synchronize": true,
"logging": false,
"entities": [
"dist/**/*.entity.js"
]
}
Note that I also changed the entities path
It didn't worked for me until I added the "cloud_sql" path also the the "host":
{
"name": "default",
"host": "/cloudsql/[project:region:instance]",
"type": "mysql",
"extra": {
"socketPath": "/cloudsql/[project:region:instance]"
},
"username": "root",
"password": "xxxx",
"database": "yyy",
"synchronize": true,
"logging": false,
"entities": [
"dist/**/*.entity.js"
]
}

what is the date format from stash api?

In the below json response, what is the date format for createdDate and updatedDate? I am not sure how to work in reverse to find what format the api is using for date. I couldn't find this any where in the documentation.
{
"size": 1,
"limit": 25,
"isLastPage": true,
"values": [
{
"id": 101,
"version": 1,
"title": "Talking Nerdy",
"description": "It’s a kludge, but put the tuple from the database in the cache.",
"state": "OPEN",
"open": true,
"closed": false,
"createdDate": 1359075920,
"updatedDate": 1359085920,
"fromRef": {
"id": "refs/heads/feature-ABC-123",
"repository": {
"slug": "my-repo",
"name": null,
"project": {
"key": "PRJ"
}
}
},
"toRef": {
"id": "refs/heads/master",
"repository": {
"slug": "my-repo",
"name": null,
"project": {
"key": "PRJ"
}
}
},
"locked": false,
"author": {
"user": {
"name": "tom",
"emailAddress": "tom#example.com",
"id": 115026,
"displayName": "Tom",
"active": true,
"slug": "tom",
"type": "NORMAL"
},
"role": "AUTHOR",
"approved": true
},
"reviewers": [
{
"user": {
"name": "jcitizen",
"emailAddress": "jane#example.com",
"id": 101,
"displayName": "Jane Citizen",
"active": true,
"slug": "jcitizen",
"type": "NORMAL"
},
"role": "REVIEWER",
"approved": true
}
],
"participants": [
{
"user": {
"name": "dick",
"emailAddress": "dick#example.com",
"id": 3083181,
"displayName": "Dick",
"active": true,
"slug": "dick",
"type": "NORMAL"
},
"role": "PARTICIPANT",
"approved": false
},
{
"user": {
"name": "harry",
"emailAddress": "harry#example.com",
"id": 99049120,
"displayName": "Harry",
"active": true,
"slug": "harry",
"type": "NORMAL"
},
"role": "PARTICIPANT",
"approved": true
}
],
"link": {
"url": "http://link/to/pullrequest",
"rel": "self"
},
"links": {
"self": [
{
"href": "http://link/to/pullrequest"
}
]
}
}
],
"start": 0
}
Just making a note that in my case, it is a UNIX timestamp, but I have to remove three trailing zeroes. E.g. the data looks like this:
"createdDate":1555621993000
If interpreted as a UNIX timestamp, that would be 09/12/51265 # 4:16am (UTC).
By removing the three trailing zeroes I get 1555621993, which is the correct time 04/18/2019 # 9:13pm (UTC)
Your mileage may vary but that was a key discovery for me :)
It looks like a UNIX timestamp.
https://en.wikipedia.org/wiki/Unix_time