visas – How many days it takes to receive a passport by an express courier return?

I have applied for a UK visa in Paris and I am wondering whether I should choose the express courier return service or not. I have already been troubled a lot by Covid-19 and I want to receive the passport as soon as possible after the decision has been made. However, I am afraid the TLSContact courier service will take too long, or perhaps it may not be something to trust very well. For those who know, how many days it usually takes for such a service to deliver a passport?

node.js – Wait for function that has setTimeout inside an Express Route

I need help with a question about code in Node.js

I got it working outside an Express Route, but my problem is when I use it inside one Express Route.

The code is to upload large files from Node.js to OneDrive, is based in code that I found here:

Upload large files from Node.js to OneDrive

I made a reduce version of the code to avoid the need of a token to explain my issue.

The code has a simulated server version where files are uploaded an a client.

The server application running in http://localhost:5000 is as follow:

const express = require('express');
const app = express();

app.put('/', function (req, res) { // PUT http://localhost:5000
     const rawHeaders = req.rawHeaders
     const bytesElement = rawHeaders(5)

     console.log(bytesElement)

     if(bytesElement === 'bytes 62914559-68663828/68663829'){
          res.send('Finish Uploading Data')
      }
})

 const port = 5000
 app.listen(port, () => console.log(`Listening port: ${port}`))

The client version that works ok is as follow:

const fs = require('fs');
const got = require('got');
const async = require('async');

const file = "./video.mp4"; 

function resUpload(){
   const uploadUrl = 'http://localhost:5000'
   uploadFile(uploadUrl);
}

let counter = 0 // USED FOR DEBUGGING

function uploadFile(uploadUrl) {  
    const params = (
           {bstart: 0, bend: 62914558, cr: 'bytes 0-62914558/68663829', clen: 62914559, stime: 10000},
           {bstart: 62914559, bend: 68663828, cr: 'bytes 62914559-68663828/68663829', clen: 5749270, stime: 10000}
)

 async.eachSeries(params, function(st, callback){
    setTimeout(async function() {  

        counter += 1
        console.log(`counter: ${counter}`); // Prints counter: 1 and counter: 2

         fs.readFile(file,  async function read(e, f) {
             try {
                 const response = await got({ 
                     method: 'PUT',
                     url: uploadUrl,
                     headers: {
                         'Content-Length': st.clen,
                         'Content-Range': st.cr,
                     },
                       body: f.slice(st.bstart, st.bend + 1)}
                     );

                 console.log(response.body); // Finish Uploading Data
             } catch (error) {
                 console.log(error)
             }    
         });

       callback();  
  
     }, st.stime);
 });
}

 resUpload();

The client version that not works ok (use an Express Route) is as follow:

const fs = require('fs');
const express = require('express');
const async = require("async");  
const got = require('got');  

const app = express();

let counter = 0 // USED FOR DEBUGGING

function uploadFile(uploadUrl, data){  
      const params = (
              {bstart: 0, bend: 62914558, cr: 'bytes 0-62914558/68663829', clen: 62914559, stime: 10000},
              {bstart: 62914559, bend: 68663828, cr: 'bytes 62914559-68663828/68663829', clen: 5749270, stime: 10000}
)
async.eachSeries(params, function(st, callback){
  setTimeout(async function() {  

    counter += 1
    console.log(`counter: ${counter}`); // Prints counter: 1

          try {
              const response = await got({ 
                  method: 'PUT',
                  url: uploadUrl,
                  headers: {
                      'Content-Length': st.clen,
                      'Content-Range': st.cr,
                  },
                  body: data.slice(st.bstart, st.bend + 1)}
             );
             console.log("response.body: " + response.body); // Never prints
          } catch (error) {
              console.log(error) 
          }  
    
    callback();  
  }, st.stime);
 });
}

const file = "./video.mp4";  

