menu

Search By Label

Through the Heroku PostgreSQL add-on create a new backup capture you can do that by the UI or the CLI running:

heroku pg:backups:capture -a your-production-name-app

and after that run:

heroku pg:backups:restore <production-database-name>::<you-backups-id> DATABASE_URL --app <production-staging-enviroment> --confirm <production-staging-enviroment>

example:

heroku pg:backups:restore juanequex-prod::b194 DATABASE_URL --app juanequex-staging --confirm juanequex-staging

Enjoy! c:
Through the Heroku PostgreSQL add-on create a new backup capture you can do that by the UI or the CLI running:

heroku pg:backups:capture -a your-production-name-app

After that download the backup on your local machine, and set it in your local environment running on the terminal:

pg_restore --verbose --clean --no-acl --no-owner -h localhost -d <data-base-name> /Users/juanequex/backups/<your-local-backup>

and it is what it is, enjoy your local debugging.
The npm show command is used to display detailed information about a package available on the npm registry. 
This command provides information such as the package's metadata, versions, maintainers, dependencies, and more. It's a useful tool when you want to inspect details about a package without necessarily installing it.

Here is the basic syntax of the npm show command:
npm show <package-name>

Keep in mind that npm show retrieves information directly from the npm registry, so it doesn't require the package to be installed locally. It's a convenient way to inspect package details before deciding to install or use a particular version.
npm-check-updates upgrades your package.json dependencies to the latest versions, ignoring specified versions.

Source: npm-check-updates - npm (npmjs.com)
To check if any module in a project is 'old':
npm outdated
'outdated' will check every module defined in package.json and see if there is a newer version in the NPM registry.

CDN
Use CDN if you are developing a website that will be accessible by public internet users.

CDN Benefits:
  • Will be cached on most browsers because it's used by a lot of other websites
  • Reduce the bandwidth

NPM
npm is a great tool for managing your app's dependencies using a module bundler.

Example:

assume using a webpack module bundler and jQuery is installed
import $ from 'jQuery'
...
var content = $('#id').html();

but the browser does not understand the import statement so you have to transpile the code with Webpack commands, the bundler will check all the used dependencies and bind them in a single file without any dependency problems.

Source: javascript - Using CDN vs Installing library by NPM - Stack Overflow

ACID properties are principles of transaction-oriented database recovery.
ACID is an acronym for a set of properties for database transactions used to make sure data is valid.

The ACID principles are:
  • Atomicity: A transaction is made up of multiple statements. Atomicity ensures that either all statements are executed or none are executed.
  • Consistency: Consistency ensures that integrity restraints are followed.
  • Isolation: Transaction often occurs concurrently, at the same time, and isolation ensures that this does not lead to inconsistent data.
  • Durability: Durability ensures that once a transaction is committed, it will remain committed even in the case of a system failure.

See more examples on: https://www.freecodecamp.org/news/acid-databases-explained/?ref=dailydev
List the stashes:
git stash list

Show the files in the most recent stash:
git stash show

Show the changes in the most recent stash:
git stash show -p

Show the changes in the named stash:
git stash show -p stash@{1}

Or in short:
git stash show -p 1 
To prevent SQL injection in Node.js, use parameterized queries with a database library, such as pg for PostgreSQL or mysql2 for MySQL.

Example using pg for PostgreSQL:

const { Client } = require('pg');

// Bad: Concatenation (vulnerable to SQL injection)
const insecureQuery = `SELECT * FROM users WHERE username = '${inputUsername}'`;

// Good: Parameterized query (prevents SQL injection)
const secureQuery = 'SELECT * FROM users WHERE username = $1';
const values = [inputUsername];

const client = new Client();
client.connect();

client.query(secureQuery, values, (err, result) => {
  // Handle the query result
  client.end();
});

By using parameterized queries, you avoid directly interpolating user input into SQL statements, reducing the risk of SQL injection.

The pointer-events CSS property is used to control under what circumstances an element can trigger user interface events like mouse clicks and hover. It allows you to control the visibility and interaction of elements on the page.


The pointer-events property can take the following values:

  • auto: The element behaves as normal. It is subject to mouse events according to its CSS styling.
  • none: The element is completely transparent to mouse events. It will not block any interactions with elements beneath it, effectively making it "click-through."

This property is beneficial when you want to overlay an element on top of another but still want the underlying element to receive mouse events. It provides a way to flexibly control layered elements' interaction behavior.



" Hello world ".strip # => "Hello world"
Deletes all Jobs in a Queue, by removing the queue.

Sidekiq.redis(&:flushdb)
process.nextTick() is a function in Node.js designed to schedule a callback function to be invoked in the next iteration of the event loop. 

It allows a callback to be executed immediately after the current operation but before the event loop continues. This makes it useful for ensuring that certain tasks, especially related to the execution context or I/O, are deferred until the next tick of the event loop. It is often used to break down large asynchronous operations into smaller, more manageable chunks.
So the operation
(3 - 10) % 27
result in 20, because when you insert a negative number in the first operand the modulus return a positive result changing this
-7 % 27
to this
-7 + 27
resulting in 20
Using the following command, you can minimize any app on your Mac

cmd + m