Monday, August 28, 2017

Change the git repository you are working on

When you need to change the git repository you connect to, here is what you can do:

1. See current repository
git remote -v
you will get something like this:
origin  https://github.com/<your-name>/<repo-name>.git (fetch)
origin  https://github.com/<your-name>/<repo-name>.git (push)
2. Remove current repository
git remote rm origin
Optionally you can run the command at step 1, to see you don't have any repository connection.
3. Connect to new repository
git remote add origin https://github.com/<your-name>/<new-repo-name>.git
If the new repository is empty you can push everything:
git push -u origin master
for other things you can execute:
git status
and continue from there.


Monday, August 21, 2017

'git push heroku master' is still asking for authentication

Even if I executed heroku longin and entered username and password, I keep getting failed login error.

When asked for git heroku credentials enter the following:

username: <leave empty>
password: heroku auth token

Note: the heroku auth token can be retrieved using the following command:
heroku auth:token

Source: https://stackoverflow.com/questions/27810419/git-push-heroku-master-is-still-asking-for-authentication

Friday, August 18, 2017

Change Git Username in Terminal

It can happen you do a "git pull" and notice another user account is logged into git.
In this case this is what you can do to change the url, to use your user and continue working:

See current git url:
git config --get remote.origin.url

Change the git url with your user:
git remote set-url origin https://{new url with username replaced}

Source: https://stackoverflow.com/questions/22844806/change-git-username-in-terminal

Error when running webpack

I had the following code:

webpack.config.js
module.exports = {
entry: './public/app.jsx',
output: {
path: __dirname,
filename: './public/bundle.js'
},
resolve: {
extensions: ['','.js','.jsx']
},
module: {
loaders: [
{
loader: 'babel-loader',
query: {
presets: ['react', 'es2015']
},
test: /\.jsx?$/,
exclude: /(node_modules|bower_components)/
}
]
}
};

package.json
{
"name": "hello-react",
"version": "1.0.0",
"description": "Simple react app",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Alina",
"license": "MIT",
"dependencies": {
"express": "^4.15.4",
"react": "^0.14.7",
"react-dom": "^0.14.7"
},
"devDependencies": {
"babel-core": "^6.26.0",
"babel-loader": "^7.1.1",
"babel-preset-es2015": "^6.5.0",
"babel-preset-react": "^6.5.0",
"webpack": "^1.12.13"
}
}


When running webpack in command line I was getting this error

Version: webpack 1.12.13
Time: 1394ms
    + 1 hidden modules

ERROR in ./public/app.jsx
Module build failed: Error: Plugin 19 specified in "D:\\Projects\\HelloReact\\node_modules\\babel-preset-es2015\\index.js" provided an invalid property of "name"
    at Plugin.init (D:\Projects\HelloReact\node_modules\babel-core\lib\transformation\plugin.js:127:13)
    at Function.normalisePlugin (D:\Projects\HelloReact\node_modules\babel-core\lib\transformation\file\options\option-manager.js:176:12)
    at D:\Projects\HelloReact\node_modules\babel-core\lib\transformation\file\options\option-manager.js:210:30
    at Array.map (native)
    at Function.normalisePlugins (D:\Projects\HelloReact\node_modules\babel-core\lib\transformation\file\options\option-manager.js:182:20)
    at OptionManager.mergeOptions (D:\Projects\HelloReact\node_modules\babel-core\lib\transformation\file\options\option-manager.js:298:36)
    at D:\Projects\HelloReact\node_modules\babel-core\lib\transformation\file\options\option-manager.js:370:14
    at D:\Projects\HelloReact\node_modules\babel-core\lib\transformation\file\options\option-manager.js:390:24
    at Array.map (native)
    at OptionManager.resolvePresets (D:\Projects\HelloReact\node_modules\babel-core\lib\transformation\file\options\option-manager.js:385:20)
    at OptionManager.mergePresets (D:\Projects\HelloReact\node_modules\babel-core\lib\transformation\file\options\option-manager.js:369:10)
    at OptionManager.mergeOptions (D:\Projects\HelloReact\node_modules\babel-core\lib\transformation\file\options\option-manager.js:328:14)
    at OptionManager.init (D:\Projects\HelloReact\node_modules\babel-core\lib\transformation\file\options\option-manager.js:481:10)
    at File.initOptions (D:\Projects\HelloReact\node_modules\babel-core\lib\transformation\file\index.js:211:75)
    at new File (D:\Projects\HelloReact\node_modules\babel-core\lib\transformation\file\index.js:129:22)
    at Pipeline.transform (D:\Projects\HelloReact\node_modules\babel-core\lib\transformation\pipeline.js:48:16)
    at transpile (D:\Projects\HelloReact\node_modules\babel-loader\index.js:14:22)
    at Object.module.exports (D:\Projects\HelloReact\node_modules\babel-loader\index.js:88:12)

Solution(that worked for me): Upgrade babel-core and babel-loader

npm install --save babel-core@latest babel-loader@latest

Running webpack went smoothly after that.

Source: https://stackoverflow.com/questions/35395881/plugin-0-specified-in-babel-preset-es2015-provided-an-invalid-property-of-c

Thursday, August 17, 2017

Download certificate from command line using openssl and import it in your JVM truststore

When you need to download a certificate from a site you have 2 options:

1. Hit F12 in Browser and go to Security Tab -> View Certificate and download it from there.
(this option doesn't seem to work every time, because the option to download is disabled)
or,

2. Use openssl
- download and istall openssl (http://gnuwin32.sourceforge.net/packages/openssl.htm)
- add path to environment variables (PATH=C:\Program Files (x86)\GnuWin32\bin)
- open Command Prompt window and run:

openssl s_client -connect HOST:PORT > "C:\Users\...\mycert.cert"

The mycert.cert file will be saved in the specified location.

Then if you want to import this certificate in java trusted store, run the following command:

"<JAVA_HOME>\bin\keytool" -import -v -trustcacerts -alias server-alias -file "C:\Users\...\mycert.cert" -keystore cacerts.jks -keypass changeit -storepass changeit

Note: to find JAVA_HOME run:
echo $JAVA_HOME
on Linux or
echo %JAVA_HOME%
on Windows

Source: https://serverfault.com/questions/139728/how-to-download-the-ssl-certificate-from-a-website
https://stackoverflow.com/questions/2893819/accept-servers-self-signed-ssl-certificate-in-java-client