javascript – Extraction of images in HTML with Node Js + Express

I start with nodejs and I have a question. Whenever I call image or even the bootstrap in my file, I have to use sendfile. Whenever you want an icon or image, should I set the route on the node, then the file, or is there a more convenient way to do it?

javascript – BOT Discord Spam JS / Node

Hello

I have created a BOT for Discord with the help of JS, NodeJS and the DiscordJS library

However, I realized that every 4 hours, my BOT sent a message on all the server channels, as well as spam via DM for all users of this server. The spam message is as follows:

@ everybody
I have good news!
link to a page generated with bitly
link to a page generated with bitly

I have already read and re-published my code, but I can not identify the problem, I believe it is not in the code.
However, follow my main.js below:

const Commando = require (& # 39; discord.js-commando & # 39;);
const {Client, attachment} = require (& # 39; discord.js & # 39;);
const bot = new Commando.Client ();
const config = require (& # 39; ./ config.json & # 39;);

// heroku
const express = require (& # 39;);
const path = require (& # 39;) & # 39;
const PORT = process.env.PORT || 5000;
express ()
.use (express.static (path.join (__ dirname, & # 39; public)))
.set ("views", path.join (___name, "views"))
.set ('visualization engine', 'ejs & # 39;)
.get (/ # 39 ;, (req, res) => res.render (& # 39; pages / index & # 39;))
.listen (PORT, () => console.log (`Listening on $ {PORT}`))

bot.registry.registerGroup ('music', 'music');
bot.registry.registerDefaults ();
bot.registry.registerCommandsIn (__ dirname + & # 39; / orders & # 39;);

global.servers = {};

bot.on ('ready', () => {
console.log (& # 39; Running ... & # 39;);
});

bot.on (& # 39; message, function (message) {
if (message.author.bot) returns;
if (message.channel.type === & dquo; dm & dquo;) returns;

const args = message.content.slice (config.prefix.length) .trim () split (/ + / g);
const command = args.shift (). toLowerCase ();

if (message.content == & # 39; hello & # 39;) {
message.channel.send ("Hi");
}

// if (command === 'quemsou') THIS WORKS WITH THE EXCLAMATION, EX :! quemsou
if (message.content == & # 39; quemsou & # 39;) {
attach attachment = new Attachment (& # 39; ./ meme.png & # 39;)

let r_text = new Array ();
r_text[0] = `$ {message.author} is a Lolzeiro, get out of here;
r_text[1] = "$ {message.author} is a C SUCCESSFUL";
r_text[2] = `$ {message.author} has already published your ULT of Mercy hj? Pathetic ... `;
r_text[3] = `$ {message.author} only plays with ASH and thinks it is PRO`;
r_text[4] = `$ {message.author} loaded globally, kjjjj`;
r_text[5] = `$ {message.author} plays PUBG with 15 SPPS and always finds it fun, kk eae men`;
r_text[6] = `$ {message.author} is an FRI reader, here you have free access and permission from the ADMINISTRATOR. Welcome MY KING! `;

let i = Math.floor (7 * Math.random ());

message.channel.send (`$ {r_text[i]} `, attachment);
}

if (message.content == & # 40; commands)
message.channel.send ( n  n  n  n  n  n Anyone who == Random messages about the game you play  n! play LINKDOYOTUBE == Bot will play your music  n! exit == Bot will stop playing The music will come out of the room  n  n THE ONLY COMMANDS THAT NEED THE EXCLAMATION "!" ARE THE COMMANDS TO PLAY MUSIC & # 39;);
}
});

bot.login (config.token);

To summarize very briefly how I created my BOT, I added the DiscordJS library to my file, I created the code in the BOT JS, I went to the official Discord site and I got it I created the BOT application, I add it in my via the link provided in the official Discord documentation.

Lightning Network – I can pay bills on my LND Mainnet node, but others can not pay my bills

I have an LND node running version 0.5.2-beta on a Ubuntu virtual machine 16.04 2-core RAM, 8 GB. Here is my node: https://1ml.com/node/02d5efae50c1cdc6011e40b74f061ea4f444088865ec14a59e4ee6cf0d71c842fc

I used the Raspibolt tutorial to configure this node. It seems to work fine, but when you try to receive payments, it does not work. I can create channels and other content, the only problem being the inability to receive payments.

For example, I have a post on the mails. I paid for the messages, it works perfectly. However, when I try to withdraw all that I have earned through the bails, the payment has failed. When I try again, it means that the bill is too heavy, although that is wrong. I can confirm that I entered the right node public key when creating the publication because I tried my invoices on other yalls publications and this clearly indicates that the publication of the node is different. Here is an imgur album that demonstrates it.

I've also tested my bills with BlueWallet, and it's written failure of LND API 7. Here is an imgur album that shows it well. I think the problem here is my knot. Has anyone encountered this problem or has he found a solution?

TLDR: I can do everything with my LND node, except receive payments on bills I make

raspberry pi – Remote SSH connection to Raspibolt Lightning network node

Regarding your specific configuration, we would need more information to solve the problem, but here are some general network debugging steps I take –

Start at the lowest level

RPIs come with SSH enabled by default the last time I checked; therefore, it is only a step of verification of integrity.

First, make sure that the Raspberry Pi allows SSH connections (you've already said that you've already done so, so be brief) from your local network –

From another machine on the same local network as the RPI

$ curl -v {{put your local IP address rpi here}}}: 22

which indicates if the port is open because you should see something along the lines of * Failed Recv: connection reset by a peer. If the port is not open, the top failure should look like the failed: connection refused.

In the first case, your server replied on the 22nd but did not accept the connection (since it is a loop and not an SSH connection attempt)

If that succeeds, you can of course continue with an SSH attempt to verify that you have access –

$ ssh {{user}} @ {{local ip}}

Exit the network

Since you have been able to do SSH locally (if you have not arrived at this step, it does not matter), the next step is to disconnect from your WiFi or local network and then test the settings of your router / firewall.

You can do this, for example, by connecting the Internet connection of your phone and issuing the same commands as above, replacing the IP address on the local network above with your external IP address. You can get your external IP address by going to Google "What is my IP address".

Finally, repeat the steps above to test first that the port is responding and to verify that the connection is allowed.

As you mentioned before, the main responsible is not the transmission of ports on the router. In addition, you will need to configure your lnd.conf to listen on the externalip as well as instruct the RPC service or the REST service to listen on this external IP address, unless you are using something more advanced, such as a reverse proxy .

theming – How to make the author info on the custom fields on the comment model and twig node in drupal8?

I'm trying to give the author the full name and information about the other customs fields of the authors in comment.html.twig and node.html.twig. But none of the fields I've created for users, such as "First Name", "Last Name", and Auther UID, etc., are displayed in comments.

I've tried with the following code for the comment writer

{{}} Comments.author.field-first_name.entity.value
{{}} Comment.author.user_picture.0.entity.uri.value
{{}} Comments.author.uid.entity.value

And, I've tried the following code for the author of the node:

{{}} Node.author.field-first_name.entity.value
{{}} Node.author.user_picture.0.entity.uri.value
{{}} Node.author.uid.entity.value

Ideas, how can I make this information in the comment template?

importaddress – How to validate the amounts of these portfolios (https://bitinfocharts.com/top-100-richest-bitcoin-addresses.html) on my complete bitcoin node?

A portfolio does not depend on whether the blockchain should be downloaded. The blockchain is not stored in a wallet. The new scan does not reload the blockchain unless you are using a pruned node.

Use import addressyou must have a portfolio. This can not work without wallet file. If for some reason you do not have a wallet file, if you start Bitcoin Core normally (that is, without any wallet deactivation option), it will automatically create a wallet. If you have a portfolio and just want to import the address into another one, you can create one using the create a portfolio order. If you have another wallet file, you can move it to the Bitcoin data directory and load the wallet by pressing loading wallet order.


However, charging or creating a wallet is not what you really want to do. You really do not want to import an address into your wallet; you really want to check if this address actually has the amount of Bitcoin you see listed on a website. To do this, you can simply use the scantxoutset command that was introduced in Bitcoin Core 0.17. It does not need portfolio and works much faster than a new analysis. See his help text (using help scantxoutset) to know how to use it.

What scantxoutset Does this parse the UTXO set for any UTXO corresponding to a given pattern. This will tell you which UTXOs are associated with an exit address or script. From there, you can add up their values ​​and calculate the total available balance. This will give you the information you want to see without needing a wallet and without having to scan the entire blockchain.

8 – When submitting a web form, set a date field on the article node equal to "current time" + "X minutes"

I use the field timer module to display the countdown on my article node.

This module will take the value of the date / time field (my case: field_article_datetime) and convert it to a countdown in the article view.

I have a web form (machine name: ABC) in the form of a field to the article content type so I can use [webform_submission:node:nid] to recover the article nest of the article to update.

The Web form (machine name: ABC) includes the following element:

1) To select element (name of the machine: increase_time_in_minutes):

  1. Text: 15 minute increase (value: 15)
  2. Text: 30 minute increase (value: 30)
  3. Text: increase of 45 minutes (value: 45)

And the content type of the article has a field below:

  1. date / time field (computer name: field_article_datetime) (the Field Timer module is applied to this field)

When the web form "ABC" is submitted, I wish:

  1. Get the nest item ([webform_submission:node:nid])
  2. Set the value of the date / time field (field_article_datetime) equal to current time + hour_increase_in minutes

EXAMPLE:

Say to 14/03/2019 20h30h15, a user submitted the web form "ABC" and selected Increase by 15 minutes select list option … so I need the associated article to be retrieved and update the (field_article_datetime) so that it has the value 14/03/2019 20:45:15

In this way, the user will see a countdown of 15 minutes on the display page of the article node.


I am not a programmer, but I think the best idea is to use a customwebformhandler.php file that will be enabled for the web form settings page.

I have created the file but I need help to complete it:

getData ();

// This is the part where to get the article node.
SOME CODES ARE HERE.

// This is the updated part of the node.
SOME CODES ARE HERE.

// This is the recording part of the node.
$ node-> save ();
}
}

bitcoin core – What information does a Lightning network node contain?

When synchronizing the bitcoin node (prerequisite for Lightning's secure run), you download the entire blockchain and you validate all historical transactions, which takes a while or more than two cents Gio. Having a complete validation node means that you always receive valid transaction information yourself and that you are not relying on third parties that may present false information or leaks in privacy by requesting information about transactions to be made. some thirds.

The bitcoin node will continue to receive new blocks and transactions as they appear on the network, and each block serves as a sync point every 10 minutes or so.

During initial Lightning Node synchronization, you receive the latest information about online nodes, open channels, and the rules by which you can send payments through these channels with Lightning Onion routing. By default, this information is limited to the previous 2 weeks, so historical node and channel information is not transmitted or stored.

After the initial synchronization, your node will receive and continuously rebroadcast new node and channel information through Lightning's gossip network. Each node broadcasts information about itself or its channels every 2 weeks if there has been no change and the channels are still active. Any changes to the channel or node states are immediately propagated, but the nodes can limit the frequency of updates that they accept to avoid a denial of service that can degrade the network. These issues are also time stamped and signed.

sublimetext3 – Sublime text: Get the full path of the yaml tree by clicking on a node and look for the full path of the tree

Let's say I have an .yml file with thousands of entries, for example.

in:
Something:
1000 entries
something else:
foo:
bar:
2000 entries
Things:
I am:
watching:
500 entries
for: "hello"

Now, let's say I've found for: "hello". Is there an easy way to get the full path, which means something.stuff.i_am.looking.for without looking for each tree node?

And my second question – from a complete path, how can I look sublime? Let's say I have hundreds of yml files, how can I look for a path something.stuff.i_am.looking.for? Searching for one of the keys is quite inefficient.

8 – D8: Module to create a custom field in all node sets

I build a module to insert a custom field in all bundles of the node. I have encountered a lot of difficulties, all the help that they can give me, I would appreciate it a lot.

The custom field I create is used to register a token automatically or manually. – field_custom_tocken

If a new set is created, the field field_custom_tocken must be added automatically to the new set. To generate the token, it is necessary that the identifier of the entity (nest) or that the token be inserted by the user.

I used Drupal Console, create the type of field, the widget and the trainer. This does not generate the field, the disadvantage is that you have to manually add the field to the set.
drupal generator: plugin: field

In this documentation, the field is created and added to a specific set. I use some of this documentation. field.storage.node.field_brand_information.yml

I have this:

this creates the field.
modules / custom / custom_tocken / config / install / field.storage.node.field_custom_tocken.yml

# field.storage.node.field_custom_tocken.yml
langcode: in
status: true
dependencies:
forced:
module:
- custom_tocken
module:
- knot
- text
id: node.field_custom_tocken
field_name: field_custom_tocken
entity_type: node
type: string
settings: {}
module: kernel
locked: true
cardinality: 1
translatable: true
index: {}
persist_with_no_fields: false
custom_storage: false

This should create the custom field in existing sets, when the module is installed, but it does not work πŸ™

/ **
* Implements hook_install ().
* /
function ide_d8_url_shortener_install () {
$ entity_type = & # 39; node & # 39 ;;
$ bundle = & # 39;
$ field['field_name'] = & # 39; field_custom_tocken & # 39 ;;
$ field['label']      = & # 39; Tocken & # 39 ;;
$ field['entity_type']= & # 39; node & # 39 ;;
$ field['type']       = & # 39; chain & # 39 ;;
$ field['settings']   = table ();

$ bundles =  Drupal :: service (& # 39; entity_type.bundle.info & # 39;) -> getBundleInfo ($ entity_type);
$ arr_bundles = [];

foreach ($ sets like $ key => value $) {
$ bundle = $ key;
$ fields =  Drupal :: entityManager () -> getFieldDefinitions ($ entity_type, $ bundle);

if (! isset ($ fields['field_short_url'])) {
entity_get_form_display ($ entity_type, $ bundle, & # 39; default)
-> setComponent ($ field['field_name']field $)
-> save ();

entity_get_display ($ entity_type, $ bundle, & # 39; default)
-> setComponent ($ field['field_name']field $)
-> save ();
}
}
}

Any help you can give me, I would appreciate it.