기본 콘텐츠로 건너뛰기

2020의 게시물 표시

Git fetch, pull, merge and reset

GIT FETCH - downloads commits, files, and refs(contents) from a remote repository into your local repo. Fetching is what you do when you want to see what everybody else has been working on. ... but it doesn't force you to actually merge the changes into your repo. Git isolates fetched content as a from existing local content, it has absolutely no effect on your local development work.Fetched content has to be explicitly checked out using the git checkout command. ...it does not update your local repo's working state, leaving your current dwor intact GIT PULL - git pull is more aggressive alternative, it will download the remote content for the active local branch and immediately execute git merge to create a merge commit for the new remote content. GIT MERGE - git merge is used to combine two branches. ...Once git finds a common base commit it will create a new "merge commit" that combines the changes of each queued merge commit sequence. -preparing to merge

When unknown command and Windows Authorization error are kicking your ass : windows

Here is what had happened. I was setting up my new work laptop. I succeeded to clone the remote repository into local. However, the previous employee who used it before me had set his windows user and somehow it seemed loads of environment variables were set to his windows user including nodejs and npm. So I reinstalled nodeJS and made sure that the installing location was set to Program files not to user Appdata. I had no problem to run npm out of his user directory, however I could not fucking run nodemon and didn't know why. After few researches, I figured out that I should have installed nodemon with global option......... npm install -g nodemon If the problem was it, I would have not write this blog post after so long time not bitting my laziness to come back here. Nevertheless of my long journey just to run nodemon instead of moving my project directory into his user file(that felt like being defeated, not sure if it was by his weird userName or myself seekin

Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client

https://www.codementor.io/@oparaprosper79/understanding-node-error-err_http_headers_sent-117mpk82z8 request with no body -> server should send back 400 to client request with body ->  server should send back 200 to client The request handler is simply a javascript anonymous function that takes the req& res arguments. Since this request handler has no explicit command for exiting the function in a situation a request body is not found and the error response is sent back to the client, therefore AFTER THE IF STATEMENT CONDITION has being resolved, the server tries to send ANOTHER RESPONSE to the client and here is when the error comes up Express is attempting to set the response header for this second response, hence the error message shows HOW TO FIX WHEN SENDING 400 ERR RESPONSE, SEND IT AS RETURN (reponse to a request with no body) so that the server sends the correct response and STOP the function execution as necessary.

Linux adding PATH environment variable

We add a new path to the PATH variable using the EXPORT command prerequisite : echo $PATH > a list of saved environment variable be printed... TO APPEND A NEW PATH, WE REASSIGN PATH WITH OUR NEW PATH AT THE END $export PATH=$PATH:/some/new/path source :  https://www.baeldung.com/linux/path-variable .....it kinda failed for my case making it able to run android studio running everywhere i am but i will just leave it like that atm..

Linux : How to copy files in terminal

cp : copy files and directories SYNOPSIS        cp [OPTION]... [-T] SOURCE DEST        cp [OPTION]... SOURCE... DIRECTORY        cp [OPTION]... -t DIRECTORY SOURCE... DESCRIPTION       Copy SOURCE to DEST, or multiple SOURCEs ro DIRECTORY error msg cp: -r not specified; omitting directory 'android-studio' -R, -r, --recursive      copy directories recursively

Linux : How to extract & install tar.gz Files in Ubuntu

1. Download the desired .tar.gz  file 2. Open terminal 3. $tar zxvf PACKAGENAME.tar.gz $tar xvjf PACKAGENAME.tar.bz2 4. navigate to the extracted folder using cd command $cd PACKAGENAME 5. Run the following command to install ./configure make sudo make install Q.tar zxvf A. man tar : an archiving utility -x : Extract files from an archive. Arguments are optional. when give, they specify names of the archive members to be extracted --extract -z : means unzip --gzip -v : means print the file name verbosely -verbose -f : means the following argument is a filename --file source : https://stackoverflow.com/questions/21929223/what-does-zxvf-mean-in-tar-zxvf-filename https://sourcedigit.com/20839-extract-install-tar-gz-files-ubuntu/ man tar

git : fatal: unable to auto-detect email address : HOW TO FIX

