├── tailwind └── extensions_for_tailwind.md ├── laravel ├── dynamic_nav.md ├── .htaccess.php ├── extensions_for_laravel.md ├── resource_route_intregation.md ├── summernote_cdn_links.php ├── how_to_clone_a_laravel_project_from_github.md ├── text_editor_image_delete.php ├── text_editor_image_upload.php ├── ajax.php ├── password_or_image_update_code.md └── text_editor_image_update.md ├── netlify.md ├── JavaScript ├── extensions_for_js_and_js_frameworks.md ├── netlify_redirect_issue.md └── reactFormValidation.md ├── README.md ├── activator.md ├── vue ├── logout.md ├── axios_api_post.md ├── mounted.md ├── router_code.md ├── formvalidation.md └── ticket_system_script.md ├── vs code ├── important_extensions_for_vscode.md ├── my-snippets.md └── my_setting_vs_code.md ├── vercel.md ├── css └── cssreset.md └── git&github.md /tailwind/extensions_for_tailwind.md: -------------------------------------------------------------------------------- 1 | ## Name Of Extensions 2 | 3 | 1. Tailwind CSS IntelliSense 4 | 2. Tailwind Documentation 5 | 3. Headwind 6 | -------------------------------------------------------------------------------- /laravel/dynamic_nav.md: -------------------------------------------------------------------------------- 1 | ### Dynamic Navbar 2 | 3 | ``` laravel 4 | {{ (\Request::route()->getName() == 'profile.index') ? 'active' : '' }} 5 | 6 | ``` 7 | -------------------------------------------------------------------------------- /netlify.md: -------------------------------------------------------------------------------- 1 | ### Create a _redirects file in your project public folder and paste this code 2 | 3 | ``` html 4 | /* /index.html 200 5 | ``` 6 | -------------------------------------------------------------------------------- /JavaScript/extensions_for_js_and_js_frameworks.md: -------------------------------------------------------------------------------- 1 | ## Name Of Extensions 2 | 3 | 1. ES7+ React/Redux/React-Native snippets 4 | 2. JavaScript (ES6) code snippets 5 | 3. Template String Converter 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # lifesaver 2 | Important Code Snippets 3 | 4 | ` In this repo you will find all the important code, files, extension names, and many other things, so save it quickly and give a star to this repo ` 5 | -------------------------------------------------------------------------------- /JavaScript/netlify_redirect_issue.md: -------------------------------------------------------------------------------- 1 | ## netlify redirect issue solved 2 | 3 | # create a file in the public folder. the folder name should be `_redirects` 4 | 5 | # After creating the file just paste this `/* /index.html 200` in the file 6 | -------------------------------------------------------------------------------- /activator.md: -------------------------------------------------------------------------------- 1 | ### Microsoft Windows 10 pro Activator 2 | ``` 3 | irm https://get.activated.win | iex 4 | ``` 5 | 6 | ### IDM Activator 7 | ``` 8 | irm https://massgrave.dev/ias | iex 9 | ``` 10 | 11 | ## use powershell to run this code. 12 | -------------------------------------------------------------------------------- /vue/logout.md: -------------------------------------------------------------------------------- 1 | ### This file is for logout on localstorage 2 | 3 | ``` vue 4 | 5 | logout() { 6 | localStorage.removeItem('users') 7 | this.$router.push({ 8 | name: "Login" 9 | }) 10 | } 11 | 12 | ``` -------------------------------------------------------------------------------- /laravel/.htaccess.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | RewriteEngine on 4 | RewriteCond %{REQUEST_FILENAME} !-f 5 | RewriteRule ^(.*)$ public/$1 [L] 6 | 7 | 8 | 9 | Order allow,deny 10 | Deny from all 11 | 12 | 13 | 14 | Order allow,deny 15 | Deny from all 16 | -------------------------------------------------------------------------------- /vs code/important_extensions_for_vscode.md: -------------------------------------------------------------------------------- 1 | ## Name Of Extensions 2 | 3 | 1. Auto Close Tag 4 | 2. Auto Rename Tag 5 | 3. Code Runner 6 | 4. Code Spell Checker 7 | 5. CodeSnap 8 | 6. CSS Formatter 9 | 7. css-auto-prefix 10 | 8. Figma for VS Code 11 | 9. GitLens — Git supercharged 12 | 10. HTML CSS Support 13 | 11. Prettier - Code formatter 14 | 12. Project Manager 15 | 13. vscode-icons 16 | 14. DotENV 17 | -------------------------------------------------------------------------------- /laravel/extensions_for_laravel.md: -------------------------------------------------------------------------------- 1 | ## Name Of Extensions 2 | 3 | 1. PHP Intelephense 4 | 2. laravel-jump-controller 5 | 3. laravel-goto-components 6 | 4. Laravel Snippets 7 | 5. Laravel goto view 8 | 6. Laravel Extra Intellisense 9 | 7. Laravel Extension Pack 10 | 8. Laravel Create View 11 | 9. Laravel Blade Wrapper 12 | 10. Laravel Blade Spacer 13 | 11. Laravel Blade Snippets 14 | 12. Laravel Blade formatter 15 | 13. Laravel Artisan 16 | 14. DotENV 17 | -------------------------------------------------------------------------------- /vercel.md: -------------------------------------------------------------------------------- 1 | ### Create a vercel.json file and paste this code 2 | 3 | ``` json 4 | { 5 | "version": 2, 6 | "builds": [ 7 | { 8 | "src": "index.js", 9 | "use": "@vercel/node" 10 | } 11 | ], 12 | "routes": [ 13 | { 14 | "src": "/(.*)", 15 | "dest": "index.js" 16 | } 17 | ] 18 | } 19 | ``` 20 | 21 | ### Create a vercel.json file and paste this code for the 404 error 22 | 23 | ``` json 24 | { "rewrites": [{ "source": "/(.*)", "destination": "/" }] } 25 | ``` 26 | -------------------------------------------------------------------------------- /vue/axios_api_post.md: -------------------------------------------------------------------------------- 1 | #### This file is for how to post data with API Axios 2 | 3 | ``` vue 4 | 5 | let submit = await axios.post('http://localhost:3000/users',{ 6 | 'name' : this.name, 7 | 'email' : this.email, 8 | 'password' : this.password 9 | }); 10 | if(submit.status == 201){ 11 | localStorage.setItem('user-info',JSON.stringify(submit.data)) 12 | alert('information submit successfull') 13 | this.$router.push({ name : "Home" }); 14 | }else{ 15 | alert('information submit unsuccessfull') 16 | } 17 | 18 | ``` -------------------------------------------------------------------------------- /laravel/resource_route_intregation.md: -------------------------------------------------------------------------------- 1 | ### Defining Resource Routes 2 | 3 | > Resource routes in Laravel are defined using the Route::resource method. 4 | 5 | ``` 6 | Route::resource('posts', PostController::class); 7 | 8 | ``` 9 | 10 | ### Here is the ex: how to work resourcefull controller methods -> 11 | 12 | ``` 13 | 'index' => 'posts.list', 14 | 'show' => 'posts.view', 15 | 'create' => 'posts.add', 16 | 'edit' => 'posts.edit', 17 | 'update' => 'posts.update', 18 | 'store' => 'posts.save', 19 | 'destroy' => 'posts.delete', 20 | 21 | ``` -------------------------------------------------------------------------------- /vue/mounted.md: -------------------------------------------------------------------------------- 1 | ### This file is for mounted localstorage 2 | 3 | ``` vue 4 | 5 | #### How to store data in localstorage 6 | 7 | if(submit.status == 201){ 8 | localStorage.setItem('user-info',JSON.stringify(submit.data)) 9 | alert('information submit successfull') 10 | this.$router.push({ name : "Home" }); 11 | }else{ 12 | alert('information submit unsuccessfull') 13 | } 14 | 15 | #### How to get data in localstorage 16 | 17 | let user = localStorage.getItem('user-info') 18 | 19 | let selectAuth = JSON.parse(localStorage.getItem('users')) 20 | this.authuser = selectAuth.name // here this.authuser is blank array where i push get item data 21 | 22 | 23 | ``` -------------------------------------------------------------------------------- /laravel/summernote_cdn_links.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /laravel/how_to_clone_a_laravel_project_from_github.md: -------------------------------------------------------------------------------- 1 | ## How to clone a LARAVEL project 2 | 3 | 1. Go to the folder application using the `cd [your project name]` command on your cmd or terminal or git 4 | 2. Run `composer install` on your cmd or terminal or git 5 | 3. Copy **_.env.example_** file to **_.env_** on the root folder. You can type `copy .env.example .env` if using the command prompt Windows or `cp .env.example .env` if using 6 | the terminal, Ubuntu 7 | 4. Open your **.env** file and change the database name **\*(DB_DATABASE)** to whatever you have, username 8 | **_(DB_USERNAME)_** and password **_(DB_PASSWORD)_** field correspond to your configuration. 9 | 5. Run `php artisan key:generate` 10 | 6. Run `php artisan migrate` 11 | 7. Run `php artisan serve` 12 | 8. Go to `[php artisan serve](http://localhost:8000/)` 13 | -------------------------------------------------------------------------------- /css/cssreset.md: -------------------------------------------------------------------------------- 1 | ``` CSS 2 | *, 3 | *::before, 4 | *::after { 5 | padding: 0; 6 | margin: 0; 7 | } 8 | 9 | q:before, 10 | q:after { 11 | content: ""; 12 | } 13 | 14 | html, 15 | body, 16 | h1, 17 | h2, 18 | h3, 19 | h4, 20 | p, 21 | ol, 22 | ul, 23 | li, 24 | figure, 25 | figcaption, 26 | blockquote, 27 | dl, 28 | dd { 29 | margin: 0; 30 | padding: 0; 31 | } 32 | 33 | html:focus-within { 34 | scroll-behavior: smooth; 35 | } 36 | 37 | body { 38 | min-height: 100vh; 39 | text-rendering: optimizeSpeed; 40 | line-height: 1.5; 41 | } 42 | 43 | ul, 44 | ol { 45 | list-style: none; 46 | } 47 | 48 | a { 49 | text-decoration: none; 50 | } 51 | 52 | img { 53 | max-width: 100%; 54 | display: block; 55 | } 56 | 57 | input, 58 | button, 59 | textarea, 60 | select { 61 | font: inherit; 62 | /* margin */ 63 | } 64 | ``` 65 | -------------------------------------------------------------------------------- /laravel/text_editor_image_delete.php: -------------------------------------------------------------------------------- 1 | find($post); 4 | unlink(base_path('public/uploads/post_thumbnail/' . $post_data->post_thumbnail)); 5 | $post_description = $post_data->post_description; 6 | libxml_use_internal_errors(true); 7 | $dom = new \DomDocument(); 8 | $dom->loadHtml('' . $post_description, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD); // must include this to avoid font problem 9 | $images = $dom->getElementsByTagName('img'); 10 | if (count($images) > 0) { 11 | foreach ($images as $img) { 12 | $src = $img->getAttribute('src'); 13 | $filename = last(explode("/", $src)); 14 | unlink(base_path('public/uploads/post_thumbnail/' . $filename)); 15 | # if the img source is 'data-url' 16 | if (preg_match('/data:image/', $src)) { 17 | unlink(base_path('public/uploads/post_thumbnail/' . $filename)); 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /vue/router_code.md: -------------------------------------------------------------------------------- 1 | ### This File is show how to create vue router file 2 | 3 | #### Also Here we see that how to make 404 page 4 | 5 | ``` vue 6 | import { createWebHistory,createRouter } from "vue-router"; 7 | import Home from "./components/Home.vue"; 8 | import signUp from "./components/signUp.vue"; 9 | import nopage from "./components/404.vue"; 10 | import Login from "./components/Login.vue"; 11 | import ShowList from "./components/ShowList.vue"; 12 | 13 | const routes = [ 14 | { 15 | name : "signUp", 16 | path:'/', 17 | component: signUp 18 | }, 19 | { 20 | name: "Home", 21 | path:'/home', 22 | component: Home 23 | }, 24 | { 25 | name: "404", 26 | path:'/:PathMatch(.*)*', 27 | component: nopage 28 | }, 29 | { 30 | name: "Login", 31 | path:'/login', 32 | component: Login 33 | }, 34 | { 35 | name: "ShowList", 36 | path:'/list', 37 | component: ShowList 38 | }, 39 | ]; 40 | 41 | const router = createRouter({ 42 | history:createWebHistory(), 43 | routes 44 | }); 45 | 46 | export default router; 47 | 48 | ``` -------------------------------------------------------------------------------- /vs code/my-snippets.md: -------------------------------------------------------------------------------- 1 | ``` js 2 | { 3 | "React TypeScript Component With Interface": { 4 | "prefix": "mrfi", 5 | "body": [ 6 | "import { FC, ReactNode } from 'react';", 7 | "", 8 | "interface ${TM_FILENAME_BASE}Props {", 9 | " children?: ReactNode;", 10 | "}", 11 | "", 12 | "const ${TM_FILENAME_BASE}: FC<${TM_FILENAME_BASE}Props> = ({ children }) => {", 13 | " return (", 14 | "
", 15 | " {children}", 16 | "
", 17 | " );", 18 | "};", 19 | "", 20 | "export default ${TM_FILENAME_BASE};" 21 | ], 22 | "description": "Creates a React TypeScript functional component with children support and the filename as the component name." 23 | }, 24 | "React TypeScript Component": { 25 | "prefix": "mrfc", 26 | "body": [ 27 | "import { FC } from 'react';", 28 | "", 29 | "const ${TM_FILENAME_BASE}: FC = () => {", 30 | " return (", 31 | "
${TM_FILENAME_BASE}
", 32 | " );", 33 | "};", 34 | "", 35 | "export default ${TM_FILENAME_BASE};" 36 | ], 37 | "description": "Creates a React TypeScript functional component with the filename as the component name." 38 | } 39 | } 40 | ``` 41 | -------------------------------------------------------------------------------- /laravel/text_editor_image_upload.php: -------------------------------------------------------------------------------- 1 | post_description; 4 | libxml_use_internal_errors(true); 5 | $dom = new \DomDocument(); 6 | $dom->loadHtml('' . $post_description, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD); // must include this to avoid font problem 7 | $images = $dom->getElementsByTagName('img'); 8 | if (count($images) > 0) { 9 | foreach ($images as $img) { 10 | $src = $img->getAttribute('src'); 11 | # if the img source is 'data-url' 12 | if (preg_match('/data:image/', $src)) { 13 | # get the mimetype 14 | preg_match('/data:image\/(?.*?)\;/', $src, $groups); 15 | $mimetype = $groups['mime']; 16 | # Generating a random filename 17 | $filename = 18 | Str::limit($slug, 5) . '_' . Auth::guard('admin')->id() . '_' . time() . 19 | Str::random(8) . '_' . Carbon::now()->format('Y'); 20 | $filepath = "uploads/post_thumbnail/$filename.$mimetype"; 21 | $image = Image::make($src) 22 | ->encode($mimetype, 100) 23 | ->save(public_path($filepath), 80); 24 | $new_src = asset($filepath); 25 | $img->removeAttribute('src'); 26 | $img->setAttribute('src', $new_src); 27 | } 28 | } 29 | } 30 | # modified entity ready to store in database 31 | $post_description = $dom->saveHTML(); -------------------------------------------------------------------------------- /laravel/ajax.php: -------------------------------------------------------------------------------- 1 | 2 | 27 | 28 | 29 | category_id; 34 | $sub_categories_lists = SubCategory::where('category_id', $category_id)->get(); 35 | $subCategoryName = ''; 36 | foreach ($sub_categories_lists as $sub_category_list) { 37 | $subCategoryName .= ""; 38 | } 39 | return $subCategoryName; 40 | } -------------------------------------------------------------------------------- /vue/formvalidation.md: -------------------------------------------------------------------------------- 1 | ### this file is for validation 2 | 3 | ``` vue 4 | login() { 5 | if (this.email === "" || this.password === "") { 6 | this.errors.nameError = "name value is null" 7 | this.errors.emailError = "email value is null" 8 | this.errors.passwordError = "password value is null" 9 | } else { 10 | if (this.email === "") { 11 | this.errors.emailError = "email value is null" 12 | } else if (this.password === "") { 13 | this.errors.passwordError = "password value is null" 14 | } else { 15 | let getValue = localStorage.getItem('users') 16 | if (getValue) { 17 | let getData = JSON.parse(localStorage.getItem('users')) 18 | if (this.email !== getData.email || this.password !== getData.password) { 19 | alert('your given credentials did not matched!') 20 | console.log('your given credentials did not matched!'); 21 | } else { 22 | this.$router.push({ 23 | name: "Ticket" 24 | }) 25 | } 26 | } else { 27 | alert('your given credentials did not matched!') 28 | console.log('your given credentials did not matched!'); 29 | } 30 | } 31 | } 32 | } 33 | 34 | ``` -------------------------------------------------------------------------------- /laravel/password_or_image_update_code.md: -------------------------------------------------------------------------------- 1 | ### This README file for Check Password or Image Update Code 2 | 3 | ``` laravel 4 | 5 | public function password_update(Request $request){ 6 | $request->validate([ 7 | 'current_password' => 'required', 8 | 'password' => 'required|confirmed|min:8', 9 | ]); 10 | 11 | if(Hash::check($request->current_password , auth()->user()->password)){ 12 | User::find(auth()->id())->update([ 13 | 'password' => $request->password, 14 | 'created_at' => now(), 15 | ]); 16 | return back()->with('password_updated','password update successfull'); 17 | }else{ 18 | return back()->with('password_updated_error','your given current password cannot match with DATABASE'); 19 | } 20 | 21 | } 22 | 23 | public function image_update(Request $request){ 24 | 25 | $request->validate([ 26 | 'image' => 'required|image', 27 | ]); 28 | 29 | if($request->hasFile('image')){ 30 | if(auth()->user()->image != "default.png"){ 31 | unlink(public_path('uploads/profile/'. auth()->user()->image)); 32 | $new_name = auth()->id().'-'.auth()->user()->name.'-'.now()->format('d-m-Y').'.'.$request->file('image')->getClientOriginalExtension(); 33 | $img = Image::make($request->file('image'))->resize(300, 200); 34 | $img->save(base_path('public/uploads/profile/'.$new_name), 80); 35 | 36 | User::findOrFail(auth()->id())->update([ 37 | 'image' => $new_name, 38 | 'created_at' => now(), 39 | ]); 40 | 41 | return back(); 42 | 43 | }else{ 44 | $new_name = auth()->id().'-'.auth()->user()->name.'-'.now()->format('d-m-Y').'.'.$request->file('image')->getClientOriginalExtension(); 45 | $img = Image::make($request->file('image'))->resize(300, 200); 46 | $img->save(base_path('public/uploads/profile/'.$new_name), 80); 47 | 48 | User::findOrFail(auth()->id())->update([ 49 | 'image' => $new_name, 50 | 'created_at' => now(), 51 | ]); 52 | 53 | return back()->with('image_updated','image update successfull'); 54 | 55 | } 56 | } 57 | 58 | } 59 | 60 | ``` -------------------------------------------------------------------------------- /laravel/text_editor_image_update.md: -------------------------------------------------------------------------------- 1 | ### text editor update 2 | 3 | `$post_description = $request->post_description; 4 | $old_post_description = $post->post_description; 5 | if ($old_post_description !== $post_description) { 6 | libxml_use_internal_errors(true); 7 | $dom = new \DomDocument(); 8 | $dom->loadHtml('' . $post_description, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD); // must include this to avoid font problem 9 | $images = $dom->getElementsByTagName('img'); 10 | if (count($images) > 0) { 11 | foreach ($images as $img) { 12 | $src = $img->getAttribute('src'); 13 | if (!preg_match('/data:image/', $src)) { 14 | $filename = last(explode("/", $src)); 15 | $oldfile = "uploads/post_thumbnail/$filename"; 16 | $mimetype = last(explode(".", $src)); 17 | $newFilename = 18 | Str::limit($slug, 5) . '_' . Auth::guard('admin')->id() . '_' . time() . 19 | Str::random(8) . '_' . Carbon::now()->format('Y'); 20 | $filepath = "uploads/post_thumbnail/$newFilename.$mimetype"; 21 | copy($oldfile, $filepath); 22 | unlink(base_path("public/" . $oldfile)); 23 | $new_src = asset($filepath); 24 | $img->removeAttribute('src'); 25 | $img->setAttribute('src', $new_src); 26 | } 27 | # if the img source is 'data-url' 28 | if (preg_match('/data:image/', $src)) { 29 | # get the mimetype 30 | preg_match('/data:image\/(?.*?)\;/', $src, $groups); 31 | $mimetype = $groups['mime']; 32 | # Generating a random filename 33 | $filename = 34 | Str::limit($slug, 5) . '_' . Auth::guard('admin')->id() . '_' . time() . 35 | Str::random(8) . '_' . Carbon::now()->format('Y'); 36 | $filepath = "uploads/post_thumbnail/$filename.$mimetype"; 37 | $image = Image::make($src) 38 | ->encode($mimetype, 100) 39 | ->save(public_path($filepath), 80); 40 | $new_src = asset($filepath); 41 | $img->removeAttribute('src'); 42 | $img->setAttribute('src', $new_src); 43 | } 44 | } 45 | } 46 | # modified entity ready to store in database 47 | $post_description = $dom->saveHTML(); 48 | $post->update([ 49 | "post_description" => null, 50 | ]); 51 | $post->update([ 52 | "post_description" => $post_description, 53 | ]); 54 | }` 55 | -------------------------------------------------------------------------------- /vs code/my_setting_vs_code.md: -------------------------------------------------------------------------------- 1 | ## vs code json file 2 | 3 | ``` json 4 | { 5 | // editor 6 | "editor.quickSuggestions": { 7 | "strings": "on" 8 | }, 9 | "editor.fontSize": 16, 10 | "editor.fontFamily": "Fira Code, Operator Mono", 11 | "editor.fontLigatures": true, 12 | "editor.wordWrap": "on", 13 | "editor.tokenColorCustomizations": { 14 | "textMateRules": [ 15 | { 16 | "scope": "comment", 17 | "settings": { 18 | "fontStyle": "italic" 19 | } 20 | } 21 | ] 22 | }, 23 | // cursor 24 | "editor.cursorSmoothCaretAnimation": "on", 25 | // config related to code formatting 26 | "editor.defaultFormatter": "esbenp.prettier-vscode", 27 | "editor.formatOnSave": true, 28 | "[javascript]": { 29 | "editor.formatOnSave": false, 30 | "editor.defaultFormatter": "esbenp.prettier-vscode" 31 | }, 32 | "[javascriptreact]": { 33 | "editor.formatOnSave": false, 34 | "editor.defaultFormatter": "esbenp.prettier-vscode" 35 | }, 36 | "editor.codeActionsOnSave": { 37 | "source.fixAll.eslint": "explicit", 38 | "source.fixAll.tslint": "explicit", 39 | "source.organizeImports": "explicit" 40 | }, 41 | "eslint.alwaysShowStatus": true, 42 | //terminal 43 | "terminal.integrated.fontSize": 16, 44 | "terminal.integrated.fontWeight": "normal", 45 | "terminal.integrated.fontFamily": "Fira Code", 46 | "terminal.external.osxExec": "warp.app", 47 | "terminal.external.windowsExec": "C:\\Windows\\System32\\cmd.exe", 48 | "terminal.integrated.defaultProfile.windows": "Git Bash", 49 | // terminal customization 50 | "files.autoSave": "afterDelay", 51 | "editor.stickyScroll.enabled": false, 52 | "[typescriptreact]": { 53 | "editor.defaultFormatter": "vscode.typescript-language-features" 54 | }, 55 | "editor.mouseWheelZoom": true, 56 | "editor.mouseWheelScrollSensitivity": 2, 57 | "github.copilot.enable": { 58 | "*": false, 59 | "plaintext": false, 60 | "markdown": false, 61 | "scminput": false, 62 | "typescriptreact": false 63 | }, 64 | "tailwindCSS.emmetCompletions": true, 65 | "tailwindCSS.includeLanguages": { 66 | "html": "html", 67 | "javascript": "javascript", 68 | "css": "css" 69 | }, 70 | "git.enableSmartCommit": true, 71 | "git.autofetch": true, 72 | "editor.codeActions.triggerOnFocusChange": true, 73 | "git.confirmSync": false, 74 | "codeium.enableConfig": { 75 | "*": true, 76 | "properties": true 77 | }, 78 | "javascript.updateImportsOnFileMove.enabled": "always", 79 | "[prisma]": { 80 | "editor.defaultFormatter": "Prisma.prisma" 81 | }, 82 | "editor.linkedEditing": true, 83 | "eslint.execArgv": null, 84 | "typescript.updateImportsOnFileMove.enabled": "always", 85 | "files.exclude": { 86 | "**/.git": false 87 | }, 88 | "editor.minimap.autohide": "mouseover", 89 | "gitlens.advanced.messages": { 90 | "suppressCommitNotFoundWarning": true 91 | }, 92 | "editor.cursorBlinking": "expand", 93 | "git.ignoreRebaseWarning": true, 94 | "workbench.colorTheme": "Xrodev", 95 | "workbench.iconTheme": "vscode-icons" 96 | } 97 | 98 | 99 | ``` 100 | -------------------------------------------------------------------------------- /JavaScript/reactFormValidation.md: -------------------------------------------------------------------------------- 1 | ### React js Form Validation 2 | 3 | 4 | ``` javascript 5 | import React, { useEffect, useState } from "react"; 6 | 7 | function RegistrationView() { 8 | const [inputValues, setInputValue] = useState({ 9 | fName: "", 10 | lName: "", 11 | email: "", 12 | password: "", 13 | confirmPassword: "", 14 | }); 15 | 16 | const [validation, setValidation] = useState({ 17 | fName: "", 18 | lName: "", 19 | email: "", 20 | password: "", 21 | confirmPassword: "", 22 | }); 23 | 24 | //handle submit updates 25 | function handleChange(event) { 26 | const { name, value } = event.target; 27 | setInputValue({ ...inputValues, [name]: value }); 28 | } 29 | 30 | const checkValidation = () => { 31 | let errors = validation; 32 | 33 | first Name validation 34 | if (!inputValues.fName.trim()) { 35 | errors.fName = "First name is required"; 36 | } else { 37 | errors.fName = ""; 38 | } 39 | //last Name validation 40 | if (!inputValues.lName.trim()) { 41 | errors.lName = "Last name is required"; 42 | } else { 43 | errors.lName = ""; 44 | } 45 | 46 | // email validation 47 | const emailCond = 48 | "/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:.[a-zA-Z0-9-]+)*$/"; 49 | if (!inputValues.email.trim()) { 50 | errors.email = "Email is required"; 51 | } else if (!inputValues.email.match(emailCond)) { 52 | errors.email = "Please ingress a valid email address"; 53 | } else { 54 | errors.email = ""; 55 | } 56 | 57 | //password validation 58 | const cond1 = "/^(?=.*[a-z]).{6,20}$/"; 59 | const cond2 = "/^(?=.*[A-Z]).{6,20}$/"; 60 | const cond3 = "/^(?=.*[0-9]).{6,20}$/"; 61 | const password = inputValues.password; 62 | if (!password) { 63 | errors.password = "password is required"; 64 | } else if (password.length < 6) { 65 | errors.password = "Password must be longer than 6 characters"; 66 | } else if (password.length >= 20) { 67 | errors.password = "Password must shorter than 20 characters"; 68 | } else if (!password.match(cond1)) { 69 | errors.password = "Password must contain at least one lowercase"; 70 | } else if (!password.match(cond2)) { 71 | errors.password = "Password must contain at least one capital letter"; 72 | } else if (!password.match(cond3)) { 73 | errors.password = "Password must contain at least a number"; 74 | } else { 75 | errors.password = ""; 76 | } 77 | 78 | //matchPassword validation 79 | if (!inputValues.confirmPassword) { 80 | errors.confirmPassword = "Password confirmation is required"; 81 | } else if (inputValues.confirmPassword !== inputValues.Password) { 82 | errors.confirmPassword = "Password does not match confirmation password"; 83 | } else { 84 | errors.password = ""; 85 | } 86 | 87 | setValidation(errors); 88 | }; 89 | 90 | useEffect(() => { 91 | checkValidation(); 92 | }, [inputValues]); 93 | 94 | const handleSubmit = (e) => { 95 | e.preventDefault(); 96 | }; 97 | 98 | return ( 99 |
100 |
101 |
107 |
108 | handleChange(e)} 115 | value={inputValues.fName} 116 | /> 117 | {validation.fName &&

{validation.fName}

} 118 | {validation.fName && console.log(validation)} 119 |
120 |
121 | handleChange(e)} 128 | value={inputValues.lName} 129 | /> 130 | {validation.lName &&

{validation.lName}

} 131 |
132 |
133 | handleChange(e)} 139 | value={inputValues.email} 140 | /> 141 |
142 | {validation.email &&

{validation.email}

} 143 | 144 |
145 | handleChange(e)} 151 | value={inputValues.password} 152 | required 153 | /> 154 | {validation.password &&

{validation.password}

} 155 |
156 |
157 | handleChange(e)} 163 | value={inputValues.confirmPassword} 164 | required 165 | /> 166 |
167 | 170 | 171 | Already have an account? Login here 172 | 173 |
174 |
175 |
176 | ); 177 | } 178 | 179 | export default RegistrationView; 180 | ``` 181 | -------------------------------------------------------------------------------- /vue/ticket_system_script.md: -------------------------------------------------------------------------------- 1 | ### This File we see that full ticket system script code 2 | 3 | ``` vue 4 | 5 | 260 | 261 | ``` -------------------------------------------------------------------------------- /git&github.md: -------------------------------------------------------------------------------- 1 | ## Git and GitHub: A Beginner's Guide 2 | 3 | ### Introduction to Git 4 | 5 | Git is a powerful version control system designed to track changes to files, making it essential for collaborative software development. It operates locally on your computer and supports Windows, macOS, and Linux. 6 | 7 | ### Understanding GitHub 8 | 9 | GitHub complements Git by providing a web-based platform to host Git repositories. It's widely used for sharing and managing code, offering features like issue tracking and pull requests. While GitHub is popular, alternatives exist for hosting Git repositories. 10 | 11 | ### Version Control Systems (VCS) 12 | 13 | Before Git, version control systems like SCCS and CVS were used. These systems allowed developers to manage code history but were less user-friendly and had limitations compared to Git. 14 | 15 | ### Learning Path 16 | 17 | Our tutorial will cover Git fundamentals before moving to GitHub: 18 | 1. **Basics of Git**: Learn essential commands (`git init`, `git commit`, `git branch`, `git merge`, `git push`) for version control. 19 | 2. **Daily Use**: Practice using Git regularly to familiarize yourself with its workflow. 20 | 3. **Troubleshooting**: Address common issues that arise during Git operations. 21 | 4. **Advanced Topics**: Explore more complex Git commands and workflows. 22 | 5. **Introduction to GitHub**: Once comfortable with Git, transition to GitHub for collaboration and code sharing. 23 | 24 | ### Installation Steps 25 | 26 | To begin: 27 | - **Install Git**: Download the installer from [git-scm.com/downloads](https://git-scm.com/downloads) and follow the setup instructions for your operating system. 28 | - **Create a GitHub Account**: Sign up at [github.com](https://github.com) to start using GitHub for remote repositories and collaboration. 29 | 30 | ### Conclusion 31 | 32 | By the end of this tutorial, you'll grasp the fundamentals of Git and GitHub, empowering you to effectively manage code versions and collaborate seamlessly with others in software development. 33 | 34 | --- 35 | Here's a revised version of the document with clearer explanations and formatting: 36 | 37 | --- 38 | 39 | ## Git and GitHub: Understanding Key Terminology and Commands 40 | 41 | ### Checking Git Version 42 | 43 | To verify your Git version, use the following command: 44 | 45 | ```bash 46 | git --version 47 | ``` 48 | 49 | This command displays the installed Git version. Git is known for its stability and rarely introduces breaking changes. 50 | 51 | ### Repository 52 | 53 | A **repository** (or repo) is a collection of files and directories managed by Git. It's more than a simple folder; it stores all project code and history. You can visualize it as a container for your entire codebase. 54 | 55 | ### Git Status 56 | 57 | To see the current state of your repository, use: 58 | 59 | ```bash 60 | git status 61 | ``` 62 | 63 | This command shows which files are tracked (green) and untracked (red) by Git. 64 | 65 | ### Configuration Settings 66 | 67 | Git uses a configuration file (`git config`) to store user-specific settings like username and email. Set these with: 68 | 69 | ```bash 70 | git config --global user.email "your-email@example.com" 71 | git config --global user.name "Your Name" 72 | ``` 73 | 74 | Check your Git configuration: 75 | 76 | ```bash 77 | git config --list 78 | ``` 79 | 80 | This lists all configured settings. 81 | 82 | ### Initializing a Repository 83 | 84 | To create a new Git repository from a folder, use: 85 | 86 | ```bash 87 | git init 88 | ``` 89 | 90 | This command initializes a new Git repository in the current directory, creating a hidden `.git` folder. 91 | 92 | ### Commit 93 | 94 | A **commit** records changes to the repository. It's like taking a snapshot of your code at a specific time: 95 | 96 | ```bash 97 | git commit -m "commit message" 98 | ``` 99 | 100 | Use `-m` to add a message describing the changes made in the commit. 101 | 102 | ### Push to GitHub 103 | 104 | To push your local repository to GitHub: 105 | 106 | 1. Initialize the repository (`git init`). 107 | 2. Add files (`git add `). 108 | 3. Commit changes (`git commit -m "Initial commit"`). 109 | 4. Push to GitHub (`git push origin main`). 110 | 111 | ### Staging 112 | 113 | **Staging** prepares changes for commit. Use `git add` to stage files: 114 | 115 | ```bash 116 | git add 117 | ``` 118 | 119 | ### Logs 120 | 121 | View commit history with: 122 | 123 | ```bash 124 | git log 125 | ``` 126 | 127 | Use `--oneline` for compact output (`git log --oneline`). 128 | 129 | ### Atomic Commits 130 | 131 | **Atomic commits** are self-contained units of work. Each commit should address a single change to maintain a clean history. 132 | 133 | ### Change Default Code Editor 134 | 135 | Set Visual Studio Code as the default editor: 136 | 137 | ```bash 138 | git config --global core.editor "code --wait" 139 | ``` 140 | 141 | ### Gitignore 142 | 143 | Create a `.gitignore` file to specify files and directories Git should ignore: 144 | 145 | Example `.gitignore`: 146 | 147 | ``` 148 | node_modules 149 | .env 150 | .vscode 151 | ``` 152 | 153 | When `git status` is run, files and folders listed in `.gitignore` are excluded from tracking. 154 | 155 | --- 156 | 157 | This revised version organizes and clarifies the information, making it easier to understand and follow for beginners learning Git and GitHub. 158 | 159 | Certainly! Here's a rewritten version of the document that explains Git internals and provides commands to explore them: 160 | 161 | --- 162 | 163 | ## Git Behind the Scenes: Understanding Git Internals 164 | 165 | Git operates internally by managing snapshots of your codebase. Let's explore the basic components that make up Git's version control system. 166 | 167 | ### Git Snapshots 168 | 169 | A **snapshot** in Git represents a specific state of your code at a given point in time. It captures the entire content of your project, including files and folders. Each snapshot is uniquely identified by a hash code, which reflects the contents of that snapshot. 170 | 171 | ### The Three Musketeers of Git 172 | 173 | The core objects in Git are known as the "Three Musketeers": 174 | 175 | #### 1. Commit Object 176 | 177 | - **Description**: A commit object records a snapshot of the project at a specific time. 178 | - **Contents**: Contains metadata such as author, committer, commit message, and a reference to the tree object representing the project's state. 179 | - **Storage**: Stored in the `.git` directory. 180 | 181 | #### 2. Tree Object 182 | 183 | - **Description**: A tree object represents the structure of the project at a particular commit. 184 | - **Contents**: Acts as a directory listing all files and subdirectories, each associated with a file mode (permissions), file name, and a reference (hash) to blob objects storing file content. 185 | - **Hierarchy**: Can reference other tree objects, enabling Git to manage directories recursively. 186 | 187 | #### 3. Blob Object 188 | 189 | - **Description**: A blob object stores the contents of each individual file. 190 | - **Contents**: Contains the actual data of the file stored as a binary large object (blob). 191 | - **Storage**: Maintained within the Git object database. 192 | 193 | ### Helpful Commands to Explore Git Internals 194 | 195 | Here are some commands to delve into the Git object structure: 196 | 197 | #### Viewing Commit Information: 198 | 199 | ```bash 200 | git show -s --pretty=raw 201 | ``` 202 | 203 | - Use this command to display detailed information about a specific commit, including its metadata. 204 | 205 | #### Listing Tree Objects: 206 | 207 | ```bash 208 | git ls-tree 209 | ``` 210 | 211 | - Retrieves and displays the contents of a tree object identified by ``, showing file modes, names, and blob hashes. 212 | 213 | #### Showing Blob Content: 214 | 215 | ```bash 216 | git show 217 | ``` 218 | 219 | - Retrieves and displays the content of a blob object identified by ``, which represents the actual file content stored in Git. 220 | 221 | #### Viewing Commit Details: 222 | 223 | ```bash 224 | git cat-file -p 225 | ``` 226 | 227 | - Displays the contents of a commit object identified by ``, showing metadata and the associated tree object. 228 | 229 | --- 230 | 231 | Understanding these Git internals provides insight into how Git manages and tracks changes within your projects. These commands allow you to explore the underlying structure of Git, enhancing your understanding of version control and its functionalities. 232 | 233 | Here's a rewritten version of the document with clear explanations and improved formatting: 234 | 235 | --- 236 | 237 | ## Branches in Git: Managing Different Versions of a Project 238 | 239 | ### Introduction to Branches 240 | 241 | Branches in Git allow developers to work on different versions of a project simultaneously. Each branch represents an independent line of development, which can be used for features, fixes, or experiments without affecting the main codebase until changes are ready. 242 | 243 | ### Understanding HEAD in Git 244 | 245 | **HEAD** is a pointer to the current branch you're working on. It always points to the latest commit of the current branch. 246 | 247 | ### Creating and Managing Branches 248 | 249 | #### Creating a New Branch 250 | 251 | To create a new branch, use: 252 | 253 | ```bash 254 | git branch 255 | git branch bug-fix 256 | git switch bug-fix 257 | ``` 258 | 259 | - `git branch`: Lists all existing branches. 260 | - `git branch bug-fix`: Creates a new branch named `bug-fix`. 261 | - `git switch bug-fix`: Switches to the `bug-fix` branch. 262 | 263 | #### Viewing Commit History 264 | 265 | ```bash 266 | git log 267 | ``` 268 | 269 | - Shows the commit history of the current branch. 270 | 271 | #### Switching Between Branches 272 | 273 | ```bash 274 | git switch master 275 | git switch -c dark-mode 276 | git checkout orange-mode 277 | ``` 278 | 279 | - `git switch master`: Switches to the `master` branch. 280 | - `git switch -c dark-mode`: Creates and switches to a new branch named `dark-mode`. 281 | - `git checkout orange-mode`: Switches to the `orange-mode` branch (alternative to `git switch`). 282 | 283 | ### Merging Branches 284 | 285 | #### Fast-Forward Merge 286 | 287 | When the branch being merged is ahead and there are no conflicting changes: 288 | 289 | ```bash 290 | git checkout main 291 | git merge bug-fix 292 | ``` 293 | 294 | - `git merge bug-fix`: Merges the `bug-fix` branch into `main` with a fast-forward merge. 295 | 296 | #### Non Fast-Forward Merge 297 | 298 | When there are conflicting changes between branches: 299 | 300 | ```bash 301 | git checkout main 302 | git merge bug-fix 303 | ``` 304 | 305 | - Involves manual conflict resolution where conflicts need to be resolved explicitly. 306 | 307 | ### Managing Conflicts 308 | 309 | Conflict resolution involves manually deciding which changes to keep when merging conflicting branches. Tools like VSCode's built-in merge tool can assist in resolving conflicts efficiently. 310 | 311 | ### Additional Branch Operations 312 | 313 | #### Renaming a Branch 314 | 315 | ```bash 316 | git branch -m 317 | ``` 318 | 319 | - Renames the specified branch. 320 | 321 | #### Deleting a Branch 322 | 323 | ```bash 324 | git branch -d 325 | ``` 326 | 327 | - Deletes the specified branch. 328 | 329 | #### Checking Out a Branch 330 | 331 | ```bash 332 | git checkout 333 | ``` 334 | 335 | - Switches to the specified branch for working on it. 336 | 337 | #### Listing All Branches 338 | 339 | ```bash 340 | git branch 341 | ``` 342 | 343 | - Lists all branches in the repository. 344 | 345 | --- 346 | 347 | Understanding and effectively managing branches in Git is crucial for collaborative software development. These commands enable efficient workflow management and version control within your projects. 348 | 349 | Here's a rewritten version of the document that explains Git `diff`, `stash`, and `tags` more clearly and concisely: 350 | 351 | --- 352 | 353 | ## Git Diff: Comparing and Viewing Changes 354 | 355 | ### Introduction to Git Diff 356 | 357 | The `git diff` command is used to compare changes between different contexts in Git. 358 | 359 | #### Comparing Working Directory with Staging Area 360 | 361 | ```bash 362 | git diff 363 | ``` 364 | 365 | - Shows unstaged changes in your working directory compared to the staging area. 366 | 367 | #### Comparing Staging Area with Repository 368 | 369 | ```bash 370 | git diff --staged 371 | ``` 372 | 373 | - Displays changes staged for the next commit compared to the last commit. 374 | 375 | #### Comparing Between Branches 376 | 377 | ```bash 378 | git diff 379 | ``` 380 | 381 | - Compares differences between two branches. 382 | 383 | #### Comparing Specific Commits 384 | 385 | ```bash 386 | git diff 387 | ``` 388 | 389 | - Highlights differences between two specific commits. 390 | 391 | --- 392 | 393 | ## Git Stash: Temporary Storage for Changes 394 | 395 | ### Introduction to Git Stash 396 | 397 | Git stash is used to temporarily save changes that aren't ready for a commit. 398 | 399 | #### Saving Changes to Stash 400 | 401 | ```bash 402 | git stash 403 | ``` 404 | 405 | - Temporarily saves changes in a stack. 406 | 407 | #### Naming a Stash 408 | 409 | ```bash 410 | git stash save "work in progress on X feature" 411 | ``` 412 | 413 | - Names a stash for easier reference. 414 | 415 | #### Viewing and Applying Stashes 416 | 417 | ```bash 418 | git stash list 419 | git stash apply 420 | git stash apply stash@{0} 421 | ``` 422 | 423 | - Lists saved stashes, applies the latest stash, or applies a specific named stash. 424 | 425 | #### Applying and Dropping Stashes 426 | 427 | ```bash 428 | git stash pop 429 | git stash drop 430 | ``` 431 | 432 | - Applies and removes the latest stash from the stack. 433 | 434 | #### Applying Stash to a Specific Branch 435 | 436 | ```bash 437 | git stash apply stash@{0} 438 | ``` 439 | 440 | - Applies a stash to a specified branch. 441 | 442 | #### Clearing Stash 443 | 444 | ```bash 445 | git stash clear 446 | ``` 447 | 448 | - Removes all stashed changes. 449 | 450 | --- 451 | 452 | ## Git Tags: Marking Specific Points in History 453 | 454 | ### Introduction to Git Tags 455 | 456 | Git tags are used to mark specific commits in history for easy reference. 457 | 458 | #### Creating a Tag 459 | 460 | ```bash 461 | git tag 462 | ``` 463 | 464 | - Creates a lightweight tag for the current commit. 465 | 466 | #### Creating an Annotated Tag 467 | 468 | ```bash 469 | git tag -a -m "Release 1.0" 470 | ``` 471 | 472 | - Creates an annotated tag with a message. 473 | 474 | #### Listing Tags 475 | 476 | ```bash 477 | git tag 478 | ``` 479 | 480 | - Lists all tags in the repository. 481 | 482 | #### Tagging a Specific Commit 483 | 484 | ```bash 485 | git tag 486 | ``` 487 | 488 | - Tags a specific commit with a name. 489 | 490 | #### Pushing Tags to Remote 491 | 492 | ```bash 493 | git push origin 494 | ``` 495 | 496 | - Pushes tags to the remote repository. 497 | 498 | #### Deleting Tags 499 | 500 | ```bash 501 | git tag -d 502 | ``` 503 | 504 | - Deletes a local tag. 505 | 506 | #### Deleting Remote Tags 507 | 508 | ```bash 509 | git push origin : 510 | ``` 511 | 512 | - Deletes a tag from the remote repository. 513 | 514 | --- 515 | 516 | Understanding these Git commands—`diff`, `stash`, and `tags`—helps in efficiently managing changes, organizing work, and marking important points in your project's history. 517 | 518 | Here's a rewritten version of the document explaining Git `rebase` and `reflog`: 519 | 520 | --- 521 | 522 | ## Git Rebase: Changing Branch Base 523 | 524 | ### Introduction to Git Rebase 525 | 526 | Git rebase is a powerful feature used to move a branch to a new base commit, effectively rewriting the commit history. 527 | 528 | #### Why Use Rebase? 529 | 530 | - **Cleaner History:** Helps maintain a linear project history. 531 | - **Integration:** Incorporates changes from one branch onto another cleanly. 532 | 533 | #### Performing a Rebase 534 | 535 | ```bash 536 | git checkout feature-branch 537 | git rebase main 538 | ``` 539 | 540 | - Moves `feature-branch` to start from the latest `main` branch commit. 541 | 542 | #### Resolving Conflicts 543 | 544 | ```bash 545 | git add 546 | git rebase --continue 547 | ``` 548 | 549 | - Manually resolve conflicts that may arise during rebase. 550 | 551 | #### Caution: Avoid `--force` 552 | 553 | - Using `--force` with rebase can lead to project history issues. 554 | 555 | --- 556 | 557 | ## Git Reflog: Viewing Commit History 558 | 559 | ### Introduction to Git Reflog 560 | 561 | Git reflog provides a detailed history of changes, useful for debugging and recovering lost commits. 562 | 563 | #### Viewing Reflog 564 | 565 | ```bash 566 | git reflog 567 | ``` 568 | 569 | - Displays a chronological list of recent commits and actions. 570 | 571 | #### Finding a Specific Commit 572 | 573 | ```bash 574 | git reflog 575 | ``` 576 | 577 | - Locates a specific commit within the reflog history. 578 | 579 | #### Recovering Lost Commits 580 | 581 | ```bash 582 | git reflog 583 | git reset --hard 584 | ``` 585 | 586 | - Retrieves commits or changes that were accidentally deleted or lost. 587 | 588 | #### Using `HEAD@{n}` 589 | 590 | ```bash 591 | git reflog 592 | git reset --hard HEAD@{1} 593 | ``` 594 | 595 | - Resets to a specific commit relative to `HEAD`. 596 | 597 | --- 598 | 599 | Understanding `rebase` and `reflog` enhances Git proficiency by facilitating cleaner histories and effective commit management. 600 | 601 | Here's a rewritten version of the "Getting Started with Github" guide: 602 | 603 | --- 604 | 605 | ## Getting Started with GitHub 606 | 607 | ### What is GitHub? 608 | 609 | GitHub is a web-based hosting service for Git repositories. It facilitates collaboration among developers, allowing them to manage and track changes to their code, as well as host and share projects. 610 | 611 | #### Alternatives to GitHub 612 | 613 | While GitHub is widely popular, other platforms include GitLab, Bitbucket, Azure Repos, and Gitea. 614 | 615 | ### GitHub Account 616 | 617 | Creating a GitHub account is free and straightforward: 618 | 619 | 1. Visit the GitHub website. 620 | 2. Click on the “Sign up” button. 621 | 3. Enter your email address and password. 622 | 4. Complete the sign-up process and access your GitHub homepage. 623 | 624 | ### Configure Your Git Config File 625 | 626 | Before using GitHub, configure your Git settings: 627 | 628 | ```bash 629 | git config --global user.email "your-email@example.com" 630 | git config --global user.name "Your Name" 631 | ``` 632 | 633 | Verify your settings: 634 | 635 | ```bash 636 | git config --list 637 | ``` 638 | 639 | ### Setup SSH Key and Add to GitHub 640 | 641 | Securely connect to GitHub using SSH keys: 642 | 643 | 1. Generate a new SSH key: 644 | 645 | ```bash 646 | ssh-keygen -t ed25519 -C "your-email@example.com" 647 | ``` 648 | 649 | 2. Save the key to your computer. 650 | 651 | 3. Add the key to your SSH agent: 652 | 653 | ```bash 654 | eval "$(ssh-agent -s)" 655 | ssh-add ~/.ssh/id_ed25519 656 | ``` 657 | 658 | 4. Add the SSH key to your GitHub account using the GitHub website. 659 | 660 | ### Adding Code to a Remote Repository 661 | 662 | Once configured, start pushing your code to a remote repository: 663 | 664 | 1. Initialize a new Git repository, add files, and commit: 665 | 666 | ```bash 667 | git init 668 | git add 669 | git commit -m "commit message" 670 | ``` 671 | 672 | 2. Check the remote URL: 673 | 674 | ```bash 675 | git remote -v 676 | ``` 677 | 678 | 3. Add a remote repository: 679 | 680 | ```bash 681 | git remote add origin 682 | ``` 683 | 684 | Example: 685 | 686 | ```bash 687 | git remote add origin https://github.com/username/repository.git 688 | ``` 689 | 690 | 4. Push code to the remote repository: 691 | 692 | ```bash 693 | git push -u origin main 694 | ``` 695 | 696 | ### Setting Up an Upstream Remote 697 | 698 | Keep your local repository synchronized with the remote repository: 699 | 700 | ```bash 701 | git remote add upstream 702 | ``` 703 | 704 | Or shorthand: 705 | 706 | ```bash 707 | git remote add -u 708 | ``` 709 | 710 | Push changes to the upstream remote: 711 | 712 | ```bash 713 | git push -u origin main 714 | ``` 715 | 716 | ### Getting Code from a Remote Repository 717 | 718 | Fetch or pull code from a remote repository: 719 | 720 | #### Fetch Code 721 | 722 | ```bash 723 | git fetch 724 | ``` 725 | 726 | Example: 727 | 728 | ```bash 729 | git fetch origin 730 | ``` 731 | 732 | #### Pull Code 733 | 734 | ```bash 735 | git pull 736 | ``` 737 | 738 | Example: 739 | 740 | ```bash 741 | git pull origin main 742 | ``` 743 | 744 | --- 745 | 746 | By following these steps, you can effectively use GitHub to collaborate on projects, manage code changes, and contribute to repositories seamlessly. 747 | 748 | ### Conclusion 749 | 750 | Git and GitHub together form a powerful ecosystem that revolutionizes how developers manage and collaborate on software projects. Git, as a distributed version control system, allows for efficient tracking of changes, branching for concurrent development, and seamless collaboration among team members. On the other hand, GitHub provides a centralized platform where Git repositories can be hosted, shared, and managed with additional features for project management, code review, and continuous integration. 751 | 752 | Key takeaways from understanding Git and GitHub include: 753 | 754 | 1. **Version Control Mastery:** Git empowers developers to manage project history effectively, enabling them to track changes, revert to previous versions, and maintain a clean and organized codebase. 755 | 756 | 2. **Collaborative Development:** GitHub facilitates teamwork by offering tools like pull requests, issues, and project boards, allowing developers to collaborate asynchronously, review code, and discuss improvements. 757 | 758 | 3. **Community and Open Source:** GitHub fosters a global community where developers can contribute to open source projects, learn from others' code, and showcase their work to a wider audience. 759 | 760 | 4. **Workflow Efficiency:** Integrating Git with GitHub streamlines workflows with automation tools like GitHub Actions, enhancing productivity through automated testing, deployment, and more. 761 | 762 | By mastering Git commands, understanding branching strategies, utilizing GitHub's collaboration tools, and embracing best practices like code reviews and continuous integration, developers can harness the full potential of this ecosystem to build better software, faster. 763 | 764 | Whether you're just starting with version control or expanding your expertise in collaborative software development, Git and GitHub provide the foundation and tools necessary to succeed in today's fast-paced software industry. 765 | --------------------------------------------------------------------------------