app.get('/', function (req, res) { // GET http://localhost:3000

   const uploadUrl = 'http://localhost:5000';

   const data = fs.readFileSync(file)

   uploadFile(uploadUrl, data)  

   res.send('Finish')
})

const port = 3000
app.listen(port, () => console.log(`Listening port: ${port}`))

As you can see in the above code the first Client Application (Do not use an Express Route),

Prints counter: 1 and counter: 2 and Prints Finish Uploading Data

But the second Client Application (Use an Express Route),

Prints counter: 1 and Never prints response.body

How could I modify the code to get the same results in the second Client Application that in the first Client Application?

javascript – PUT and GET methods not working with express

I’m building a CRUD app. I’m stuck on update and delete operation, everything else seems to be working. So I use method-override to send PUT and GET request.

Here’s the relevant code:

app.js

const methodOverride = require('method-override');
app.use(methodOverride('_method'));

Here’s what I wrote for update and delete. I’m using monk driver for mongodb.

index.js

var router = express.Router();

router.put('/videos/:id', function(req, res){
    var collection = db.get('videos');
    var item = {
        title: req.body.title,
        genre: req.body.genre,
        image: req.body.image,
        description: req.body.desc
    };
    var id = req.params.id;
    collection.update(
    {_id: id}, {
        $set: item
    });
    res.redirect('/videos');
});

router.delete('/videos/:id', function(req, res){
    var collection = db.get('videos');
    collection.remove({"_id" : req.params.id});
    res.redirect('/videos');
});

For delete form

<form action="/videos/<%= video._id %>?_method=DELETE" method="POST">
<button type="submit" class="btn btn-danger">Delete video</button>
</form>

For update form

<form method="POST" action="/videos/<%= video._id %>?_method=PUT">
    <input type="hidden" name="_method" value="PUT">
</form>

I’ve searched in many places, still get a webpage not found (404) error when I hit the submit button.
What am I missing ?
The submit button should call the two methods I showed in index.js.

visas – How many days it takes to recieve a passport by an express courier return?

I have applied for the UK visa in Paris and I am wondering whether I should choose the express courier return service or not. I have already been troubled a lot by Covid-19 and I want to recieve the passport as soon as possible after the decesion has been made. However, I am afraid the TLSContact courier service will take too long or perhaps it may not be something to trust very well. For those who know, how many days it usually takes for such a service to deliver a passport?

bitcoin core – Starting bitcoind for the express purpose of creating a wallet?

Referencing this solution:

My favorite method:

  • grab out a old/unused pc/mac
  • install a linux over usb (maybe Talis) (make sure your USB stick is clean!)
  • download a recent version of bitcoin-core (check hash, verify gitian signatures)
  • copy bitcoin-core over usb to your offline machine
  • start ./bitcoind
  • ./bitcoin-cli getnewaddress (gives you a new public key)
  • ./bitcoin-cli dumpprivatekey (gives you the corresponding private key)
  • print or write down both strings (address can be recreated from private key, but print it anyhow)
  • verify the printed or written down strings
  • try to delete printers cache (power off, reset)

Now you could delete/format the pc/mac.
But maybe it’s worth keeping your new offline computer to generate new addresses or sign transaction in a “cold space/wallet”.

I’ve installed bitcoin-core using snap on Ubuntu and ready to start a dry-run of this for reference. However, disk space is limited, and, even then, I have no interest in downloading the blockchain itself.

How do I start bitcoind for generating a wallet?

I have:

nicholas@mordor:~$ 
nicholas@mordor:~$ bitcoin-core.cli status
error: Could not connect to the server 127.0.0.1:8332

Make sure the bitcoind server is running and that you are connecting to the correct RPC port.
nicholas@mordor:~$ 
nicholas@mordor:~$ bitcoin-core.cli getblockchaininfo
error: Could not connect to the server 127.0.0.1:8332

Make sure the bitcoind server is running and that you are connecting to the correct RPC port.
nicholas@mordor:~$ 
nicholas@mordor:~$ bitcoin-core.cli start
error: Could not connect to the server 127.0.0.1:8332

