Skip to content

Instantly share code, notes, and snippets.

View danieldogeanu's full-sized avatar

Daniel Dogeanu danieldogeanu

View GitHub Profile
@danieldogeanu
danieldogeanu / EnablePaste.md
Last active September 14, 2023 17:36
Re-enable pasting on input fields.

To re-enable pasting for input fields where paste is disabled, open the console and paste the following:

document.addEventListener('paste', (e) => e.stopImmediatePropagation(), true);

Enjoy! 😊

If this was useful, you can buy me a coffee here. Thank you!

@danieldogeanu
danieldogeanu / ChangeGitRemote.md
Created March 19, 2023 01:54
How to change Git remote origin urls, to push repo to GitLab or GitHub.

How to change Git remote origin URLs, to push all branches and tags from your repo to GitLab or GitHub.

With the commands below, you can change your source control provider easily:

git remote set-url origin git@gitlab.com:your-repo-name.git
git remote -v
git push -u origin --all
git push -u origin --tags
import { ComponentProps, FC, Fragment } from "react";
export interface ProvidersProps {
children: React.ReactNode;
}
export type ProviderWithProps = [FC<ProvidersProps>, Object];
/**
* Function that combines all the context providers into a single one.
@danieldogeanu
danieldogeanu / ConvertUnixTimestamp.md
Created October 31, 2020 19:01
How to convert a unix timestamp from a string to a number, in JavaScript, without losing precision.

How to convert a unix timestamp from a string to a number, in JavaScript, without losing precision:

const stringTimestamp = '1603767190'; // Unix Timestamp
const numberTimestamp = (+ new Date(stringTimestamp * 1000)) / 1000;

console.log(numberTimestamp); // 1603767190
console.log(typeof numberTimestamp); // number
@danieldogeanu
danieldogeanu / RenameGitBranch.md
Last active April 24, 2024 17:19
How to rename your Git master branch to main.

To rename your Git master branch to main, you must do the following steps:

  1. Navigate to your repository in the command line and issue the following commands: - git branch -m master main - git push -u origin main

  2. Change your default branch on GitHub by going to your GitHub repository in your browser, and navigate to Settings > Branches and click on the dropdown and switch from master to main and click Update (this will only show if you have two or more branches). The main branch is now your default branch.

  3. Update the tracking of the branch from your command line with the following command: - git branch -u origin/main main

@danieldogeanu
danieldogeanu / NotAllowedSetStateReact.md
Last active March 9, 2020 05:22
React lifecycle methods in which is not allowed to set state.

Don't set state in the following methods or you'll create an infinite loop and your app will crash:

  • componentWillMount() // State doesn't exist yet.
  • render()
  • shouldComponentUpdate()
  • componentWillUpdate()
  • componentWillUnmount() // The component is going away.
@danieldogeanu
danieldogeanu / WampSendmail.md
Created November 22, 2019 17:12
How to configure Wamp Server to send email with sendmail.

1. Download and Configure Sendmail for Windows:

  • Download Sendmail for Windows;
  • Extract sendmail.zip and place the contents in an easily accessible place, like C:\sendmail;
  • Open the sendmail.ini file using a text editor such as notepad and edit the following values:
    [sendmail]
    smtp_server=mail.example.com
    smtp_port=465
    auth_username=username@example.com
    

auth_password=your_password

@danieldogeanu
danieldogeanu / RedirectWordPressToHTTPS.md
Last active October 17, 2019 23:26
How to redirect a WordPress site to HTTPS via the .htaccess file.

Add the following two lines of code into the .htaccess file:

RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

WARNING: For testing purposes, you might want to remove the [L,R=301] condition from the second line and instead just use [L,R]. R=301 will make your browser PERMANENTLY redirect to the new URL and there's no way you can break out of that if you missconfigure your .htaccess file! You might get around the mistake, but your users WON'T!

Your final .htaccess should look like this:

@danieldogeanu
danieldogeanu / WampHTTPS.md
Last active April 13, 2024 20:38
How to enable HTTPS for WAMP Server.

After you've downloaded and installed WAMP Server, follow these steps:

  1. Generate SSL certificate using OpenSSL:
  • Add C:\wamp64\bin\apache\apache2.4.27\bin directory to the PATH so you can access openssl command from the command prompt (WAMP comes with its own version of OpenSSL already integrated, so you don't need to install it. You'll find it in this directory.).

    IMPORTANT: Please note that the path of your installation depends on your version of Apache! DO NOT copy and paste the paths presented in this gist as they will not match with yours!

  • Navigate to your user directory (C:\Users\%YOUR_USERNAME%\), create a new folder (.openssl), navigate to it with Powershell and run these commands:

    openssl genrsa -aes256 -out private.key 2048
    

openssl rsa -in private.key -out private.key

@danieldogeanu
danieldogeanu / GitLabCICD.md
Last active October 3, 2019 20:04
Things to remember about GitLab CI/CD config file.
  • You MUST indent lines in the .gitlab-ci.yml file with 2 spaces and NOT TABS! If you don't do this, the GitLab CI/CD pipeline will fail and say there's unknown characters in your file (this is why).