Skip to content

Instantly share code, notes, and snippets.

View danieldogeanu's full-sized avatar

Daniel Dogeanu danieldogeanu

View GitHub Profile
@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 / 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 / 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).
@danieldogeanu
danieldogeanu / InstallSQLite.md
Last active September 24, 2019 05:06
How to install SQLite 3 on Windows 10.
  1. Go to the SQLite download page;
  2. Under Precompiled Binaries for Windows download sqlite-tools-win32-x86-3290000.zip;
  3. Extract sqlite-tools-win32-x86-3290000.zip on the C:\ drive (it can be in the root of the drive or in a folder without spaces in its name);
  4. Search for "environment variables" in Windows Search and click on Edit the system environment variables;
  5. In the System Properties window click Environment Variables...;
  6. Under System variables select Path and click Edit...;
  7. In the Edit environment variable window, click New and paste the folder location where you extracted sqlite-tools-win32-x86-3290000.zip on the C:\ drive.
  8. Optionally you can rename sqlite3.exe to sqlite.exe, so you can type only sqlite command. Or you can duplicate sqlite3.exe and rename it to sqlite.exe to have access to both versions for compatibility.
@danieldogeanu
danieldogeanu / ListGlobalNPMPackages.md
Created August 5, 2019 19:52
List all global npm packages.

npm list -g --depth 0

@danieldogeanu
danieldogeanu / git checkout-all-branches.sh
Created March 16, 2018 07:23
git checkout-all-branches
#!/bin/bash
#Whenever you clone a repo, you do not clone all of its branches by default.
#If you wish to do so, use the following script:
for branch in `git branch -a | grep remotes | grep -v HEAD | grep -v master `; do
git branch --track ${branch#remotes/origin/} $branch
done
@danieldogeanu
danieldogeanu / MergeBranchToMaster.md
Last active September 1, 2018 01:34
How to merge a branch into master on GitHub/BitBucket.

git checkout master

git pull origin master

git merge yourBranch

git push origin master

@danieldogeanu
danieldogeanu / DeleteBranches.md
Last active September 1, 2018 01:32
How to delete branches from GitHub/BitBucket.
  1. If the branches are only local, you can use -d if the branch has been merged:

    git branch -d branch-name

  2. If the branch contains code you never plan on mergin, use -D instead:

    git branch -D branch-name

  3. If the branch is in the upstream repo you can remove the remote reference by:

Keybase proof

I hereby claim:

  • I am danieldogeanu on github.
  • I am danieldogeanu (https://keybase.io/danieldogeanu) on keybase.
  • I have a public key ASCsAwthxKe2hoVBGnVC4NlpHaz_IBnII0nFe2J-DiHvFwo

To claim this, I am signing this object:

@danieldogeanu
danieldogeanu / FixPathTooLongGradle
Created July 4, 2018 09:40
How to fix Gradle "file path too long" error on Windows 10.
// In the build.gradle file, at the project root, add the `buildDir` with the path to a directory on the root of the drive you are using. For example `D:/Builds/`.
allprojects {
buildDir = "D:/Builds/${rootProject.name}/${project.name}" // Fix for PATH TOO LONG error.
repositories {
jcenter()
}
}