lundi 27 juillet 2020

How to upload code files to a web server?

As a tyro and after a long time of searching, I desperately wanna know how to upload the code which has been done to a web server. Mechanism explaining would be pleasing. Thanks for answering.

BTY, I'm trying this for training on a VM of my laptop, on which I have built up a LAMP Stack.




How do i put textbox with a text exactly below the next one? css&html

I'm trying to put the text box with the text before and it doesn't work. I tried with float and its works but stick the text together... please help (:

 <div class="optionContainer">
        
        <div class="firstName">
            <label for="fname">First Name*</label>
            <input type="text" id="fname" name="fname">
    </div>
        
        <div class="LastName">
            <label for="lname">Last Name*</label>
            <input type="text" id="lname" name="lname">
    </div>
    
    </div>



Upload a file to the Google Drive API in status 200, but where's the file?

I'm trying to upload a file to Google Drive. After I run the program, I get status 200 but I can't find the file in Drive. I entered a folder ID in the fileMetadata variable under the parents key.

This is my code:

const { google } = require('googleapis');
const credentials = require('./credentials.json');
const fs = require('fs')

const scopes = [
    'https://www.googleapis.com/auth/drive',
    'https://www.googleapis.com/auth/drive.file',
    'https://www.googleapis.com/auth/drive.appdata',
  ];

const auth = new google.auth.JWT(
credentials.client_email, null,
credentials.private_key, scopes
);

const drive = google.drive({ version: "v3", auth });

auth.authorize(function(err, tokens) {
    if (err) {
        console.log(err);
        return;                                                     
    } else {
        console.log('It authorized successfully!');
        console.log(`The Token is: ${JSON.stringify(tokens)}`)
        var data = fs.createReadStream('./Test.txt')
        var fileMetadata = {
            'name': 'photo.txt',
            'parents':[{'id':'1MiFB-XXWFRHjxZwTmE9FxsCGb9Een_2Y'}] //Folder ID
          };
          var media = {
            mimeType: 'text/plain',
            body: data //
          };
          drive.files.create({
             resource: fileMetadata,
             media: media,
             fields: 'id'
          }).then (function(err, file) {
            if(err) {
              // Handle error
              console.log(err);
            } else {
              console.log('File Id: ', file.id);
            }
          });
    }
});

And that's the response I got back:

{
  config: {
    url: 'https://www.googleapis.com/upload/drive/v3/files?fields=id&uploadType=multipart',
    method: 'POST',
    paramsSerializer: [Function (anonymous)],
    data: PassThrough {
      _readableState: [ReadableState],
      _events: [Object: null prototype],
      _eventsCount: 2,
      _maxListeners: undefined,
      _writableState: [WritableState],
      allowHalfOpen: true,
      _flush: [Function: flush],
      [Symbol(kCapture)]: false,
      [Symbol(kTransformState)]: [Object]
    },
    headers: {
      'Content-Type': 'multipart/related; boundary=7b25465c-4ee3-450d-b41c-7efd51e4637d',
      'Accept-Encoding': 'gzip',
      'User-Agent': 'google-api-nodejs-client/0.7.2 (gzip)',
      Authorization: 'Bearer `TOKEN`,
      Accept: 'application/json'
    },
    params: [Object: null prototype] { fields: 'id', uploadType: 'multipart' },
    validateStatus: [Function (anonymous)],
    body: PassThrough {
      _readableState: [ReadableState],
      _events: [Object: null prototype],
      _eventsCount: 2,
      _maxListeners: undefined,
      _writableState: [WritableState],
      allowHalfOpen: true,
      _flush: [Function: flush],
      [Symbol(kCapture)]: false,
      [Symbol(kTransformState)]: [Object]
    },
    responseType: 'json'
  },
  data: { id: '1up-LCc9Fc0D2_t7OdJvF9D2QEVwxhV8y' },
  headers: {
    'alt-svc': 'h3-29=":443"; ma=2592000,h3-27=":443"; ma=2592000,h3-T050=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43"',
    'cache-control': 'no-cache, no-store, max-age=0, must-revalidate',
    connection: 'close',
    'content-length': '47',
    'content-type': 'application/json; charset=UTF-8',
    date: 'Mon, 27 Jul 2020 09:54:42 GMT',
    expires: 'Mon, 01 Jan 1990 00:00:00 GMT',
    pragma: 'no-cache',
    server: 'UploadServer',
    vary: 'Origin, X-Origin',
    'x-guploader-uploadid': 'AAANsUma96bf0mAHkz32b8QuarZvQBuez_rVwOmhVV-ESgd1IccLyYYnn3xdT--jVFDdo9zC9Qz_VqAVyaHK-OcQWFA'
  },
  status: 200,
  statusText: 'OK'
}

Where is the file? What's not right here?

Thank you!!




Ionic. Use flex display for responsive

I tried to adapt an React App to an Ionic React App. But if I use display flex in IonContent, the div take more than the screen width for show all items in a row. How can I fix it?




How to change the address shown in the address bar into a shortened address, while the actual access address remains the same?

For example, my request URL is "https://ift.tt/3g69aXz" and I want to only show "https://ift.tt/23AdZdS" on the address bar and hide the "/api". The actual interface is still "https://ift.tt/3g69aXz, but the "/api" is removed when it is displayed. How to implement this? Thank you very much!




ExecuteReader in to XML in VB.net

Created a Web Service in Vb.net which reads records from the Database. Trying to convert the selected record that is read using ExecuteReader in to XML

<WebMethod()>
Public Function GetRoles(ByVal ID As String, ByVal ROLE As String) As List(Of String)

    Dim log As String = ""
    Dim sqlconn As New SqlConnection
    Dim sqlconn2 As New SqlConnection
    Dim sqlcmd As New SqlCommand
    Dim listOfficerRoles As New List(Of String)()

    Try
        sqlconn2.ConnectionString = STR_CONFIG
        Dim sqlcmd2 = New SqlCommand
        sqlcmd2.Connection = sqlconn2
        sqlconn2.Open()
        Dim sqlquery2 = "select a.LOGIN,a.USER,
                                    STUFF((select ', ' + CAST(ROLE AS  VARCHAR(1000)) from STROLE b where 
                                    b.USER = a.USER
                                    FOR XML PATH('')),1,1,'') AS ROLES 
                                    from T_USER a where ID = @ID
                                    group by a.ID, a.LOGIN"
        With sqlcmd2
            .Connection = sqlconn2
            .CommandText = sqlquery2
            .CommandType = CommandType.Text
            .Parameters.AddWithValue("@ID", ID)
        End With
        sqlcmd2.CommandText = sqlquery2
        Dim ds = New DataSet()
        Dim sqlreader2 = sqlcmd2.ExecuteReader()
        If sqlreader2 IsNot Nothing And sqlreader2.HasRows Then
            While sqlreader2.Read()

                listOfficerRoles.Add(sqlreader2("LOGIN").ToString)
                listOfficerRoles.Add(sqlreader2("ID").ToString)
                listOfficerRoles.Add(sqlreader2("ROLES").ToString)
            End While
        End If
        Return listOfficerRoles
    Catch ex As Exception
        log += Environment.NewLine + "ERROR: " + ex.Message
    Finally
        If sqlconn.State <> ConnectionState.Closed Then
            sqlconn2.Close()
            sqlconn.Close()
        End If

    End Try
    Return Nothing
End Function

I created a class namely

<Serializable()>
Public Class RolesModel

    Private LOGIN As String
    Private ID As String
    Private ROLES As String

    Public Property LOGIN1 As String
        Get
            Return LOGIN
        End Get
        Set(value As String)
            LOGIN = value
        End Set
    End Property

    Public Property ID1 As String
        Get
            Return ID
        End Get
        Set(value As String)
            ID = value
        End Set
    End Property

    Public Property ROLES1 As String
        Get
            Return ROLES
        End Get
        Set(value As String)
            ROLES = value
        End Set
    End Property
End Class

The response which i get is the following

<ArrayOfString>
   <string>ABCD</string>
   <string>1</string>
   <string>1,2,3</string>
</ArrayOfString>

WHAT I NEED IS XML

<LOGIN>ABCD</LOGIN>
<ID>1</ID>
<ROLES>1,2,3</ROLES>

There is no need to write to any file. while working with C# i created an array of class which gets populated on ExecuteReader. the default return is XML in C# but in VB.net I don't understand how to achieve it Any help is greatly appreciated.




Float moves everything to the one side, HTML and CSS

I have a problem with an image and 'float: right;'. It moves everything on the image. I really need help. I am just a beginner. Any help will be appreciated. Please help me. My HTML code:


    <section id="header">
        <div class="container">
            <img scr="./img/logo.png" class="logo">

            <div class="header-text">
                <h1>Choose the cheapest teachers</h1>
                <span class="square"></span>
                <p>Here you can find the best people<br>Start working for us right now</p>
                <button class="common-btn">Read more</button>

                
            </div>
        </div>

My CSS code:

* {
    margin: 0;
    padding: 0;
    font-family: sans-serif;
    font: Nunito;
}

#header {
    height: 100vh;
    background-image: url(img/image3.png);
    background-position: center;
    background-size: cover;
    width: 80vh;
    height: 80vh;
    padding:35px;
    float: right;
}
    


}
.conatiner {
    margin-right: 100px;
    margin-left: 100px;
}

.logo {
    margin-top: 30px;
    width: 100px;
    
}
.header-text{
    max-width: 350px;
    margin-top: 140px;
}