Make sure the bitcoind server is running and that you are connecting to the correct RPC port.
nicholas@mordor:~$ 

and am just looking to run bitcoin-core in pruning mode to play with.

I want to run a command like:

bitcoin-cli -testnet getblockchaininfo

Because I installed with snap I can run snap info bitcoin-core but man bitcoin-core doesn’t give any results.

Starting the daemon:

nicholas@mordor:~$ 
nicholas@mordor:~$ bitcoin-core.daemon
2020-11-11T20:55:32Z Bitcoin Core version v0.20.1 (release build)
2020-11-11T20:55:32Z Assuming ancestors of block 0000000000000000000f2adce67e49b0b6bdeb9de8b7c3d7e93b21e7fc1e819d have valid signatures.
2020-11-11T20:55:32Z Setting nMinimumChainWork=00000000000000000000000000000000000000000e1ab5ec9348e9f4b8eb8154
2020-11-11T20:55:32Z Using the 'sse4(1way),sse41(4way)' SHA256 implementation
2020-11-11T20:55:32Z Default data directory /home/nicholas/snap/bitcoin-core/common/.bitcoin
2020-11-11T20:55:32Z Using data directory /home/nicholas/snap/bitcoin-core/common/.bitcoin
2020-11-11T20:55:32Z Config file: /home/nicholas/snap/bitcoin-core/common/.bitcoin/bitcoin.conf
2020-11-11T20:55:32Z Using at most 125 automatic connections (1024 file descriptors available)
2020-11-11T20:55:32Z Using 16 MiB out of 32/2 requested for signature cache, able to store 524288 elements
2020-11-11T20:55:32Z Using 16 MiB out of 32/2 requested for script execution cache, able to store 524288 elements
2020-11-11T20:55:32Z Script verification uses 1 additional threads
2020-11-11T20:55:32Z scheduler thread start
2020-11-11T20:55:32Z HTTP: creating work queue of depth 16
2020-11-11T20:55:32Z No rpcpassword set - using random cookie authentication.
2020-11-11T20:55:32Z Generated RPC authentication cookie /home/nicholas/snap/bitcoin-core/common/.bitcoin/.cookie
2020-11-11T20:55:32Z HTTP: starting 4 worker threads
2020-11-11T20:55:32Z Using wallet directory /home/nicholas/snap/bitcoin-core/common/.bitcoin/wallets
2020-11-11T20:55:32Z init message: Verifying wallet(s)...
2020-11-11T20:55:33Z Using BerkeleyDB version Berkeley DB 4.8.30: (April  9, 2010)
2020-11-11T20:55:33Z Using wallet /home/nicholas/snap/bitcoin-core/common/.bitcoin/wallets
2020-11-11T20:55:33Z BerkeleyEnvironment::Open: LogDir=/home/nicholas/snap/bitcoin-core/common/.bitcoin/wallets/database ErrorFile=/home/nicholas/snap/bitcoin-core/common/.bitcoin/wallets/db.log
2020-11-11T20:55:33Z init message: Loading banlist...
2020-11-11T20:55:33Z Using /16 prefix for IP bucketing
2020-11-11T20:55:33Z Cache configuration:
2020-11-11T20:55:33Z * Using 2.0 MiB for block index database
2020-11-11T20:55:33Z * Using 8.0 MiB for chain state database
2020-11-11T20:55:33Z * Using 440.0 MiB for in-memory UTXO set (plus up to 286.1 MiB of unused mempool space)
2020-11-11T20:55:33Z init message: Loading block index...
2020-11-11T20:55:33Z Opening LevelDB in /home/nicholas/snap/bitcoin-core/common/.bitcoin/blocks/index
2020-11-11T20:55:33Z Opened LevelDB successfully
2020-11-11T20:55:33Z Using obfuscation key for /home/nicholas/snap/bitcoin-core/common/.bitcoin/blocks/index: 0000000000000000
2020-11-11T20:55:43Z LoadBlockIndexDB: last block file = 186
2020-11-11T20:55:43Z LoadBlockIndexDB: last block file info: CBlockFileInfo(blocks=338, size=108899992, heights=325785...326349, time=2014-10-17...2014-10-21)
2020-11-11T20:55:43Z Checking all blk files are present...
2020-11-11T20:55:43Z LoadBlockIndexDB(): Block files have previously been pruned
2020-11-11T20:55:43Z : You need to rebuild the database using -reindex to go back to unpruned mode.  This will redownload the entire blockchain.
Please restart with -reindex or -reindex-chainstate to recover.
: You need to rebuild the database using -reindex to go back to unpruned mode.  This will redownload the entire blockchain.
Please restart with -reindex or -reindex-chainstate to recover.
2020-11-11T20:55:43Z Aborted block database rebuild. Exiting.
2020-11-11T20:55:43Z Shutdown: In progress...
2020-11-11T20:55:43Z scheduler thread exit
2020-11-11T20:55:43Z Shutdown: done
nicholas@mordor:~$ 