STEP1 git config --global -l --show-origin result warning: unable to access '/home/min/.gitconfig': Permission denied warning: unable to access '/home/min/.gitconfig': Permission denied fatal: unable to read config file '/home/min/.gitconfig': Permission denied PERMISSION FUCKING DENIED STEP2 ls -la /home/min this shows the list of directory /home/min ...but then I could finally see where da .gitconfig file is. -rwx--x--x   1 root root    98 Mar  9 17:10 .gitconfig oddly it was owned by user root and group root, let's fix it out and rest of files in /home/min, chown was 711 STEP3 chmod 755 /home/min sudo chown /home/min/.gitconfig min:min $shdo chown USERNAME:GROUPNAME FILENAME.EXTENSION chmod 644 /home/min/.gitconfig PERFECTO

git : configuration file not found...by my eyes

https://git-scm.com/book/en/v2/Customizing-Git-Git-Configuration?fbclid=IwAR0JOZWtTslqD8v-eA9n6pK6u9Gc9eXJMgKPZRskWZZcP3uOgNVlXz8xeUc git configuration file is supposed to be found at followed locations: 1. ~./gitconfig or ~.config/git/config 2. etc.gifconfig 3. .git/config

Linux : directory structure

/ - The Root Directory /bin - Essential User Binaries that must be present when the system is mounted in single-user mode.. sbin is similar /boot - static boot files /etc - Configuration files contains system-wide configuration files. unlikely, user-specific configuration files are located in each user's home directory /home - Home Folders contains a home folder for each user. for example /lib - Essential shared libraries contains libraries needed by the essential binaries in the /bin and /sbin folder. /root - Root home directory is the home directory of the root user. instead of being located at /home/root, its located at /root, this is distinct from /, which is the system root directory. /sbin - System Administration Binaries essential binaries that are generally intended to be run by the root user for system administration. $ dollar sign means that you are a normal user # hash means that you are the system administrator(root) ~ tilde means home d

git : fatal: unable to auto-detect email address

https://stackoverflow.com/questions/25671785/git-fatal-unable-to-auto-detect-email-address/34409245 make..sure you should be in your home directory not in local directory... i never thought that could be the factor... I should be sticking more around documentations. https://git-scm.com/docs/user-manual.html $ means user home directory still not fixed