javascript – Why is express failing to lookup ejs file in views folder?

Started learning NodeJS and Express.

// express framework 
var express  = require("express");
var app = express();

app.get("/", (req,res) =>
{
    res.render("home.ejs");
})

//port listening 
app.listen(3000, ()=>
    (
        console.log("Server listening at 3000")
    ))

The views folder is present in the same folder of the code and has the file “home.ejs”.

I receive the following error

Error: Failed to lookup view “home.ejs” in views directory “/Users/username/Desktop/Programming/JavaScript/views”
at Function.render (/Users/username/node_modules/express/lib/application.js:580:17)
at ServerResponse.render (/Users/username/node_modules/express/lib/response.js:1012:7)
at /Users/username/Desktop/Programming/JavaScript/practice/app.js:8:9
at Layer.handle (as handle_request) (/Users/username/node_modules/express/lib/router/layer.js:95:5)
at next (/Users/username/node_modules/express/lib/router/route.js:137:13)
at Route.dispatch (/Users/username/node_modules/express/lib/router/route.js:112:3)
at Layer.handle (as handle_request) (/Users/username/node_modules/express/lib/router/layer.js:95:5)
at /Users/username/node_modules/express/lib/router/index.js:281:22
at Function.process_params (/Users/username/node_modules/express/lib/router/index.js:335:12)
at next (/Users/username/node_modules/express/lib/router/index.js:275:10)

node.js – É possível descobrir a duração de um áudio pela requisição do Express?

Olá, tudo certo?

Estou desenvolvendo uma aplicação em Node.js com Express que tem como uma de suas funções receber um arquivo de audio e armazenar no banco de dados as informações do arquivo. Estou passando esse arquivo em formato .ogg dentro da requisição, e no corpo da requisição estou passando a duração do audio manualmente.

Existe alguma maneira de obter a duração do audio a partir da requisição?

Segue um exemplo da minha função post()

route.post(
  '/upload',
  upload.single('audio'),
  (request, response) => {
    const { title, description, tags, duration, post_time } = request.body;
    const createAudioSevice = new CreateAudioService();

    const audio = createAudioSevice.execute({
      id: request.file.filename,
      title,
      user_id: request.user.id,
      description,
      duration,
      post_time,
      tags,
    });

    return response.json(audio);
  },
);

Magento – PayPal express checkout button missing in Shopping cart

Anyone else getting PayPal express checkout button in shopping cart missing?

enter image description here

From older posts It looks like It might be from the server being down?

Anyway, when I got to : fpdbs.paypal.com I can’t reach the website.

The button image source is : https://fpdbs.paypal.com/dynamicimageweb?cmd=_dynamic-image&buttontype=ecshortcut&locale=en_GB&ordertotal=#####&pal=########

And that fails too.

Anyone else?

node.js – 400 Bad request no servidor express e typeorm

Ola, estou tentando criar um usuario, mas ao enviar o método post com os dados do usúario eu recebo um 400 Bad Request do servidor, o problema é que o servidor não está entendendo os dados, no erro aparece como se todos os campos estivessem faltando. Segue prints e o código:

import { getRepository } from 'typeorm';
import * as Yup from 'yup';

import User from '../models/users';
import UserView from '../views/users_view';

export default {
    async login(request: Request, response: Response) {
        // const userReposity = getRepository(User);

        // const {
        //     userName,
        //     userPassword,
        // } = request.body;
    },

    async createUser(request: Request, response: Response) {
        
        const {
            userName,
            userPassword,
            access_level,
        } = request.body;
        
        const userReposity = getRepository(User);

        const data = {
            userName,
            userPassword,
            access_level
        }

        const schema = Yup.object().shape({
            userName: Yup.string().required('Nome obrigatório'),
            userPassword: Yup.string().required('Senha obrigatória'),
            access_level: Yup.string().required('Nível de acesso obrigatório'),
        })

        await schema.validate(data,
            { abortEarly: false }
        );

        const user = userReposity.create(data);

        await userReposity.save(user);

        return response.status(201).json(user);
    }

}```
Codigo do front end: 

```typescript
import api from '../services/api'

import '../styles/pages/login-page.css';

export default function Login() {

    const history = useHistory();

    const (name, setName) = useState('');
    const (password, setPassword) = useState('');

    async function handleSubmitLogin(event: FormEvent){
        event.preventDefault();

        const data = new FormData();

        data.append('userName', name);
        data.append('userPassword', password);

        await api.post('usercreate', data);

        history.push('/dashboard');
    }

    return (
        <div className="containerLogin">
            <Link to="/app">
                <FiArrowLeft size={32} color="#FFF" className="button-GoBack" />
            </Link>
            <div className="container-inputs">
                <form className="container-inputsLogin" onSubmit={handleSubmitLogin}>
                    <h1 className="text-login">Login</h1>
                    <div className="input-blockLogin">
                        <label htmlFor="name">
                            <FiUser size={32} color="#FFF" className="icon-input" />
                        </label>
                        <input
                            id="name"
                            value={name}
                            onChange={event => setName(event.target.value)}
                            placeholder="Nome de usúario" />
                    </div>
                    <div className="input-blockLogin">
                        <label htmlFor="password">
                            <FiKey size={32} color="#FFF" />
                        </label>
                        <input
                            className="input-password"
                            id="password"
                            value={password}
                            onChange={event => setPassword(event.target.value)}
                            placeholder="Senha"
                            type="password" />
                    </div>
                    <button className="confirm-button" type="submit">
                        ENTRAR
                        <FiArrowRight size={28} color="#141414" className="button-arrow"/>
                    </button>
                </form>
            </div>
        </div>
    )

}```

(!(Print do erro no insomnia)(1))(1)


  (1): https://i.stack.imgur.com/evPrf.png

network – Airport Express in bridge mode intermittently loses connection to internet

My Apple Airport Express (A1392, 2nd gen) loses connection to the internet once or twice a day.
Rebooting it or rebooting the modem-router to which it is connected solves the issue. Strangely enough, when this happens the NAS that is connected to the modem-router via Ethernet also loses connection to the internet.

The modem-router itself does not lose connection to the internet (all lights remain on, cpanel shows no loss of connection).

My network setup is simple:

  • modem-router provided by my ISP with Wi-Fi turned off
  • Wired connections between this modem-router and the Airport Express, a NAS and a network switch.
  • The Airport Express is set to bridge mode.

What I have tried:

  • new modem-router from ISP. No change.
  • reset Airport Express. No change.
  • Set IPv6 to link-local only on the Airport Express. No change.
  • leaving the Airport Express turned off: no more network issues.
  • ISP technician saw no problems with line values etc.