python : strings enclosed by """

https://www.digitalocean.com/community/tutorials/how-to-format-text-in-python-3 Multiple lines With multiple lines, strings can be grouped into clean and orderly text, formatted as a letter, or used to maintain the linebreaks of a poem or song lyrics with triple quotes, you can print strings on multiple lines to make text, especially lengthy text, easier to read... """ This string is on multiple lines within three double quotes on either side. """

virtualenv : How to set up a virtual environment for python

step 0. be at the directory that you want to set up the env step1. make sure that you have virtualenv installed https://gist.github.com/frfahim/73c0fad6350332cef7a653bcd762f08d step2.  $virtualenv projectName =>this will set up up bin, include, and lib folder in current directory step2-1. $ virtualenv -p python3 . tag -p specifies the specific version of python step3. source projectName/bin/activate => this will activate the env step4. deactivate //to deactivate.... How to delete a virtual environment? $rm -rf projectName

pip [Errno 13] Permission denied:

it seems installing a python package to a system folder is not recommended I think that's how i broke my latest ubuntu linux lol I was doing a lot of random stuff installing python packages on system folder --user https://stackoverflow.com/questions/42988977/what-is-the-purpose-pip-install-user --user makes pip install packages in your home directory instead, which doesn't require any special privileges... resource: https://github.com/googlesamples/assistant-sdk-python/issues/236

port? port? PORT?!

In computer networking, a port is a COMMUNICATION ENDPOINT. At the software level, within an operating system, a port is A LOGICAL CONSTRUCT that identifies a specific process or a type of network service. Ports are identified for each protocol and address combination by 16-bit unsigned numbers, commonly known as the port number. https://en.wikipedia.org/wiki/Port_(computer_networking)

git revert : for the first time in forever

https://www.atlassian.com/git/tutorials/undoing-changes/git-revert omg im so tired now typed $git revert HEAD and some scary nano editor popped up and i do not remember how exactly i managed to escape the editor and made revert done, but i ........donno. now it seems reverting didnt put my web app into previous status but totally broken. let me take some rest and take a careful look into it.....later....

How to set base url when deployed in Heroku? : base url and axios

https://stackoverflow.com/questions/47164330/axios-api-calls-in-heroku/47165888 baseUrl = process.env.baseURL || "http://localhost:5000" Even more stable way https://stackoverflow.com/questions/52129849/how-to-get-the-base-url-variable-on-a-deployed-heroku-node-app const production  = 'https://examplePage.com'; const development = 'http://localhost:3000/'; const url = (process.env.NODE_ENV ? production : development); process.env.NODE_ENV will resolve to undefined if you are running on localhost production mode. and return production if you have deployed the app production mode.

What is process.env?

the process.env global variable is injected by the Node at runtime for your application to use and it represents the state of the system environment your application is in when it starts. https://codeburst.io/process-env-what-it-is-and-why-when-how-to-use-it-effectively-505d0b2831e7

Heroku : at=error code=H10 desc="App crashed" method=GET path="/" : GREATEST POST EVER IN THIS MONTH

https://dev.to/lawrenceagles/causes-of-heroku-h10-app-crashed-error-and-how-to-solve-them-3jnl i got into this bug and hadn't find a way to go out, the reason was that i made a typo which my tutorial alerted me to take care already lol.. anyways. guys let's stay awake.... DO NOT MAKE A SPACE WITHOUT ENOUGH CARE Wrong:  web : node index.js Correct  web:node index.js

Heroku : npm ERR! code EEXIST

resource https://stackoverflow.com/questions/46541371/npm-err-refusing-to-delete-code-eexist log messeges npm ERR! Refusing to delete /tmp/build_1d08d29a9c9a463668992db197c02ec0/client/node_modules/.bin/jest: ../jest-cli/bin/jest.js symlink target is not controlled by npm solution : since Heroku could not delete the file which was not supposed to be existing, delete the node_modules and run heroku again andnnndd you maayyy want to delete package-lock json as well.. and heroku will be installing node modules when running.....

Heroku code H10 & H81 : Blank app

this error means NO CODE HAS BEEN PUSHED TO THIS APPLICATION. it means that all those times that I pushed the code by $git push heroku anotherbranchname has not been working as I meant. Besides, when pushing code to heroku, the comment must be looking like this $git push heroku master as the document says, "Note that Heroku only deploys code that you push to the master branch of the heroku remote. PUSHING CODE TO ANOTHER BRANCH OF THE REMOTE HAS NO EFFECT. **Deploying from a branch besides master $git push heroku testbranch:master resources: https://devcenter.heroku.com/articles/error-codes#h81-blank-app https://devcenter.heroku.com/articles/git#deploying-code

Node.js Module : what is node_modules folder?

https://stackoverflow.com/questions/34526844/what-is-node-modules-directory-in-angularjs npm is the node package manager, which installs packages locally into a project, speficifally, into the node-modules folder. from there the package code can be included into a project *official document https://www.tutorialsteacher.com/nodejs/what-is-nodejs Node.js is an open source server side runtime environment built on Chrome engine. Node.js can be used to build different types of applications such as command line application, web application, real-time application, ..etc.. However, it is mainly used to build network programs like web servers, similar to PHP, Java, or ASP.NET *NODE.JS MODULE Module in Node.js is a simple or complex functionality organized in single or multiple JS files which can be reused throughout the Node.js application. *Node.js module types 1.core Modules 2.Local Modules - in order to use Node.js core or NPM modules, YOU FIRST NEED TO IMPORT IT USING REQU

Git undoings : git reset

for this undo strategy we will continue with our working example. git reset is an extensive command with multiple uses and functions. if we invoke get reset --hard "commit code", THE COMMIT HISTORY IS RESET TO THAT SPECIFIED COMMIT. https://www.atlassian.com/git/tutorials/undoing-changes

Git undoings : checkout / viewing an old revision

https://www.atlassian.com/git/tutorials/undoing-changes git log (--oneline) you can view all commits across all branches by executing $git log --branches=* to view specific branch's commits $git log <branch_name> UNDOING A COMMITED SNAPSHOT being in a detached HEAD state $git checkout "commit code" this makes your working directory match the exact state of the specified commit.

Git revert : undoing?

The git revert command can be considered an 'undo' type command, however, it is not a traditional undo operation. instead of removing the commit from the project, it figures out how to invert the changes introduced by the commit and appends a new commit with the resulting inverse content. Reverting should be used when you want to apply the inverse of a commit from your project history. This can be useful, for example, if you are tracking down a bug and find that it was introduced by a single commit. and commiting a new snapshot, you can use git revert to automatically do all of this for you. invert: put upside down or in the opposite position, order, or arrangement inverse: opposite or contrary in position, direction, order, or effect. resource : https://www.atlassian.com/git/tutorials/undoing-changes/git-revert

Tracked and untracked file

Remember that each file in your working directory can be in one of two states : TRACKED OR UNTRACKED. tracked files are files that WERE IN THE LAST SNAPSHOT; they can be unmodified, modified, or staged. in short, tracked files are files that Git knows about. Untracked files are everything else - any files in your working directory THAT WERE NOT IN YOUR LAST SNAPSHOT AND ARE NOT IN YOUR STAGING AREA. When you first clone a repository, all of your files will be tracked and unmodified because Git just checked them out and you haven't edited anything.

Git Branching - Basic Branching and Merging

https://git-scm.com/book/en/v2/Git-Branching-Basic-Branching-and-Merging note that if your working directory or staging area has uncommitted changes that conflict with the branch you are checking out, GIT WON'T LET YOU SWITCH BRANCHES. IT'S BEST TO HAVE A CLEAN WORKING STATE WHEN YOU SWITCH BRANCHES. when you switch branches, Git resets your working directory to look like it did the last time you committed on that branch.

npm install and about package

npm install installs a package, and any packages that it depends on. A package is: a) a folder containing a program described by a package.json file b) a gzipped tarball containing (a) c) a url that resolves to (b) d) a <name>@<version> that is published on the registry (see npm-registry) with (c) e) a <name>@<tag> (see npm-dist-tag) that points to (d) f) a <name> that has a “latest” tag satisfying (e) g) a <git remote url> that resolves to (a) npm install (in package directory, no arguments) install the dependencies in the local node_nodules folder By default, npm install will install all modules listed as dependencies in package.json https://docs.npmjs.com/cli/install

What is 'package.json' file? and when is it created?

https://nodejs.org/en/knowledge/getting-started/npm/what-is-the-file-package-json/ All npm packages contain a file, usually in the project root, called package.json this file holds various meta data relevant to the project. this file is used to give information to npm that allows it to identify the project as well as handel the project's dependencies. WHEN AND HOW IS IT CREATED? https://docs.npmjs.com/cli/init npm-init creates 'package.json' file. *ADDITIONAL INFO - NPX * npm init <initializer>  can be used to set up a new or existing npm package. initializer  in this case is an npm package named  create-<initializer> , which will be installed by  npx , and then have its main bin executed – presumably creating or updating  package.json  and running any other initialization-related operations. The init command is transformed to a corresponding  npx  operation as follows: npm init foo  ->  npx create-foo npm init @usr/foo  ->  npx @us

How to commit to anther branch?

I got to have this message when I made commits but have not pushed to remote branch Your branch is ahead of 'origin/master' by 2 commits' However, I did not want to push the commits on master, but to another one called "buildtest" https://stackoverflow.com/questions/13897717/push-commits-to-another-branch/13897766 $ git push origin master:buildtest this line did the work as I wished it to be :)

What is it on index.js file? : ReactDOM.render()

https://reactjs.org/docs/react-dom.html#render ReactDOM.render(element, container[, callback]) Render a React element into the DOM in the supplied container and return a reference to the component(or returns null for stateless components) if the React element was previously rendered into container, this iwll perfomr an update on it and only mutate the DOM as necessary to reflect the latest React element..? ex) ReactDOM.render(<App />, document.getElementbyIdD("potato")); element to render is <App />(App.js), the container is potato. potato is name of the div. it is a container that I wish the blocks of elements to be filled with in index.html.

Select lines and display : sed

sed : stream editor for filtering and transforming text. -n : SUPPRESS automatic PRINTING of pattern space p : print current line n : next line 'n;p' : keep odd ones 'p;n' : keep even ones https://stackoverflow.com/questions/21309020/remove-odd-or-even-lines-from-a-text-file

Let's be friends with sed

https://stackoverflow.com/questions/7657647/combining-two-sed-commands sed - stream editor for filtering and transforming text Sed is a stream editor. input and output file can be specified as follow sed "s/regexp/replacement/g" inputfile > outputfile flag -i is used to save the stream output in the input file. then specified output file argument is ignored and the change will be saved in the input file g to replace as many times as the pattern is detected more than once per each line without it, sed does the replacement for the first pattern detected by each line. CHAINING SED / COMBINING SED https://stackoverflow.com/questions/7657647/combining-two-sed-commands sed is a scripting language. you can separate commands with semicolon or newline ex $sed -i 's/File//g;s/MINvac\.pdb//g' filessldkjaginadkljef

Veritas vos liberabit : so will Linux, $PATH

https://linuxize.com/post/how-to-add-directory-to-path-in-linux/ at the end of .bashrc file, add  export PATH="$HOME/dirName:$PATH" to permanently save the change, run as followed $ source ~/.bashrc to confirm the change $echo $PATH I remember all those moments that this PATH problems caught on my feet and wasted so many time. Veritas vos liberabit Staying awake frees you from agonies and pains

cut and head to deal with csv files : How to separate specific column and get the data wanted?

https://stackoverflow.com/questions/47638184/can-i-use-grep-to-extract-a-single-column-of-a-csv-file How to separate specific column and get the data wanted? cut : remove sections from each lines of files ALSO CAN USED TO SEPARATE COLUMNS USING ; AS DELIMITER cut -d';' -f3 ;  separate dates by ; => -d';', and select only 3rd group => -f3

What is mongoDB dbpath?

Where is the database folder? - You should be able to find the location in the configuration file : /etc/mongod.conf grep dbPath /etc/mongod/conf grep??? -grep searches for PATTERNS in  each FILE. PATTERNS is one or patterns separated by newline charactors, and grep prints each line that matches a pattern. If the default path is not given, mongo saves the data in the root directory as printed when grep dbPath /etc/mongodb/conf shows :  dbPath: /var/lib/mongodb otherwise, I can set a default path to save the data. from Mongodb : If you want  mongod  to store data files at a path other than  /data/db  you can specify a  dbPath . The  dbPath  must exist before you start  mongod . If it does not exist, create the directory and the permissions so that  mongod  can read and write data to this path. For more information on permissions, see the security operations documentation. source :  https://askubuntu.com/questions/982673/where-is-mongo-database-folder-on-the-

Debugging guide : commenting and logging steps

1. Check any possible typos 2. Calm down and read the code   comment every code step by step 3. Debugging. go back to step 2 till you figure the matter out   keep searching while looping step 2 and 3 I code to be into it not to be mat at it HAPPY CODING! app . post ( '/meower' , ( req , res )  =>  {    console . log ( '1. POST /mews request' );    if ( isValidMew ( req . body )) {      console . log ( '2.A. Body is valid' );      const   mew  = {        name:   req . body . name . toString ,        content:   req . body . content . toString ,        created:   new   Date (),     };      mews       . insert ( mew )       . then ( createdMew   =>  {          console . log ( '3.A Mew has been created' );          console . log ( createdMew );          //TODO       })       . catch ( err   =>  {          console . log ( '3.B Mew creation has failed' );          console . log ( err )       })

COR error : Cross Origin Resource

Access to fetch at 'http://localhost:5000/mews' from origin 'http://127.0.0.1:8080' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled. shows up when the ogirin resource localhost:8080 is trying to fetch data to localhost 5000 without this Access-Control-Allow-Origin header. in this project we will be using a package to prevent this error on server side.

Why do I need initialize an empty array attribute of datamodel?

https://moonformeli.tistory.com/3 export   default   class   GiftList   extends   Component  {      constructor ( props ){          super ( props );          //what is this for??          this . state  = { gifts:  []};     } } //the answer is in the link, have fun!

non-editable input type="text'?!

Yes. i am still working on that MERN stack project like since forever and i am not ashamed of it! However however, I found an error, from one of the pages, i could not edit the input text. and it was because I set the onChange function in a wrong way. < div   className = "form-group" >                          < label > Gift Name: </ label >                          < input   type = "text"                          required                          className = "form-control"                          value = {this . state . gift  ||  "" }                          onChange = {this . onChangeGift }                          //setting on change to be                          //onChange={this.state.onChangeGift}                          //prevents editing from user                          />                      </ div > So, since onChange function is already bind to the state, I mean t

mongoDB error : "Error: MongoError: E11000 duplicate key error collection: test.santas index: username_1 dup key: { username: null }"

https://www.freecodecamp.org/forum/t/mongoerror-e11000-duplicate-key-error-collection-timeformationbd-formations-index-description-1-dup-key-null/212336 I was working on this santa helena website. today I was building the components, creating a page for creating new santa. But adding new santa made an error and there above was the error message and how I got to solve it. I don't yet really get what was wrong with my very first collection. maybe there must be some difference with those ones which can be created by my page, cuz the first one was made by Insomnia the API testing program. ------update still getting errors. its weird that the data model for santa, the one that i modeled after has unique attribute but still works well. https://stackoverflow.com/questions/57507314/i-am-getting-this-mongo-error-e11000-duplicate-key-error-collection-21day-cha

[ReactJS]Module not found: Can't resolve 'react-router-dom'

The error message "Module not found: Can't resolve 'react-router-dom'" would show up when the project does not have the package 'react-router-dom' as dependencies in your package.json file or whatever the equivalent you use to manage the dependencies in your project that could be solve as typing the following line in terminal, at your project directory  (if using yarn, do yarn install react-router-dom) npm i -S react-router-dom