├── .DS_Store ├── .vscode └── settings.json ├── LICENSE ├── README.md ├── algorithms ├── .gitignore ├── pom.xml └── src │ └── main │ └── java │ └── cc │ └── gaurav │ ├── algorithms │ ├── array │ │ ├── flat │ │ │ ├── ArrayFlatner.java │ │ │ ├── ArrayFlatnerMain.java │ │ │ ├── IterativeArrayFlatner.java │ │ │ └── RecursiveArrayFlatner.java │ │ └── rotation │ │ │ ├── ArrayRotation.java │ │ │ ├── ArrayRotationMain.java │ │ │ ├── JugglingAlgorithm.java │ │ │ ├── ReverseAlgorithm.java │ │ │ ├── SpaceComplexityAlgorithm.java │ │ │ └── TimeComplexityNoSpaceComplexity.java │ ├── search │ │ ├── ArraySearch.java │ │ ├── BinarySearch.java │ │ ├── ExponentialSearch.java │ │ ├── FrontAndBackSearch.java │ │ ├── InterpolationSearch.java │ │ ├── JumpSearch.java │ │ ├── LinearSearch.java │ │ ├── NonRecursiveBinarySearch.java │ │ ├── NonRecursiveInterpolationSearch.java │ │ ├── PivotedArraySearch.java │ │ ├── Search.java │ │ ├── SquareRootBinarySearch.java │ │ └── string │ │ │ ├── KMPSearchMain.java │ │ │ ├── NaiveStringSearchMain.java │ │ │ └── RabinKarpSearchMain.java │ └── varioussamples │ │ └── conversion │ │ └── Base64Main.java │ ├── backtrack │ ├── GenerateListOfPossibleWords.java │ ├── GetAllPathsFromSourceToDest.java │ ├── LongestPossiblePath.java │ ├── ShortestPathInMaze.java │ ├── Solution.java │ └── UniquePathInMaze.java │ ├── bitmanupulation │ ├── LoneInteger.java │ └── SubMajorityVote.java │ ├── cache │ └── LFUCacheV2.java │ ├── dailyproblem │ ├── ProductOfNumsExceptCurrent.java │ └── TreeSerialization.java │ ├── dp │ ├── FindingAllCommonSubsequence.java │ ├── FindingLongestCommonSubsequence.java │ ├── LongestCommonSubsequence.java │ ├── LongestIncreasingSubsequence.java │ ├── NumberOfHops.java │ └── UpsideDown.java │ ├── graph │ └── CloneGraph.java │ ├── hash │ ├── AnagramDifference.java │ └── RotationGroups.java │ ├── heap │ ├── MaxHeap.java │ ├── MinHeap.java │ ├── MinQueueWithStack.java │ ├── MinimumQueue.java │ ├── MinimumStack.java │ └── RemoveSmallestPeaks.java │ ├── integers │ ├── NarcissisticNumber.java │ └── RepeatedAddition.java │ ├── interval │ ├── ContiguousIntervals.java │ ├── IntervalDuration.java │ ├── IntervalOverlaps.java │ └── LongestInterval.java │ ├── list │ ├── BinaryTreeToLinkedList.java │ ├── CentralLinkedList.java │ ├── CountOccurrences.java │ ├── EquivalentAndFrequency.java │ ├── LinkedListDeleteKthElement.java │ ├── LinkedListDeleteLastOccurance.java │ ├── LinkedListJumps.java │ ├── LinkedListRemoval.java │ ├── LinkedListRotation.java │ ├── ListPartitioning.java │ ├── MinimumPeak.java │ ├── MinimumStack.java │ ├── RangeUpdate.java │ ├── Replace369.java │ ├── ReverseInnerLinkedList.java │ ├── ReverseLinkedList.java │ ├── SmallestIntersectingElement.java │ ├── TwoSumV1.java │ └── TwoSumV2.java │ ├── lld │ └── PasswordChecker.java │ ├── matrix │ ├── ExcelSpreadSheet.java │ ├── MatrixTranspose.java │ └── NearestBusStop.java │ ├── queue │ ├── TowersWithoutValley.py │ ├── QueriesFixedLength.java │ ├── RemoveSmallestPeaks.java │ ├── SlidingWindowAverage.java │ ├── TowersWithValleySegTree.java │ ├── TowersWithoutAValley.java │ └── WordMachine.java │ ├── search │ ├── BinarySearchTemplate.java │ ├── PerfectSquare.java │ └── SkyDivers.java │ ├── set │ └── Set.java │ ├── sort │ ├── MergeSort.java │ ├── QuickSelect.java │ ├── QuickSort.java │ ├── SortBinaryArray.java │ └── SortByFreqAndValue.java │ ├── stack │ ├── MaximumStack.java │ ├── RepeatedDeletionByK.java │ ├── SpaceBattle.java │ └── UnixPathResolution.java │ ├── str │ ├── BalancedString.java │ └── ParseBooleanExpression.java │ ├── string │ ├── AnagramSubstring.java │ ├── BalancedStrings.java │ ├── DecodeString.java │ ├── DeleteCharsToEqualizeStrings.java │ ├── LazyRunLengthDecodingV1.java │ ├── LazyRunLengthDecodingV2.java │ ├── MinimumBracketAddition.java │ ├── NumberToCurrencyFormatting.java │ ├── OddPalindrome.java │ ├── PackageVersioning.java │ ├── RemovingParenthesis.java │ ├── RunLengthDecodedStringIterator.java │ ├── STypeExpressEvaluation.java │ ├── ShortestString.java │ ├── StringInterleaving.java │ ├── StringIsomorpism.java │ ├── StuckKeyboard.java │ └── TernaryExpressionParser.java │ ├── trie │ └── SearchEngine.java │ ├── tries │ ├── BinarySearchTreeCutter.java │ ├── CountMaximalValueRoots.java │ ├── InvertedTree.java │ ├── KthSmallestNumber.java │ ├── LeftMostDeepestTreeNode.java │ ├── MorrisInOrderIterator.java │ ├── NextPositionInTree.java │ ├── SecondDeepestLeafHeight.java │ ├── TreeIterable.java │ ├── TreeNode.java │ └── TwinTrees.java │ └── unionfind │ ├── FriendGroups.java │ ├── MinimumSpanningTree.java │ └── UnionFindWithPathCompression.java ├── angular7-example ├── .editorconfig ├── .gitignore ├── .vscode │ └── launch.json ├── README.md ├── angular.json ├── e2e │ ├── protractor.conf.js │ ├── src │ │ ├── app.e2e-spec.ts │ │ └── app.po.ts │ └── tsconfig.e2e.json ├── package-lock.json ├── package.json ├── src │ ├── app │ │ ├── _guards │ │ │ ├── auth-guard.guard.spec.ts │ │ │ └── auth-guard.guard.ts │ │ ├── _models │ │ │ ├── alert-message-type.enum.ts │ │ │ ├── alert-message.ts │ │ │ ├── login-request.ts │ │ │ ├── login-response.ts │ │ │ ├── login-status.enum.ts │ │ │ └── user.ts │ │ ├── _services │ │ │ ├── alert.service.spec.ts │ │ │ ├── alert.service.ts │ │ │ ├── login.service.spec.ts │ │ │ ├── login.service.ts │ │ │ └── mock-xhr-backend.ts │ │ ├── alert │ │ │ ├── alert.component.html │ │ │ ├── alert.component.scss │ │ │ ├── alert.component.spec.ts │ │ │ └── alert.component.ts │ │ ├── app-routing.module.ts │ │ ├── app.component.html │ │ ├── app.component.scss │ │ ├── app.component.spec.ts │ │ ├── app.component.ts │ │ ├── app.module.ts │ │ ├── footer │ │ │ ├── footer.component.html │ │ │ ├── footer.component.scss │ │ │ ├── footer.component.spec.ts │ │ │ └── footer.component.ts │ │ ├── home │ │ │ ├── home.component.html │ │ │ ├── home.component.scss │ │ │ ├── home.component.spec.ts │ │ │ └── home.component.ts │ │ ├── login │ │ │ ├── login.component.html │ │ │ ├── login.component.scss │ │ │ ├── login.component.spec.ts │ │ │ └── login.component.ts │ │ ├── navbar │ │ │ ├── navbar.component.html │ │ │ ├── navbar.component.spec.ts │ │ │ └── navbar.component.ts │ │ └── products │ │ │ ├── _model │ │ │ └── product.ts │ │ │ ├── _services │ │ │ ├── product.service.spec.ts │ │ │ └── product.service.ts │ │ │ ├── product-details │ │ │ ├── product-details.component.html │ │ │ ├── product-details.component.scss │ │ │ ├── product-details.component.spec.ts │ │ │ └── product-details.component.ts │ │ │ ├── product-list │ │ │ ├── product-list.component.html │ │ │ ├── product-list.component.scss │ │ │ ├── product-list.component.spec.ts │ │ │ └── product-list.component.ts │ │ │ ├── products-routing.module.ts │ │ │ ├── products.module.ts │ │ │ └── products │ │ │ ├── products.component.html │ │ │ ├── products.component.scss │ │ │ ├── products.component.spec.ts │ │ │ └── products.component.ts │ ├── assets │ │ └── .gitkeep │ ├── browserslist │ ├── environments │ │ ├── environment.prod.ts │ │ └── environment.ts │ ├── favicon.ico │ ├── index.html │ ├── karma.conf.js │ ├── main.ts │ ├── polyfills.ts │ ├── styles.scss │ ├── test.ts │ ├── tsconfig.app.json │ ├── tsconfig.spec.json │ └── tslint.json ├── tsconfig.json └── tslint.json ├── application-events ├── .gitignore ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── gauravbytes │ │ └── elk │ │ ├── AppEventGenerator.java │ │ └── event │ │ ├── AppEvent.java │ │ ├── AppLog.java │ │ ├── BaseEvent.java │ │ ├── EventEmitter.java │ │ └── LoggerEventEmitter.java │ └── resources │ ├── logback.xml │ └── logs.jsonl ├── avro-java-class-generation ├── .DS_Store ├── .classpath ├── .gitignore ├── .project ├── .settings │ ├── org.eclipse.core.resources.prefs │ ├── org.eclipse.jdt.apt.core.prefs │ ├── org.eclipse.jdt.core.prefs │ └── org.eclipse.m2e.core.prefs ├── pom.xml └── src │ └── main │ ├── avro │ └── employee.avsc │ └── java │ └── com │ └── gauravbytes │ ├── avro │ ├── Employee.java │ └── SEX.java │ └── schemageneration │ ├── AvroDatumExample.java │ └── PragmaticSchemaGeneration.java ├── avro-rpc ├── .DS_Store ├── .classpath ├── .gitignore ├── .project ├── .settings │ ├── org.eclipse.core.resources.prefs │ ├── org.eclipse.jdt.apt.core.prefs │ ├── org.eclipse.jdt.core.prefs │ └── org.eclipse.m2e.core.prefs ├── pom.xml └── src │ └── main │ ├── avro │ └── avro-rpc.avpr │ └── java │ └── com │ └── gauravbytes │ ├── EmailClientServer.java │ └── avro │ ├── EmailMessage.java │ └── EmailSender.java ├── big-data-learnings ├── .DS_Store ├── .gitignore ├── GraphDB_Neo4j │ ├── Neo4j_Example.ipynb │ ├── edge_distance.txt │ └── node_city.txt ├── NoSQL_Cassandra │ └── 01 Loading data into Cassandra.ipynb └── NoSQL_MongoDB │ ├── 01 Getting Started with MongoDB.ipynb │ ├── 02 Loading data into MongoDB.ipynb │ ├── 03 Loading data from MongoDB into Pandas dataframe.ipynb │ ├── adult.data │ └── adult.names ├── core-java-8 ├── .DS_Store ├── .classpath ├── .gitignore ├── .project ├── .settings │ ├── org.eclipse.jdt.apt.core.prefs │ ├── org.eclipse.jdt.core.prefs │ └── org.eclipse.m2e.core.prefs ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── gauravbytes │ ├── clone │ ├── deep │ │ ├── Address.java │ │ ├── DeepCloneExample.java │ │ └── Employee.java │ └── shallow │ │ ├── Address.java │ │ ├── Employee.java │ │ └── ShallowCloneExample.java │ ├── inheritence │ ├── Child.java │ ├── MyStaticTest.java │ └── Parent.java │ ├── java8 │ ├── collections │ │ └── CollectionImprovements.java │ ├── comparator │ │ └── ComparatorExample.java │ ├── customcollector │ │ └── CustomCollectorExample.java │ ├── datetime │ │ └── JavaDateTimePlaybook.java │ ├── defaultmethods │ │ ├── BinaryExpression.java │ │ ├── ConstantExpression.java │ │ ├── Expression.java │ │ ├── ExpressionDefaultMethodExample.java │ │ └── Java8DefaultMethods.java │ ├── filtering │ │ ├── Employee.java │ │ ├── EmployeeStub.java │ │ ├── Java8ConsumerExample.java │ │ └── Java8FilteringWithPredicates.java │ ├── functional │ │ └── Spec.java │ ├── lambda │ │ └── LambdaTest.java │ ├── methodref │ │ └── MethodReferenceExample.java │ ├── optional │ │ └── OptionalUsageExample.java │ ├── parameters │ │ └── Java8MethodParameters.java │ ├── stream │ │ ├── CreateStreamsExample.java │ │ ├── DataStub.java │ │ ├── ParallelStreamPerformanceTest.java │ │ ├── StreamCollectionExample.java │ │ ├── StreamDistinctExample.java │ │ ├── StreamExceptionExample.java │ │ ├── StreamFilteringExample.java │ │ ├── StreamMappingExample.java │ │ ├── StreamMinMaxExample.java │ │ ├── StreamReductionExample.java │ │ ├── StreamSamples.java │ │ └── StreamSortingExample.java │ ├── supplier │ │ └── SupplierExample.java │ └── types │ │ ├── NonNull.java │ │ └── TypeCheckingPlaybook.java │ ├── serialization │ ├── Dog.java │ ├── SimpleSerializationExample.java │ └── custom │ │ ├── Collar.java │ │ ├── Dog.java │ │ └── SimpleSerializationExample.java │ └── sort │ └── TopologicalSort.java ├── data-analytics-kibana-reporting ├── mailcontent.txt ├── query-example-response.json ├── same-ip-different-user-login-query.json └── watcher-condition.json ├── design-patterns ├── .gitignore ├── pom.xml └── src │ └── main │ └── java │ └── in │ └── lineofcode │ └── patterns │ └── observer │ ├── MyTask.java │ ├── Observable.java │ ├── Observer.java │ └── ObserverPatternMain.java ├── docker-learning └── docker_notes.txt ├── elasticpluginexample ├── .gitignore ├── pom.xml └── src │ ├── main │ ├── assemblies │ │ └── plugin.xml │ ├── java │ │ └── in │ │ │ └── lineofcode │ │ │ └── elasticsearch │ │ │ ├── ElasticSearchDemoPlugin.java │ │ │ └── rest │ │ │ └── HelloRestAction.java │ └── resources │ │ └── plugin-descriptor.properties │ └── test │ ├── java │ └── in │ │ └── lineofcode │ │ └── elasticsearch │ │ └── ElasticSearchDemoPluginIntegrationTest.java │ └── resources │ └── log4j.xml ├── elasticsearch-clientexample ├── .gitignore ├── pom.xml └── src │ └── main │ └── java │ └── in │ └── lineofcode │ └── elasticsearch │ └── lowlevelhttp │ ├── LowLevelElasticAsyncClientExample.java │ ├── LowLevelElasticClientExample.java │ └── LowlevelHttpClientUtils.java ├── es6-lessons ├── Cheetah.jpg ├── Lesson 10 - Sets.js ├── Lesson 11 - Maps.js ├── Lesson 4 - Object Literals.html ├── Lesson 4 - Object Literals.js ├── Lesson 5 - ForOf Loop.js ├── Lesson 5 - Spread Operator.js ├── Lesson 6 - Arrow Functions.js ├── Lesson 7 - Default Function Parameters.html ├── Lesson 7 - Default Function Parameters.js ├── Lesson 8 - Classes.js ├── Lesson 9 - Symbols.js ├── Lesson1-NewVariableSyntax.html ├── Lesson1-NewVariableSyntax.js ├── Lesson2 - TemplateLiterals.html ├── Lesson2 - TemplateLiterals.js ├── Lesson2-Quiz.html ├── Lesson2-Quiz.js ├── Lesson3 - Destructing.js └── Lesson3- Destructing.html ├── fbgraph-location ├── .gitignore ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── gauravbytes │ │ └── fbgraph │ │ └── FBApp.java │ └── resources │ ├── application.yml │ └── logback-spring.xml ├── hadoop-training ├── MR2-WordCount.txt └── shakespeare.raw ├── ignite-examples ├── .gitignore ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── gauravbytes │ └── igniteexamples │ ├── HelloworldIgniteExample.java │ ├── IgniteAsyncExample.java │ ├── IgniteComputeExample.java │ ├── IgniteComputerGrid2Example.java │ ├── IgniteConfigurationHelper.java │ ├── IgniteCustomThreadPoolExample.java │ ├── IgniteDataGridExample.java │ ├── IgniteLifecycleExample.java │ ├── IgniteServiceGridExample.java │ └── IgniteSqlExample.java ├── java-openclose-principle ├── .DS_Store ├── .classpath ├── .gitignore ├── .project ├── .settings │ ├── org.eclipse.jdt.apt.core.prefs │ ├── org.eclipse.jdt.core.prefs │ └── org.eclipse.m2e.core.prefs ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── gauravbytes │ └── openclose │ ├── bad │ ├── ImageEditor.java │ ├── Rectangle.java │ ├── Shape.java │ ├── ShapeType.java │ └── Square.java │ └── notbad │ ├── ImageEditor.java │ ├── Rectangle.java │ ├── Shape.java │ ├── ShapeType.java │ └── Square.java ├── java-srp-improved ├── .gitignore ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── gauravbytes │ └── good │ └── srp │ └── parser │ ├── CSVFileParser.java │ ├── FileParser.java │ ├── FileType.java │ ├── JsonFileParser.java │ ├── Parser.java │ └── XmlFileParser.java ├── java-srp ├── .gitignore ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── gauravbytes │ ├── good │ └── srp │ │ └── parser │ │ ├── CSVFileParser.java │ │ ├── FileParser.java │ │ ├── FileType.java │ │ ├── FileValidationUtils.java │ │ ├── JsonFileParser.java │ │ ├── Parser.java │ │ └── XmlFileParser.java │ └── srp │ └── parser │ ├── FileParser.java │ └── FileType.java ├── java-vertx ├── .gitignore ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── gauravbytes │ └── vertx │ ├── VerticleExample.java │ ├── VertxPeriodicTimerExample.java │ └── VertxWorkExecutorExample.java ├── java10-project ├── .gitignore ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── gauravbytes │ └── java10 │ └── collection │ └── ImmutableLists.java ├── kafka-begineer ├── .gitignore ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── gauravbytes │ └── kafka │ └── producerdemo │ ├── KafkaConsumerAssignAndSeekDemoMain.java │ ├── KafkaConsumerDemoMain.java │ ├── KafkaConsumerWithGroupDemoMain.java │ ├── KafkaConsumerWithThreadsDemoMain.java │ ├── KafkaProducerDemoMain.java │ ├── KafkaProducerDemoWithCallbackMain.java │ └── KafkaProducerDemoWithKeysMain.java ├── my-first-react-app-with-typescript ├── .gitignore ├── README.md ├── package-lock.json ├── package.json ├── public │ ├── favicon.ico │ ├── index.html │ ├── logo192.png │ ├── logo512.png │ ├── manifest.json │ └── robots.txt ├── src │ ├── App.css │ ├── App.test.tsx │ ├── App.tsx │ ├── Welcome.css │ ├── Welcome.tsx │ ├── gaurav-bytes.png │ ├── index.css │ ├── index.tsx │ ├── react-app-env.d.ts │ ├── serviceWorker.ts │ └── setupTests.ts └── tsconfig.json ├── my-first-react-app ├── .gitignore ├── README.md ├── package-lock.json ├── package.json ├── public │ ├── favicon.ico │ ├── index.html │ ├── logo192.png │ ├── logo512.png │ ├── manifest.json │ └── robots.txt └── src │ ├── App.css │ ├── App.js │ ├── App.test.js │ ├── Welcome.css │ ├── Welcome.js │ ├── gaurav-bytes.png │ ├── index.css │ ├── index.js │ ├── serviceWorker.js │ └── setupTests.js ├── notes ├── Apache Spark big data notes.txt ├── Architecting batch-processing Big Data applications.txt ├── Architecting real-time Big Data applications.txt ├── Data_Reporting_Analysis_notes.sql ├── Develiping Secure Software notes.txt └── HBase notes.txt ├── product-find-java8 ├── .gitignore ├── pom.xml └── src │ ├── main │ └── java │ │ └── com │ │ └── gauravbytes │ │ └── product │ │ ├── Color.java │ │ ├── Product.java │ │ ├── ProductCatalog.java │ │ ├── ProductSearcher.java │ │ └── Size.java │ └── test │ └── java │ └── com │ └── gauravbytes │ └── product │ └── ProductSelectionTest.java ├── react-blog-post-nextjs-ssg ├── .DS_Store ├── .gitignore ├── LICENSE ├── README.md ├── next-env.d.ts ├── package-lock.json ├── package.json ├── public │ ├── favicon.ico │ ├── logo192.png │ ├── logo512.png │ ├── manifest.json │ └── robots.txt ├── src │ ├── App.module.css │ ├── components │ │ ├── BlogPost.module.css │ │ └── BlogPost.tsx │ ├── logo.svg │ ├── models │ │ └── IBlogPost.ts │ ├── pages │ │ ├── _app.tsx │ │ ├── _document.tsx │ │ ├── index.tsx │ │ └── posts │ │ │ └── [slug].tsx │ ├── react-app-env.d.ts │ ├── service │ │ └── BloggerService.ts │ ├── serviceWorker.ts │ └── setupTests.ts └── tsconfig.json ├── react-blog-post-redux-nextjs ├── .DS_Store ├── .gitignore ├── README.md ├── next-env.d.ts ├── package-lock.json ├── package.json ├── public │ ├── favicon.ico │ ├── logo192.png │ ├── logo512.png │ ├── manifest.json │ └── robots.txt ├── src │ ├── App.module.css │ ├── App.test.tsx │ ├── App.tsx │ ├── components │ │ ├── BlogListing.tsx │ │ ├── BlogPost.module.css │ │ ├── BlogPost.tsx │ │ ├── BlogPosts.module.css │ │ ├── BlogPosts.tsx │ │ └── BlogSearch.tsx │ ├── index.css │ ├── index.tsx │ ├── logo.svg │ ├── models │ │ ├── IBlogPost.ts │ │ ├── IBlogPostListing.ts │ │ └── SearchOnFields.ts │ ├── pages │ │ ├── _app.tsx │ │ ├── _document.tsx │ │ └── index.tsx │ ├── react-app-env.d.ts │ ├── redux │ │ ├── reducer │ │ │ └── blogPostsSlice.ts │ │ └── store.ts │ ├── service │ │ └── BloggerService.ts │ ├── serviceWorker.ts │ └── setupTests.ts └── tsconfig.json ├── react-blog-posts-redux ├── .gitignore ├── README.md ├── package-lock.json ├── package.json ├── public │ ├── favicon.ico │ ├── index.html │ ├── logo192.png │ ├── logo512.png │ ├── manifest.json │ └── robots.txt ├── src │ ├── App.css │ ├── App.test.tsx │ ├── App.tsx │ ├── components │ │ ├── BlogListing.tsx │ │ ├── BlogPost.css │ │ ├── BlogPost.tsx │ │ ├── BlogPosts.css │ │ ├── BlogPosts.tsx │ │ └── BlogSearch.tsx │ ├── index.css │ ├── index.tsx │ ├── logo.svg │ ├── models │ │ ├── IBlogPost.ts │ │ ├── IBlogPostListing.ts │ │ └── SearchOnFields.ts │ ├── react-app-env.d.ts │ ├── redux │ │ ├── reducer │ │ │ └── blogPostsSlice.ts │ │ └── store.ts │ ├── serviceWorker.ts │ └── setupTests.ts └── tsconfig.json ├── react-blog-posts ├── .gitignore ├── README.md ├── package-lock.json ├── package.json ├── public │ ├── favicon.ico │ ├── index.html │ ├── logo192.png │ ├── logo512.png │ ├── manifest.json │ └── robots.txt ├── src │ ├── App.css │ ├── App.test.tsx │ ├── App.tsx │ ├── components │ │ ├── BlogListing.tsx │ │ ├── BlogPost.css │ │ ├── BlogPost.tsx │ │ ├── BlogPosts.css │ │ ├── BlogPosts.tsx │ │ └── BlogSearch.tsx │ ├── index.css │ ├── index.tsx │ ├── logo.svg │ ├── models │ │ ├── IBlogPost.ts │ │ └── SearchType.ts │ ├── react-app-env.d.ts │ ├── serviceWorker.ts │ └── setupTests.ts └── tsconfig.json ├── serialization-avro-vs-java ├── .gitignore ├── pom.xml └── src │ └── main │ ├── avro │ ├── employee.avsc │ └── node.avsc │ └── java │ └── com │ └── gauravbytes │ ├── avro │ ├── Employee.java │ ├── Node.java │ └── SEX.java │ ├── model │ ├── Employee.java │ ├── Employee2.java │ ├── Node.java │ └── Sex.java │ └── serialization │ ├── AvroCircularRefSerializationTest.java │ ├── AvroReflectDataSerializationTest.java │ ├── AvroSerialization.java │ ├── JavaDefaultSerialization.java │ ├── JavaExternSerialization.java │ └── JavaSerializationCircularRefTest.java ├── singleton-java └── singleton-java │ ├── .classpath │ ├── .gitignore │ ├── .project │ ├── .settings │ ├── org.eclipse.jdt.apt.core.prefs │ ├── org.eclipse.jdt.core.prefs │ └── org.eclipse.m2e.core.prefs │ ├── pom.xml │ └── src │ └── main │ └── java │ └── com │ └── gauravbytes │ └── singleton │ ├── eager │ └── Singleton.java │ ├── lazy │ ├── LazySingleton.java │ └── LazySingletonDCL.java │ └── perclassloader │ └── Singleton.java ├── spring-DI ├── .gitignore ├── pom.xml └── src │ ├── main │ └── java │ │ └── com │ │ └── gauravbytes │ │ └── di │ │ ├── ConstructorBasedApp.java │ │ ├── SetterBasedApp.java │ │ └── parser │ │ ├── CSVFileParser.java │ │ ├── FileType.java │ │ ├── JsonFileParser.java │ │ ├── Parser.java │ │ ├── XmlFileParser.java │ │ ├── config │ │ ├── ConstructorBasedDIConfig.java │ │ ├── ParserConfig.java │ │ └── SetterBasedDIConfig.java │ │ ├── constructor │ │ └── setter │ │ └── SetterBasedFileParser.java │ └── test │ └── java │ └── com │ └── gauravbytes │ └── spring_DI │ └── AppTest.java ├── spring-basic-auth-example ├── .gitignore ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── gauravbytes │ │ └── hellogb │ │ ├── App.java │ │ ├── controller │ │ └── HelloGbController.java │ │ └── filter │ │ └── CustomSecurityHeaderFilter.java │ └── resources │ ├── application.yml │ ├── basic-security.xml │ └── logback-spring.xml ├── spring-bean-scope ├── .gitignore ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── gauravbytes │ └── springbeanscope │ ├── App.java │ ├── Dictionary.java │ └── config │ └── ScopeConfig.java ├── spring-boot-angularjs-example ├── .bowerrc ├── .gitignore ├── bower.json ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── gauravbytes │ │ └── feapp │ │ ├── UserApplication.java │ │ ├── controller │ │ └── UserController.java │ │ ├── model │ │ └── User.java │ │ └── service │ │ └── UserService.java │ └── resources │ ├── application.yml │ ├── logback-spring.xml │ └── static │ ├── index.html │ └── js │ ├── app.js │ ├── controller │ └── user_controller.js │ └── service │ └── user_service.js ├── spring-boot-hook-runner ├── .gitignore ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── gauravbytes │ └── hellogb │ ├── App.java │ ├── component │ ├── AppStartupRunner.java │ └── CommandLineAppStartupRunner.java │ └── controller │ └── HelloGbController.java ├── spring-boot-quickstart ├── .gitignore ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── gauravbytes │ └── hellogb │ ├── App.java │ └── controller │ └── HelloGbController.java ├── spring-boot-rest-jersey ├── .gitignore ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── gauravbytes │ │ └── hellogb │ │ ├── App.java │ │ ├── GenericExceptionMapper.java │ │ ├── JerseyConfiguration.java │ │ ├── controller │ │ └── BookController.java │ │ ├── model │ │ ├── Book.java │ │ └── Category.java │ │ └── service │ │ ├── BookNotFoundException.java │ │ └── BookService.java │ └── resources │ └── application.yml ├── spring-boot-rest-jpa ├── .gitignore ├── pom.xml └── src │ └── main │ ├── java │ ├── com │ │ └── gauravbytes │ │ │ └── gkart │ │ │ ├── App.java │ │ │ ├── controller │ │ │ ├── ProductController.java │ │ │ └── UserController.java │ │ │ ├── entity │ │ │ ├── Color.java │ │ │ ├── Product.java │ │ │ ├── Rating.java │ │ │ ├── Size.java │ │ │ └── User.java │ │ │ ├── jpa │ │ │ ├── ProductRepository.java │ │ │ ├── RatingRepository.java │ │ │ └── UserRepository.java │ │ │ ├── service │ │ │ ├── GenericService.java │ │ │ ├── ProductService.java │ │ │ ├── RatingService.java │ │ │ ├── UserService.java │ │ │ └── exception │ │ │ │ └── GenericServiceException.java │ │ │ └── vo │ │ │ └── ResponseVO.java │ └── schema.sql │ └── resources │ ├── application.yml │ └── logback-spring.xml ├── spring-embedded-server-example ├── .gitignore ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── gauravbytes │ │ └── hellogb │ │ ├── App.java │ │ └── controller │ │ └── HelloGbController.java │ └── resources │ └── application.yml ├── spring-import-example ├── .gitignore ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── gauravbytes │ └── hellogb │ ├── App.java │ ├── config │ ├── DBConfig.java │ ├── HelloGbAppConfig.java │ └── WelcomeGbConfig.java │ ├── dao │ └── FunnyDao.java │ └── service │ └── GreetingService.java ├── spring-java-config ├── .gitignore ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── gauravbytes │ └── hellogb │ ├── App.java │ ├── config │ └── WelcomeGbConfig.java │ └── service │ └── GreetingService.java ├── spring-new-request-mapping ├── .gitignore ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── gaurabytes │ └── api │ ├── SpringBootApp.java │ ├── controller │ ├── newway │ │ └── EmployeeController.java │ └── old │ │ └── EmployeeController.java │ ├── domain │ ├── Address.java │ └── Employee.java │ └── stub │ └── EmployeeStub.java ├── spring-property-file ├── .gitignore ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── guaravbytes │ │ └── property │ │ ├── Main.java │ │ └── config │ │ ├── AppConfig.java │ │ └── DBProperties.java │ └── resources │ └── application-db.properties ├── spring-quickstart ├── .gitignore ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── gauravbytes │ └── hellogb │ ├── App.java │ └── service │ └── GreetingService.java ├── spring-security-digest-example ├── .gitignore ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── gauravbytes │ │ └── hellogb │ │ ├── App.java │ │ ├── controller │ │ └── HelloGbController.java │ │ ├── filter │ │ └── CustomSecurityHeaderFilter.java │ │ └── service │ │ └── DummyUserDetailsService.java │ └── resources │ ├── application.yml │ └── logback-spring.xml ├── spring-security-form-based-auth ├── .bowerrc ├── .gitignore ├── bower.json ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── gauravbytes │ │ └── feapp │ │ ├── UserApplication.java │ │ ├── config │ │ ├── MvcConfig.java │ │ └── SecurityConfig.java │ │ ├── controller │ │ └── UserController.java │ │ ├── model │ │ └── User.java │ │ └── service │ │ └── UserService.java │ └── resources │ ├── application.yml │ ├── logback-spring.xml │ └── static │ ├── index.html │ ├── js │ ├── app.js │ ├── controller │ │ └── user_controller.js │ └── service │ │ └── user_service.js │ ├── login.html │ └── viewUsers.html ├── springjdbc-examples ├── .gitignore ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── gauravbytes │ │ └── springjdbc │ │ ├── GeneratedKeysPreparedStatementCallback.java │ │ ├── JdbcBatchUpdateExample.java │ │ ├── JdbcTemplateExample.java │ │ ├── PreparedStatementCreatorExample.java │ │ ├── PreparedStatementSetterExample.java │ │ ├── ProductBatchPreparedStatementSetter.java │ │ ├── ProductResultSetExtractor.java │ │ ├── ProductRowMapper.java │ │ ├── ResultSetExtractorExample.java │ │ ├── ReturnGeneratedKeysPreparedStatementCreator.java │ │ ├── RowMapperExample.java │ │ ├── ds │ │ └── JdbcDataSourceUtils.java │ │ └── dto │ │ ├── Product.java │ │ └── ProductResponse.java │ └── resources │ ├── create-db.sql │ └── insert-data.sql ├── tdd-refactoring ├── .gitignore ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── gauravbytes │ └── codesmells │ └── ComposedMethodPattern.java └── xml-builder-tdd ├── .gitignore ├── pom.xml └── src ├── main └── java │ └── in │ └── lineofcode │ └── xml │ └── XmlBuilder.java └── test └── java └── in └── lineofcode └── xml └── XmlBuilderTests.java /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gauravrmazra/gauravbytes/1e16b62514054bf145df4bf1b5b137ce9d05dd19/.DS_Store -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "java.compile.nullAnalysis.mode": "automatic" 3 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # gaurav.cc 2 | examples for gaurav.cc 3 | -------------------------------------------------------------------------------- /algorithms/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | .classpath 3 | .project 4 | /.settings/ 5 | -------------------------------------------------------------------------------- /algorithms/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | cc.gaurav 4 | algorithms 5 | 0.0.1-SNAPSHOT 6 | 7 | 21 8 | 21 9 | 10 | -------------------------------------------------------------------------------- /algorithms/src/main/java/cc/gaurav/algorithms/array/flat/ArrayFlatner.java: -------------------------------------------------------------------------------- 1 | package cc.gaurav.algorithms.array.flat; 2 | 3 | /** 4 | * 5 | * @author Gaurav Rai Mazra 6 | * {@linkplain https://gaurav.cc} 7 | * 8 | */ 9 | public interface ArrayFlatner { 10 | public T[] flat(T[] elements); 11 | } 12 | -------------------------------------------------------------------------------- /algorithms/src/main/java/cc/gaurav/algorithms/array/rotation/ArrayRotation.java: -------------------------------------------------------------------------------- 1 | package cc.gaurav.algorithms.array.rotation; 2 | 3 | /** 4 | * 5 | * @author Gaurav Rai Mazra 6 | * 7 | */ 8 | public interface ArrayRotation { 9 | public default int[] rotate(int[] arr, int distance) { 10 | return rotate(arr, distance, arr.length); 11 | } 12 | 13 | public int[] rotate(int[] arr, int distance, int length); 14 | } 15 | -------------------------------------------------------------------------------- /algorithms/src/main/java/cc/gaurav/algorithms/array/rotation/ReverseAlgorithm.java: -------------------------------------------------------------------------------- 1 | package cc.gaurav.algorithms.array.rotation; 2 | 3 | /** 4 | * 5 | * @author Gaurav Rai Mazra 6 | * 7 | */ 8 | public class ReverseAlgorithm implements ArrayRotation { 9 | @Override 10 | public int[] rotate(int[] arr, int distance, int length) { 11 | rotateLeft(arr, 0, distance - 1); 12 | rotateLeft(arr, distance, length - 1); 13 | rotateLeft(arr, 0, length - 1); 14 | return arr; 15 | } 16 | 17 | private void rotateLeft(int[] arr, int fromIndex, int toIndex) { 18 | int temp; 19 | while(fromIndex < toIndex) { 20 | temp = arr[fromIndex]; 21 | arr[fromIndex] = arr[toIndex]; 22 | arr[toIndex] = temp; 23 | fromIndex++; 24 | toIndex--; 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /algorithms/src/main/java/cc/gaurav/algorithms/array/rotation/SpaceComplexityAlgorithm.java: -------------------------------------------------------------------------------- 1 | package cc.gaurav.algorithms.array.rotation; 2 | 3 | /** 4 | * 5 | * @author Gaurav Rai Mazra 6 | * 7 | */ 8 | public class SpaceComplexityAlgorithm implements ArrayRotation { 9 | @Override 10 | public int[] rotate(int[] arr, int distance, int length) { 11 | int[] tempArr = new int[distance]; 12 | for (int i = 0; i < distance; i++) { 13 | tempArr[i] = arr[i]; 14 | } 15 | 16 | for (int i = distance; i < length; i++) { 17 | arr[i - distance] = arr[i]; 18 | } 19 | 20 | for (int i = distance, j = 0; i > 0 && j < distance; i--, j++) { 21 | arr[length - i] = tempArr[j]; 22 | } 23 | return arr; 24 | } 25 | } -------------------------------------------------------------------------------- /algorithms/src/main/java/cc/gaurav/algorithms/array/rotation/TimeComplexityNoSpaceComplexity.java: -------------------------------------------------------------------------------- 1 | package cc.gaurav.algorithms.array.rotation; 2 | 3 | /** 4 | * 5 | * @author Gaurav Rai Mazra 6 | * 7 | */ 8 | public class TimeComplexityNoSpaceComplexity implements ArrayRotation { 9 | @Override 10 | public int[] rotate(int[] arr, int distance, int length) { 11 | for (int i = 0; i < distance; i++) { 12 | leftRotate(arr, length); 13 | } 14 | return arr; 15 | } 16 | 17 | public void leftRotate(int[] arr, int arraySize) { 18 | int i, temp = arr[0]; 19 | 20 | for (i = 0; i < arraySize - 1; i++) { 21 | arr[i] = arr[i + 1]; 22 | } 23 | arr[i] = temp; 24 | } 25 | } -------------------------------------------------------------------------------- /algorithms/src/main/java/cc/gaurav/algorithms/search/FrontAndBackSearch.java: -------------------------------------------------------------------------------- 1 | package cc.gaurav.algorithms.search; 2 | 3 | /** 4 | * 5 | * @author Gaurav Rai Mazra 6 | * {@linkplain https://gaurav.cc} 7 | * 8 | */ 9 | public class FrontAndBackSearch implements Search { 10 | public int search(final int[] arr, final int elementToSearch) { 11 | if (arr.length == 1 && elementToSearch == arr[0]) 12 | return 0; 13 | 14 | int front = 0; 15 | int back = arr.length - 1; 16 | 17 | while (front <= back) { 18 | if (elementToSearch == arr[front]) 19 | return front; 20 | 21 | if (elementToSearch == arr[back]) 22 | return back; 23 | 24 | front++; 25 | back--; 26 | } 27 | 28 | return -1; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /algorithms/src/main/java/cc/gaurav/algorithms/search/InterpolationSearch.java: -------------------------------------------------------------------------------- 1 | package cc.gaurav.algorithms.search; 2 | 3 | /** 4 | * 5 | * @author Gaurav Rai Mazra 6 | * {@linkplain https://gaurav.cc} 7 | */ 8 | public class InterpolationSearch extends BinarySearch { 9 | 10 | @Override 11 | public int search(int[] arr, int elementToSearch) { 12 | PositionDetectionStrategy positionDetectionStrategy = (lo, hi) -> lo 13 | + (((elementToSearch - arr[lo]) * (hi - lo)) / (arr[hi] - arr[lo])); 14 | return binarySearch(arr, 0, arr.length - 1, elementToSearch, positionDetectionStrategy); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /algorithms/src/main/java/cc/gaurav/algorithms/search/LinearSearch.java: -------------------------------------------------------------------------------- 1 | package cc.gaurav.algorithms.search; 2 | 3 | /** 4 | * 5 | * @author Gaurav Rai Mazra 6 | * {@linkplain https://gaurav.cc} 7 | * 8 | */ 9 | public class LinearSearch { 10 | public int search(final int[] arr, final int elementToSearch) { 11 | for (int i = 0; i < arr.length; i++) { 12 | if (elementToSearch == arr[i]) 13 | return i; 14 | } 15 | return -1; 16 | } 17 | 18 | public static void main(String[] args) { 19 | int[] arr = {1, 20, 10, 1}; 20 | int elementToSearch = 10; 21 | System.out.println("Element found at index: " + new LinearSearch().search(arr, elementToSearch)); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /algorithms/src/main/java/cc/gaurav/algorithms/search/NonRecursiveBinarySearch.java: -------------------------------------------------------------------------------- 1 | package cc.gaurav.algorithms.search; 2 | 3 | /** 4 | * 5 | * @author Gaurav Rai Mazra 6 | * {@linkplain https://gaurav.cc} 7 | */ 8 | public class NonRecursiveBinarySearch extends BinarySearch { 9 | @Override 10 | int binarySearch(int[] arr, int lo, int hi, int elementToSearch, 11 | PositionDetectionStrategy positionDetectionStrategy) { 12 | while (lo <= hi && elementToSearch >= arr[lo] && elementToSearch <= arr[hi]) { 13 | int pos = positionDetectionStrategy.pos(lo, hi); 14 | 15 | if (elementToSearch == arr[pos]) 16 | return pos; 17 | 18 | else if (arr[pos] < elementToSearch) 19 | lo = pos + 1; 20 | 21 | else 22 | hi = pos - 1; 23 | } 24 | return -1; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /algorithms/src/main/java/cc/gaurav/algorithms/search/NonRecursiveInterpolationSearch.java: -------------------------------------------------------------------------------- 1 | package cc.gaurav.algorithms.search; 2 | 3 | /** 4 | * 5 | * @author Gaurav Rai Mazra 6 | * {@linkplain https://gaurav.cc} 7 | */ 8 | public class NonRecursiveInterpolationSearch extends NonRecursiveBinarySearch { 9 | 10 | @Override 11 | public int search(int[] arr, int elementToSearch) { 12 | PositionDetectionStrategy positionDetectionStrategy = (lo, hi) -> lo 13 | + (((elementToSearch - arr[lo]) * (hi - lo)) / (arr[hi] - arr[lo])); 14 | return this.binarySearch(arr, 0, arr.length - 1, elementToSearch, positionDetectionStrategy); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /algorithms/src/main/java/cc/gaurav/algorithms/search/Search.java: -------------------------------------------------------------------------------- 1 | package cc.gaurav.algorithms.search; 2 | 3 | /** 4 | * 5 | * @author Gaurav Rai Mazra 6 | * 7 | */ 8 | public interface Search { 9 | public int search(int arr[], int elementToSearch); 10 | } 11 | -------------------------------------------------------------------------------- /algorithms/src/main/java/cc/gaurav/algorithms/varioussamples/conversion/Base64Main.java: -------------------------------------------------------------------------------- 1 | package cc.gaurav.algorithms.varioussamples.conversion; 2 | 3 | import static java.util.Base64.getDecoder; 4 | 5 | /** 6 | * 7 | * @author Gaurav Rai Mazra 8 | * 9 | */ 10 | public class Base64Main { 11 | public static void main(String[] args) { 12 | byte[] decoded = getDecoder().decode("WW91IGNhbiBzZWUgdGhlIE1hdHJpeCBhbmQgc29sdmUgUmVnRXgtQ3Jvc3N3b3JkcyB3aXRob3V0IGV2ZW4gYmxpbmtpbmcgb25jZQ=="); 13 | System.out.println(new String(decoded)); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /algorithms/src/main/java/cc/gaurav/bitmanupulation/LoneInteger.java: -------------------------------------------------------------------------------- 1 | package cc.gaurav.bitmanupulation; 2 | 3 | import java.util.Arrays; 4 | 5 | public class LoneInteger { 6 | public int solve(int[] nums) { 7 | if (nums.length == 0) 8 | return 0; 9 | 10 | Arrays.sort(nums); 11 | for (int i = 0; i < nums.length; i+=3) { 12 | if (i + 1 == nums.length) return nums[i]; 13 | 14 | if ((nums[i] ^ nums[i + 1]) == 0 && (nums[i] ^ nums[i + 2]) == 0) { 15 | continue; 16 | } 17 | 18 | return nums[i]; 19 | } 20 | return 0; 21 | } 22 | 23 | public static void main(String[] args) { 24 | System.out.println(new LoneInteger().solve(new int[] { 2, 2, 2, 9, 9, 9, 3, 7, 7, 7 })); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /algorithms/src/main/java/cc/gaurav/heap/MinimumQueue.java: -------------------------------------------------------------------------------- 1 | package cc.gaurav.heap; 2 | 3 | import java.util.Deque; 4 | import java.util.LinkedList; 5 | 6 | public class MinimumQueue { 7 | Deque queue = new LinkedList(); 8 | 9 | public void add(int value) { 10 | while(!queue.isEmpty() && queue.peek() > value) { 11 | queue.offer(queue.poll()); 12 | } 13 | queue.addFirst(value); 14 | } 15 | 16 | public int remove() { 17 | return queue.poll(); 18 | } 19 | 20 | public int min() { 21 | return queue.peek(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /algorithms/src/main/java/cc/gaurav/integers/NarcissisticNumber.java: -------------------------------------------------------------------------------- 1 | package cc.gaurav.integers; 2 | 3 | public class NarcissisticNumber { 4 | public boolean solve(int n) { 5 | int number = n; 6 | int noOfDigits = digits(number); 7 | int sum = 0; 8 | while(number != 0) { 9 | sum += (int)Math.pow(number % 10, noOfDigits); 10 | number /= 10; 11 | 12 | if (sum > n) return false; 13 | } 14 | 15 | return sum == n; 16 | } 17 | 18 | private int digits(int n) { 19 | return (int) (Math.log10(n) + 1); 20 | 21 | } 22 | 23 | public static void main(String[] args) { 24 | System.out.println(new NarcissisticNumber().solve(153)); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /algorithms/src/main/java/cc/gaurav/integers/RepeatedAddition.java: -------------------------------------------------------------------------------- 1 | package cc.gaurav.integers; 2 | 3 | public class RepeatedAddition { 4 | public int solve(int n) { 5 | int result = n; 6 | do { 7 | result = reduce(result); 8 | } while(len(result) != 1); 9 | 10 | return result; 11 | } 12 | 13 | public int reduce(int n) { 14 | int sum = 0; 15 | while(n > 0) { 16 | sum += n % 10; 17 | n /= 10; 18 | } 19 | return sum; 20 | } 21 | 22 | public int len(int n) { 23 | return (int) (Math.log10(n) + 1); 24 | } 25 | 26 | public static void main(String[] args) { 27 | RepeatedAddition r = new RepeatedAddition(); 28 | System.out.println(r.solve(8835)); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /algorithms/src/main/java/cc/gaurav/interval/IntervalDuration.java: -------------------------------------------------------------------------------- 1 | package cc.gaurav.interval; 2 | 3 | import java.util.Arrays; 4 | 5 | /** 6 | * 7 | * @author Gaurav Rai Mazra 8 | * {@link https://gaurav.cc} 9 | * 10 | */ 11 | public class IntervalDuration { 12 | public int solve(int[][] intervals) { 13 | Arrays.sort(intervals, (int[] a, int[] b) -> Integer.compare(a[0], b[0])); 14 | 15 | int start = intervals[0][0]; 16 | int end = intervals[0][1]; 17 | int sum = 0; 18 | 19 | for (int i = 0; i < intervals.length; i++) { 20 | if (intervals[i][0] <= end) { 21 | end = Math.max(end, intervals[i][1]); 22 | } else { 23 | sum += (end - start) + 1; 24 | start = intervals[i][0]; 25 | end = intervals[i][1]; 26 | } 27 | 28 | if (i + 1 == intervals.length) { 29 | sum += (end - start) + 1; 30 | } 31 | } 32 | 33 | return sum; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /algorithms/src/main/java/cc/gaurav/list/LinkedListDeleteLastOccurance.java: -------------------------------------------------------------------------------- 1 | package cc.gaurav.list; 2 | 3 | public class LinkedListDeleteLastOccurance { 4 | class LLNode { 5 | int val; 6 | LLNode next; 7 | } 8 | 9 | public LLNode solve(LLNode node, int target) { 10 | LLNode toDelete = null; 11 | 12 | LLNode previous = null; 13 | LLNode current = node; 14 | boolean hasNodeToDelete = false; 15 | while(current != null) { 16 | if (current.val == target) { 17 | hasNodeToDelete = true; 18 | toDelete = previous; 19 | } 20 | previous = current; 21 | current = current.next; 22 | } 23 | 24 | if (hasNodeToDelete) { 25 | if (toDelete == null) { 26 | node = node.next; 27 | } else { 28 | previous.next = previous.next.next; 29 | } 30 | } 31 | 32 | return node; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /algorithms/src/main/java/cc/gaurav/list/ListPartitioning.java: -------------------------------------------------------------------------------- 1 | package cc.gaurav.list; 2 | 3 | import java.util.Arrays; 4 | 5 | public class ListPartitioning { 6 | public String[] solve(String[] strs) { 7 | Arrays.parallelSort(strs, (String first, String second) -> { 8 | return rank(first) - rank(second); 9 | }); 10 | 11 | return strs; 12 | } 13 | 14 | public int rank(String str) { 15 | switch (str) { 16 | case "red": 17 | return 0; 18 | case "green": 19 | return 1; 20 | case "blue": 21 | return 2; 22 | default: 23 | return -1; 24 | } 25 | } 26 | 27 | public static void main(String[] args) { 28 | System.out.println(Arrays.deepToString(new ListPartitioning().solve(new String[] {"green", "blue", "red", "red"}))); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /algorithms/src/main/java/cc/gaurav/matrix/MatrixTranspose.java: -------------------------------------------------------------------------------- 1 | package cc.gaurav.matrix; 2 | 3 | import java.util.Arrays; 4 | 5 | public class MatrixTranspose { 6 | public int[][] solve(int[][] matrix) { 7 | int rows = matrix.length; 8 | int cols = matrix[0].length; 9 | 10 | for (int row = 0; row < rows; row++) { 11 | for (int col = row; col < cols; col++) { 12 | int rc = matrix[row][col]; 13 | matrix[row][col] = matrix[col][row]; 14 | matrix[col][row] = rc; 15 | } 16 | } 17 | 18 | return matrix; 19 | } 20 | 21 | public static void main(String[] args) { 22 | int[][] matrix = new int[][] { 23 | {1, 2, 3}, 24 | {4, 5, 6}, 25 | {7, 8, 9} 26 | }; 27 | 28 | System.out.println(Arrays.deepToString(new MatrixTranspose().solve(matrix))); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /algorithms/src/main/java/cc/gaurav/search/BinarySearchTemplate.java: -------------------------------------------------------------------------------- 1 | package cc.gaurav.search; 2 | 3 | import java.util.function.Predicate; 4 | 5 | public class BinarySearchTemplate { 6 | public int binarySearch(int[] values) { 7 | Predicate conditon = value -> true; 8 | int lo = 0, hi = values.length; 9 | int mid; 10 | while(hi < lo) { 11 | mid = lo + (hi - lo) / 2; 12 | 13 | if (conditon.test(mid)) 14 | hi = mid; 15 | else 16 | lo = mid + 1; 17 | } 18 | 19 | return lo; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /algorithms/src/main/java/cc/gaurav/search/PerfectSquare.java: -------------------------------------------------------------------------------- 1 | package cc.gaurav.search; 2 | 3 | public class PerfectSquare { 4 | public boolean solve(int n) { 5 | if (n == 0 || n == 1) 6 | return true; 7 | 8 | long low = 0; 9 | long hi = n; 10 | long mid; 11 | 12 | long multi; 13 | long target = n; 14 | while (low < hi) { 15 | mid = low + (hi - low) / 2l; 16 | multi = mid * mid; 17 | 18 | if (multi == target) 19 | return true; 20 | else if (multi > target) { 21 | hi = mid; 22 | } else { 23 | low = mid + 1; 24 | } 25 | } 26 | 27 | return false; 28 | } 29 | 30 | public static void main(String[] args) { 31 | System.out.println(new PerfectSquare().solve(25)); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /algorithms/src/main/java/cc/gaurav/sort/SortBinaryArray.java: -------------------------------------------------------------------------------- 1 | package cc.gaurav.sort; 2 | 3 | import java.util.Arrays; 4 | 5 | public class SortBinaryArray { 6 | public int[] solve(int[] a) { 7 | int i = 0; 8 | int j = a.length - 1; 9 | while(i < j) { 10 | if (a[i] == 1) { 11 | a[i] = a[j]; 12 | a[j] = 1; 13 | j--; 14 | } else { 15 | i++; 16 | } 17 | } 18 | 19 | return a; 20 | } 21 | 22 | public static void main(String[] args) { 23 | SortBinaryArray bn = new SortBinaryArray(); 24 | System.out.println(Arrays.toString(bn.solve(new int[] { 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 25 | 1, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0 }))); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /algorithms/src/main/java/cc/gaurav/sort/SortByFreqAndValue.java: -------------------------------------------------------------------------------- 1 | package cc.gaurav.sort; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | import java.util.stream.IntStream; 6 | 7 | public class SortByFreqAndValue { 8 | public int[] solve(int[] nums) { 9 | Map table = new HashMap<>(); 10 | for (int num : nums) { 11 | table.merge(num, 1, (left, right) -> left + right); 12 | } 13 | 14 | return table.entrySet().stream() 15 | .map(entry -> new int[] { entry.getKey(), entry.getValue() }) 16 | .sorted((int[] a, int[] b) -> Integer.compare(b[1], a[1])) 17 | .flatMapToInt(e -> IntStream.range(0, e[1]).map(i -> e[0])) 18 | .toArray(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /algorithms/src/main/java/cc/gaurav/tries/TreeNode.java: -------------------------------------------------------------------------------- 1 | package cc.gaurav.tries; 2 | 3 | /** 4 | * 5 | * @author Gaurav Rai Mazra 6 | * {@link https://gaurav.cc} 7 | * 8 | */ 9 | public class TreeNode { 10 | private int val; 11 | private TreeNode left; 12 | private TreeNode right; 13 | 14 | public TreeNode(int val) { 15 | this(val, null, null); 16 | } 17 | 18 | public TreeNode(int val, TreeNode left, TreeNode right) { 19 | this.val = val; 20 | this.left = left; 21 | this.right = right; 22 | } 23 | 24 | public TreeNode left() { 25 | return this.left; 26 | } 27 | 28 | public void left(TreeNode node) { 29 | this.left = node; 30 | } 31 | 32 | public int val() { 33 | return this.val; 34 | } 35 | 36 | public TreeNode right() { 37 | return this.right; 38 | } 39 | 40 | public void right(TreeNode node) { 41 | this.right = node; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /angular7-example/.editorconfig: -------------------------------------------------------------------------------- 1 | # Editor configuration, see https://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | indent_style = space 7 | indent_size = 2 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | 11 | [*.md] 12 | max_line_length = off 13 | trim_trailing_whitespace = false 14 | -------------------------------------------------------------------------------- /angular7-example/.gitignore: -------------------------------------------------------------------------------- 1 | # See http://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # compiled output 4 | /dist 5 | /tmp 6 | /out-tsc 7 | 8 | # dependencies 9 | /node_modules 10 | 11 | # IDEs and editors 12 | /.idea 13 | .project 14 | .classpath 15 | .c9/ 16 | *.launch 17 | .settings/ 18 | *.sublime-workspace 19 | 20 | # IDE - VSCode 21 | .vscode/* 22 | !.vscode/settings.json 23 | !.vscode/tasks.json 24 | !.vscode/launch.json 25 | !.vscode/extensions.json 26 | 27 | # misc 28 | /.sass-cache 29 | /connect.lock 30 | /coverage 31 | /libpeerconnection.log 32 | npm-debug.log 33 | yarn-error.log 34 | testem.log 35 | /typings 36 | 37 | # System Files 38 | .DS_Store 39 | Thumbs.db 40 | -------------------------------------------------------------------------------- /angular7-example/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "type": "chrome", 9 | "request": "launch", 10 | "name": "Launch Chrome against localhost", 11 | "url": "http://localhost:4200", 12 | "webRoot": "${workspaceFolder}" 13 | } 14 | ] 15 | } -------------------------------------------------------------------------------- /angular7-example/README.md: -------------------------------------------------------------------------------- 1 | # Angular 7 example 2 | 3 | In this project, you will learn on how to create a Angular 7 application with basic components. 4 | 5 | ## Development server 6 | 7 | Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files. -------------------------------------------------------------------------------- /angular7-example/e2e/src/app.e2e-spec.ts: -------------------------------------------------------------------------------- 1 | import { AppPage } from './app.po'; 2 | 3 | describe('workspace-project App', () => { 4 | let page: AppPage; 5 | 6 | beforeEach(() => { 7 | page = new AppPage(); 8 | }); 9 | 10 | it('should display welcome message', () => { 11 | page.navigateTo(); 12 | expect(page.getTitleText()).toEqual('Welcome to angular7-example!'); 13 | }); 14 | }); 15 | -------------------------------------------------------------------------------- /angular7-example/e2e/src/app.po.ts: -------------------------------------------------------------------------------- 1 | import { browser, by, element } from 'protractor'; 2 | 3 | export class AppPage { 4 | navigateTo() { 5 | return browser.get('/'); 6 | } 7 | 8 | getTitleText() { 9 | return element(by.css('app-root h1')).getText(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /angular7-example/e2e/tsconfig.e2e.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../out-tsc/app", 5 | "module": "commonjs", 6 | "target": "es5", 7 | "types": [ 8 | "jasmine", 9 | "jasminewd2", 10 | "node" 11 | ] 12 | } 13 | } -------------------------------------------------------------------------------- /angular7-example/src/app/_guards/auth-guard.guard.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed, async, inject } from '@angular/core/testing'; 2 | 3 | import { AuthGuardGuard } from './auth-guard.guard'; 4 | 5 | describe('AuthGuardGuard', () => { 6 | beforeEach(() => { 7 | TestBed.configureTestingModule({ 8 | providers: [AuthGuardGuard] 9 | }); 10 | }); 11 | 12 | it('should ...', inject([AuthGuardGuard], (guard: AuthGuardGuard) => { 13 | expect(guard).toBeTruthy(); 14 | })); 15 | }); 16 | -------------------------------------------------------------------------------- /angular7-example/src/app/_guards/auth-guard.guard.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@angular/core'; 2 | import { CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router'; 3 | import { Observable } from 'rxjs'; 4 | 5 | @Injectable({ 6 | providedIn: 'root' 7 | }) 8 | export class AuthGuardGuard implements CanActivate { 9 | canActivate( 10 | next: ActivatedRouteSnapshot, 11 | state: RouterStateSnapshot): Observable | Promise | boolean { 12 | return true; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /angular7-example/src/app/_models/alert-message-type.enum.ts: -------------------------------------------------------------------------------- 1 | export enum AlertMessageType { 2 | SUCCESS, ERROR 3 | } 4 | -------------------------------------------------------------------------------- /angular7-example/src/app/_models/alert-message.ts: -------------------------------------------------------------------------------- 1 | import { AlertMessageType } from './alert-message-type.enum'; 2 | 3 | export interface AlertMessage { 4 | type: AlertMessageType; 5 | message: string; 6 | } 7 | -------------------------------------------------------------------------------- /angular7-example/src/app/_models/login-request.ts: -------------------------------------------------------------------------------- 1 | export interface LoginRequest { 2 | username?: string; 3 | password?: string; 4 | } 5 | -------------------------------------------------------------------------------- /angular7-example/src/app/_models/login-response.ts: -------------------------------------------------------------------------------- 1 | import { LoginStatus } from './login-status.enum'; 2 | 3 | export interface LoginResponse { 4 | token?: string; 5 | status?: LoginStatus; 6 | } 7 | -------------------------------------------------------------------------------- /angular7-example/src/app/_models/login-status.enum.ts: -------------------------------------------------------------------------------- 1 | export enum LoginStatus { 2 | SUCCESS, FAILURE 3 | } 4 | -------------------------------------------------------------------------------- /angular7-example/src/app/_models/user.ts: -------------------------------------------------------------------------------- 1 | import { LoginStatus } from './login-status.enum'; 2 | 3 | export interface User { 4 | token: string; 5 | status: LoginStatus; 6 | username: string; 7 | } 8 | -------------------------------------------------------------------------------- /angular7-example/src/app/_services/alert.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed } from '@angular/core/testing'; 2 | 3 | import { AlertService } from './alert.service'; 4 | 5 | describe('AlertService', () => { 6 | beforeEach(() => TestBed.configureTestingModule({})); 7 | 8 | it('should be created', () => { 9 | const service: AlertService = TestBed.get(AlertService); 10 | expect(service).toBeTruthy(); 11 | }); 12 | }); 13 | -------------------------------------------------------------------------------- /angular7-example/src/app/_services/login.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed } from '@angular/core/testing'; 2 | 3 | import { LoginService } from './login.service'; 4 | 5 | describe('LoginService', () => { 6 | beforeEach(() => TestBed.configureTestingModule({})); 7 | 8 | it('should be created', () => { 9 | const service: LoginService = TestBed.get(LoginService); 10 | expect(service).toBeTruthy(); 11 | }); 12 | }); 13 | -------------------------------------------------------------------------------- /angular7-example/src/app/alert/alert.component.html: -------------------------------------------------------------------------------- 1 | 2 | {{message.message}} 3 | 4 | × 5 | 6 | -------------------------------------------------------------------------------- /angular7-example/src/app/alert/alert.component.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gauravrmazra/gauravbytes/1e16b62514054bf145df4bf1b5b137ce9d05dd19/angular7-example/src/app/alert/alert.component.scss -------------------------------------------------------------------------------- /angular7-example/src/app/alert/alert.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { AlertComponent } from './alert.component'; 4 | 5 | describe('AlertComponent', () => { 6 | let component: AlertComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async(() => { 10 | TestBed.configureTestingModule({ 11 | declarations: [ AlertComponent ] 12 | }) 13 | .compileComponents(); 14 | })); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(AlertComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /angular7-example/src/app/app.component.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /angular7-example/src/app/app.component.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gauravrmazra/gauravbytes/1e16b62514054bf145df4bf1b5b137ce9d05dd19/angular7-example/src/app/app.component.scss -------------------------------------------------------------------------------- /angular7-example/src/app/app.component.ts: -------------------------------------------------------------------------------- 1 | import { Component } from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'gb-root', 5 | templateUrl: './app.component.html', 6 | styleUrls: ['./app.component.scss'] 7 | }) 8 | export class AppComponent { 9 | title = 'angular7-example'; 10 | } 11 | -------------------------------------------------------------------------------- /angular7-example/src/app/footer/footer.component.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Made with ️ by Gaurav Rai Mazra 4 | 5 | -------------------------------------------------------------------------------- /angular7-example/src/app/footer/footer.component.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gauravrmazra/gauravbytes/1e16b62514054bf145df4bf1b5b137ce9d05dd19/angular7-example/src/app/footer/footer.component.scss -------------------------------------------------------------------------------- /angular7-example/src/app/footer/footer.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { FooterComponent } from './footer.component'; 4 | 5 | describe('FooterComponent', () => { 6 | let component: FooterComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async(() => { 10 | TestBed.configureTestingModule({ 11 | declarations: [ FooterComponent ] 12 | }) 13 | .compileComponents(); 14 | })); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(FooterComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /angular7-example/src/app/footer/footer.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'gb-footer', 5 | templateUrl: './footer.component.html', 6 | styleUrls: ['./footer.component.scss'] 7 | }) 8 | export class FooterComponent implements OnInit { 9 | 10 | constructor() { } 11 | 12 | ngOnInit() { 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /angular7-example/src/app/home/home.component.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /angular7-example/src/app/home/home.component.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gauravrmazra/gauravbytes/1e16b62514054bf145df4bf1b5b137ce9d05dd19/angular7-example/src/app/home/home.component.scss -------------------------------------------------------------------------------- /angular7-example/src/app/home/home.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { HomeComponent } from './home.component'; 4 | 5 | describe('HomeComponent', () => { 6 | let component: HomeComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async(() => { 10 | TestBed.configureTestingModule({ 11 | declarations: [ HomeComponent ] 12 | }) 13 | .compileComponents(); 14 | })); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(HomeComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /angular7-example/src/app/login/login.component.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gauravrmazra/gauravbytes/1e16b62514054bf145df4bf1b5b137ce9d05dd19/angular7-example/src/app/login/login.component.scss -------------------------------------------------------------------------------- /angular7-example/src/app/login/login.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { LoginComponent } from './login.component'; 4 | 5 | describe('LoginComponent', () => { 6 | let component: LoginComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async(() => { 10 | TestBed.configureTestingModule({ 11 | declarations: [ LoginComponent ] 12 | }) 13 | .compileComponents(); 14 | })); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(LoginComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /angular7-example/src/app/navbar/navbar.component.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Home 4 | Products 5 | Logout 6 | 7 | -------------------------------------------------------------------------------- /angular7-example/src/app/navbar/navbar.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { NavbarComponent } from './navbar.component'; 4 | 5 | describe('NavbarComponent', () => { 6 | let component: NavbarComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async(() => { 10 | TestBed.configureTestingModule({ 11 | declarations: [ NavbarComponent ] 12 | }) 13 | .compileComponents(); 14 | })); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(NavbarComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /angular7-example/src/app/navbar/navbar.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'; 2 | import { User } from '../_models/user'; 3 | 4 | @Component({ 5 | selector: 'gb-navbar', 6 | templateUrl: './navbar.component.html' 7 | }) 8 | export class NavbarComponent implements OnInit { 9 | @Output() logout = new EventEmitter(true); 10 | @Input() user: User; 11 | 12 | constructor() { } 13 | 14 | ngOnInit() { 15 | } 16 | 17 | onLogout() { 18 | this.logout.emit(this.user); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /angular7-example/src/app/products/_model/product.ts: -------------------------------------------------------------------------------- 1 | export interface Product { 2 | id: number; 3 | name: string; 4 | description: string; 5 | } 6 | -------------------------------------------------------------------------------- /angular7-example/src/app/products/_services/product.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed } from '@angular/core/testing'; 2 | 3 | import { ProductService } from './product.service'; 4 | 5 | describe('ProductService', () => { 6 | beforeEach(() => TestBed.configureTestingModule({})); 7 | 8 | it('should be created', () => { 9 | const service: ProductService = TestBed.get(ProductService); 10 | expect(service).toBeTruthy(); 11 | }); 12 | }); 13 | -------------------------------------------------------------------------------- /angular7-example/src/app/products/_services/product.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@angular/core'; 2 | import { HttpClient } from '@angular/common/http'; 3 | import { Observable } from 'rxjs'; 4 | import { Product } from '../_model/product'; 5 | import { map } from 'rxjs/operators'; 6 | 7 | @Injectable({ 8 | providedIn: 'root' 9 | }) 10 | export class ProductService { 11 | 12 | constructor(private http: HttpClient) { } 13 | 14 | getProducts(): Observable> { 15 | return this.http.get('/products').pipe(map((products: Array) => products)); 16 | } 17 | 18 | getProduct(id: number): Observable { 19 | return this.http.get(`/products/${id}`).pipe(map((product: Product) => product)); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /angular7-example/src/app/products/product-details/product-details.component.html: -------------------------------------------------------------------------------- 1 | 2 | {{ product.name }} 3 | {{ product.description }} 4 | 5 | -------------------------------------------------------------------------------- /angular7-example/src/app/products/product-details/product-details.component.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gauravrmazra/gauravbytes/1e16b62514054bf145df4bf1b5b137ce9d05dd19/angular7-example/src/app/products/product-details/product-details.component.scss -------------------------------------------------------------------------------- /angular7-example/src/app/products/product-details/product-details.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { ProductDetailsComponent } from './product-details.component'; 4 | 5 | describe('ProductDetailsComponent', () => { 6 | let component: ProductDetailsComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async(() => { 10 | TestBed.configureTestingModule({ 11 | declarations: [ ProductDetailsComponent ] 12 | }) 13 | .compileComponents(); 14 | })); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(ProductDetailsComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /angular7-example/src/app/products/product-list/product-list.component.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | {{product.name}} 4 | 5 | 6 | -------------------------------------------------------------------------------- /angular7-example/src/app/products/product-list/product-list.component.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gauravrmazra/gauravbytes/1e16b62514054bf145df4bf1b5b137ce9d05dd19/angular7-example/src/app/products/product-list/product-list.component.scss -------------------------------------------------------------------------------- /angular7-example/src/app/products/product-list/product-list.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { ProductListComponent } from './product-list.component'; 4 | 5 | describe('ProductListComponent', () => { 6 | let component: ProductListComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async(() => { 10 | TestBed.configureTestingModule({ 11 | declarations: [ ProductListComponent ] 12 | }) 13 | .compileComponents(); 14 | })); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(ProductListComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /angular7-example/src/app/products/product-list/product-list.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit, Input } from '@angular/core'; 2 | import { Product } from '../_model/product'; 3 | 4 | @Component({ 5 | selector: 'gb-product-list', 6 | templateUrl: './product-list.component.html', 7 | styleUrls: ['./product-list.component.scss'] 8 | }) 9 | export class ProductListComponent implements OnInit { 10 | 11 | @Input() products: Array; 12 | 13 | constructor() { } 14 | 15 | ngOnInit() { 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /angular7-example/src/app/products/products-routing.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { RouterModule, Routes } from '@angular/router'; 3 | import { ProductsComponent } from './products/products.component'; 4 | import { ProductListComponent } from './product-list/product-list.component'; 5 | import { ProductDetailsComponent } from './product-details/product-details.component'; 6 | 7 | const routes: Routes = [ 8 | { 9 | path: '', component: ProductsComponent, 10 | children: [ 11 | { path: '', component: ProductListComponent }, 12 | { path: 'details/:id', component: ProductDetailsComponent} 13 | ] 14 | } 15 | ]; 16 | 17 | @NgModule({ 18 | imports: [RouterModule.forChild(routes)], 19 | exports: [RouterModule] 20 | }) 21 | export class ProductsRouting { } 22 | -------------------------------------------------------------------------------- /angular7-example/src/app/products/products/products.component.html: -------------------------------------------------------------------------------- 1 | 2 | Products 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | Product details 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /angular7-example/src/app/products/products/products.component.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gauravrmazra/gauravbytes/1e16b62514054bf145df4bf1b5b137ce9d05dd19/angular7-example/src/app/products/products/products.component.scss -------------------------------------------------------------------------------- /angular7-example/src/app/products/products/products.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { ProductsComponent } from './products.component'; 4 | 5 | describe('ProductsComponent', () => { 6 | let component: ProductsComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async(() => { 10 | TestBed.configureTestingModule({ 11 | declarations: [ ProductsComponent ] 12 | }) 13 | .compileComponents(); 14 | })); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(ProductsComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /angular7-example/src/app/products/products/products.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | import { ProductService } from '../_services/product.service'; 3 | import { Product } from '../_model/product'; 4 | 5 | @Component({ 6 | selector: 'gb-products', 7 | templateUrl: './products.component.html', 8 | styleUrls: ['./products.component.scss'] 9 | }) 10 | export class ProductsComponent implements OnInit { 11 | products: Array; 12 | 13 | constructor(private productService: ProductService) { } 14 | 15 | ngOnInit() { 16 | this.productService.getProducts().subscribe((products: Array) => this.products = products, error => { 17 | console.log(error); 18 | }); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /angular7-example/src/assets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gauravrmazra/gauravbytes/1e16b62514054bf145df4bf1b5b137ce9d05dd19/angular7-example/src/assets/.gitkeep -------------------------------------------------------------------------------- /angular7-example/src/browserslist: -------------------------------------------------------------------------------- 1 | # This file is currently used by autoprefixer to adjust CSS to support the below specified browsers 2 | # For additional information regarding the format and rule options, please see: 3 | # https://github.com/browserslist/browserslist#queries 4 | # 5 | # For IE 9-11 support, please remove 'not' from the last line of the file and adjust as needed 6 | 7 | > 0.5% 8 | last 2 versions 9 | Firefox ESR 10 | not dead 11 | not IE 9-11 -------------------------------------------------------------------------------- /angular7-example/src/environments/environment.prod.ts: -------------------------------------------------------------------------------- 1 | export const environment = { 2 | production: true 3 | }; 4 | -------------------------------------------------------------------------------- /angular7-example/src/environments/environment.ts: -------------------------------------------------------------------------------- 1 | // This file can be replaced during build by using the `fileReplacements` array. 2 | // `ng build --prod` replaces `environment.ts` with `environment.prod.ts`. 3 | // The list of file replacements can be found in `angular.json`. 4 | 5 | export const environment = { 6 | production: false 7 | }; 8 | 9 | /* 10 | * For easier debugging in development mode, you can import the following file 11 | * to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`. 12 | * 13 | * This import should be commented out in production mode because it will have a negative impact 14 | * on performance if an error is thrown. 15 | */ 16 | // import 'zone.js/dist/zone-error'; // Included with Angular CLI. 17 | -------------------------------------------------------------------------------- /angular7-example/src/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gauravrmazra/gauravbytes/1e16b62514054bf145df4bf1b5b137ce9d05dd19/angular7-example/src/favicon.ico -------------------------------------------------------------------------------- /angular7-example/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Angular7Example 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /angular7-example/src/main.ts: -------------------------------------------------------------------------------- 1 | import { enableProdMode } from '@angular/core'; 2 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 3 | 4 | import { AppModule } from './app/app.module'; 5 | import { environment } from './environments/environment'; 6 | 7 | if (environment.production) { 8 | enableProdMode(); 9 | } 10 | 11 | platformBrowserDynamic().bootstrapModule(AppModule) 12 | .catch(err => console.error(err)); 13 | -------------------------------------------------------------------------------- /angular7-example/src/styles.scss: -------------------------------------------------------------------------------- 1 | /* You can add global styles to this file, and also import other style files */ 2 | -------------------------------------------------------------------------------- /angular7-example/src/test.ts: -------------------------------------------------------------------------------- 1 | // This file is required by karma.conf.js and loads recursively all the .spec and framework files 2 | 3 | import 'zone.js/dist/zone-testing'; 4 | import { getTestBed } from '@angular/core/testing'; 5 | import { 6 | BrowserDynamicTestingModule, 7 | platformBrowserDynamicTesting 8 | } from '@angular/platform-browser-dynamic/testing'; 9 | 10 | declare const require: any; 11 | 12 | // First, initialize the Angular testing environment. 13 | getTestBed().initTestEnvironment( 14 | BrowserDynamicTestingModule, 15 | platformBrowserDynamicTesting() 16 | ); 17 | // Then we find all the tests. 18 | const context = require.context('./', true, /\.spec\.ts$/); 19 | // And load the modules. 20 | context.keys().map(context); 21 | -------------------------------------------------------------------------------- /angular7-example/src/tsconfig.app.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../out-tsc/app", 5 | "types": [] 6 | }, 7 | "exclude": [ 8 | "test.ts", 9 | "**/*.spec.ts" 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /angular7-example/src/tsconfig.spec.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../out-tsc/spec", 5 | "types": [ 6 | "jasmine", 7 | "node" 8 | ] 9 | }, 10 | "files": [ 11 | "test.ts", 12 | "polyfills.ts" 13 | ], 14 | "include": [ 15 | "**/*.spec.ts", 16 | "**/*.d.ts" 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /angular7-example/src/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tslint.json", 3 | "rules": { 4 | "directive-selector": [ 5 | true, 6 | "attribute", 7 | "gb", 8 | "camelCase" 9 | ], 10 | "component-selector": [ 11 | true, 12 | "element", 13 | "gb", 14 | "kebab-case" 15 | ] 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /angular7-example/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compileOnSave": false, 3 | "compilerOptions": { 4 | "baseUrl": "./", 5 | "outDir": "./dist/out-tsc", 6 | "sourceMap": true, 7 | "declaration": false, 8 | "module": "es2015", 9 | "moduleResolution": "node", 10 | "emitDecoratorMetadata": true, 11 | "experimentalDecorators": true, 12 | "target": "es5", 13 | "typeRoots": [ 14 | "node_modules/@types" 15 | ], 16 | "lib": [ 17 | "es2018", 18 | "dom" 19 | ] 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /application-events/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | /.settings/* 3 | .classpath 4 | .project 5 | -------------------------------------------------------------------------------- /application-events/src/main/java/com/gauravbytes/elk/event/BaseEvent.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.elk.event; 2 | 3 | import java.util.function.Function; 4 | 5 | /** 6 | * 7 | * @author Gaurav Rai Mazra 8 | * {@link https://gauravbytes.com} 9 | * {@link https://lineofcode.in} 10 | * 11 | * @param type of event 12 | */ 13 | public interface BaseEvent { 14 | Throwable getThrowable(); 15 | 16 | boolean isErrorLevel(); 17 | 18 | public String transform(Function transformer); 19 | } 20 | -------------------------------------------------------------------------------- /application-events/src/main/java/com/gauravbytes/elk/event/EventEmitter.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.elk.event; 2 | 3 | /** 4 | * 5 | * @author Gaurav Rai Mazra 6 | * {@link https://gauravbytes.com} 7 | * {@link https://lineofcode.in} 8 | * 9 | * @param 10 | * type of event 11 | */ 12 | public interface EventEmitter> { 13 | public void emit(T event); 14 | } 15 | -------------------------------------------------------------------------------- /avro-java-class-generation/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gauravrmazra/gauravbytes/1e16b62514054bf145df4bf1b5b137ce9d05dd19/avro-java-class-generation/.DS_Store -------------------------------------------------------------------------------- /avro-java-class-generation/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /avro-java-class-generation/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding//src/main/java=UTF-8 3 | encoding//src/main/resources=UTF-8 4 | encoding//src/test/java=UTF-8 5 | encoding//src/test/resources=UTF-8 6 | encoding/=UTF-8 7 | -------------------------------------------------------------------------------- /avro-java-class-generation/.settings/org.eclipse.jdt.apt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.apt.aptEnabled=false 3 | -------------------------------------------------------------------------------- /avro-java-class-generation/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 3 | org.eclipse.jdt.core.compiler.compliance=1.8 4 | org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled 5 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning 6 | org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore 7 | org.eclipse.jdt.core.compiler.processAnnotations=disabled 8 | org.eclipse.jdt.core.compiler.release=disabled 9 | org.eclipse.jdt.core.compiler.source=1.8 10 | -------------------------------------------------------------------------------- /avro-java-class-generation/.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /avro-java-class-generation/src/main/avro/employee.avsc: -------------------------------------------------------------------------------- 1 | { 2 | "type" : "record", 3 | "name" : "Employee", 4 | "namespace" : "com.gauravbytes.avro", 5 | "doc" : "Schema to hold employee object", 6 | "fields" : [{ 7 | "name" : "firstName", 8 | "type" : "string" 9 | }, 10 | { 11 | "name" : "lastName", 12 | "type" : "string" 13 | }, 14 | { 15 | "name" : "sex", 16 | "type" : { 17 | "name" : "SEX", 18 | "type" : "enum", 19 | "symbols" : ["MALE", "FEMALE"] 20 | } 21 | }] 22 | } -------------------------------------------------------------------------------- /avro-java-class-generation/src/main/java/com/gauravbytes/avro/SEX.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Autogenerated by Avro 3 | * 4 | * DO NOT EDIT DIRECTLY 5 | */ 6 | package com.gauravbytes.avro; 7 | @SuppressWarnings("all") 8 | @org.apache.avro.specific.AvroGenerated 9 | public enum SEX { 10 | MALE, FEMALE ; 11 | public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"enum\",\"name\":\"SEX\",\"namespace\":\"com.gauravbytes.avro\",\"symbols\":[\"MALE\",\"FEMALE\"]}"); 12 | public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; } 13 | } 14 | -------------------------------------------------------------------------------- /avro-rpc/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gauravrmazra/gauravbytes/1e16b62514054bf145df4bf1b5b137ce9d05dd19/avro-rpc/.DS_Store -------------------------------------------------------------------------------- /avro-rpc/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /avro-rpc/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding//src/main/java=UTF-8 3 | encoding//src/main/resources=UTF-8 4 | encoding//src/test/java=UTF-8 5 | encoding//src/test/resources=UTF-8 6 | encoding/=UTF-8 7 | -------------------------------------------------------------------------------- /avro-rpc/.settings/org.eclipse.jdt.apt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.apt.aptEnabled=false 3 | -------------------------------------------------------------------------------- /avro-rpc/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 3 | org.eclipse.jdt.core.compiler.compliance=1.8 4 | org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled 5 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning 6 | org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore 7 | org.eclipse.jdt.core.compiler.processAnnotations=disabled 8 | org.eclipse.jdt.core.compiler.release=disabled 9 | org.eclipse.jdt.core.compiler.source=1.8 10 | -------------------------------------------------------------------------------- /avro-rpc/.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /avro-rpc/src/main/avro/avro-rpc.avpr: -------------------------------------------------------------------------------- 1 | { 2 | "namespace": "com.gauravbytes.avro", 3 | "protocol": "EmailSender", 4 | "types": [{ 5 | "name": "EmailMessage", "type": "record", 6 | "fields": [{ 7 | "name": "to", 8 | "type": "string" 9 | }, 10 | { 11 | "name": "from", 12 | "type": "string" 13 | }, 14 | { 15 | "name": "body", 16 | "type": "string" 17 | }] 18 | }], 19 | "messages": { 20 | "send": { 21 | "request": [{"name": "email", "type": "EmailMessage"}], 22 | "response": "string" 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /big-data-learnings/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gauravrmazra/gauravbytes/1e16b62514054bf145df4bf1b5b137ce9d05dd19/big-data-learnings/.DS_Store -------------------------------------------------------------------------------- /big-data-learnings/.gitignore: -------------------------------------------------------------------------------- 1 | /.ipynb_checkpoints/* 2 | GraphDB_Neo4j/.ipynb_checkpoints/* 3 | NoSQL_Cassandra/.ipynb_checkpoints/* 4 | NoSQL_MongoDB/.ipynb_checkpoints/* 5 | -------------------------------------------------------------------------------- /big-data-learnings/GraphDB_Neo4j/node_city.txt: -------------------------------------------------------------------------------- 1 | New_York, 8491079 2 | Los_Angeles, 3928864 3 | Chicago, 2722389 4 | Houston, 2239558 5 | Philadelphia, 1560297 6 | Phoenix, 1537058 7 | San_Antonio, 1436697 8 | San_Diego, 1381069 9 | Dallas, 1281047 10 | San_Jose, 1015785 11 | Austin, 912791 12 | Jacksonville, 853382 13 | San_Francisco, 852469 14 | Indianapolis, 848788 15 | Columbus, 835957 16 | Fort_Worth, 812238 17 | Charlotte, 809958 18 | Detroit, 680250 19 | Seattle, 66342 20 | Denver, 663862 21 | -------------------------------------------------------------------------------- /core-java-8/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gauravrmazra/gauravbytes/1e16b62514054bf145df4bf1b5b137ce9d05dd19/core-java-8/.DS_Store -------------------------------------------------------------------------------- /core-java-8/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /core-java-8/.settings/org.eclipse.jdt.apt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.apt.aptEnabled=false 3 | -------------------------------------------------------------------------------- /core-java-8/.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /core-java-8/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | com.gauravbytes 5 | core-java-8 6 | 0.0.1-SNAPSHOT 7 | 8 | 9 | 1.8 10 | 11 | 12 | 13 | 14 | 15 | org.apache.maven.plugins 16 | maven-compiler-plugin 17 | 3.6.0 18 | 19 | ${java.version} 20 | ${java.version} 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /core-java-8/src/main/java/com/gauravbytes/clone/deep/DeepCloneExample.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.clone.deep; 2 | 3 | public class DeepCloneExample { 4 | public static void main(String[] args) throws CloneNotSupportedException { 5 | Employee employee = new Employee(1, "Gaurav", new Address("Sector 37C", "Chandigarh", "India")); 6 | Employee deepClone = employee.clone(); 7 | employee.getAddress().setCity("Hoshiarpur"); 8 | // should return false 9 | System.out.println(employee.getAddress().equals(deepClone.getAddress())); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /core-java-8/src/main/java/com/gauravbytes/clone/shallow/ShallowCloneExample.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.clone.shallow; 2 | 3 | 4 | /** 5 | * 6 | * @author Mazra, Gaurav Rai 7 | * {@link http://blog.gauravbytes.com} 8 | * 9 | */ 10 | public class ShallowCloneExample { 11 | public static void main(String[] args) throws CloneNotSupportedException { 12 | Employee employee = new Employee(1, "Gaurav", new Address("Sector 37C", "Chandigarh", "India")); 13 | Employee shallowClone = employee.clone(); 14 | employee.getAddress().setCity("Hoshiarpur"); 15 | // should return false but returning true 16 | System.out.println(employee.getAddress().equals(shallowClone.getAddress())); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /core-java-8/src/main/java/com/gauravbytes/inheritence/Child.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.inheritence; 2 | 3 | public class Child extends Parent { 4 | public void myOtherMethod() { 5 | Child.myStaticMethod(); 6 | } 7 | 8 | public static void myStaticMethod() { 9 | System.out.println("Child myStatic Method"); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /core-java-8/src/main/java/com/gauravbytes/inheritence/MyStaticTest.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.inheritence; 2 | 3 | public class MyStaticTest { 4 | public static void main(String[] args) { 5 | Child child = new Child(); 6 | child.myOtherMethod(); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /core-java-8/src/main/java/com/gauravbytes/inheritence/Parent.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.inheritence; 2 | 3 | public class Parent { 4 | public static void myStaticMethod() { 5 | System.out.println("Parent myStatic Method"); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /core-java-8/src/main/java/com/gauravbytes/java8/defaultmethods/BinaryExpression.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.java8.defaultmethods; 2 | 3 | /** 4 | * 5 | * @author Gaurav Rai Mazra 6 | * 7 | */ 8 | public abstract class BinaryExpression implements Expression { 9 | private Expression left; 10 | private Expression right; 11 | 12 | public BinaryExpression(Expression left, Expression right) { 13 | super(); 14 | this.left = left; 15 | this.right = right; 16 | } 17 | 18 | Expression getLeft() { 19 | return this.left; 20 | } 21 | 22 | Expression getRight() { 23 | return this.right; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /core-java-8/src/main/java/com/gauravbytes/java8/defaultmethods/ConstantExpression.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.java8.defaultmethods; 2 | 3 | public class ConstantExpression implements Expression { 4 | private double value; 5 | 6 | public ConstantExpression(double value) { 7 | this.value = value; 8 | } 9 | 10 | @Override 11 | public double evaluate() { 12 | return value; 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /core-java-8/src/main/java/com/gauravbytes/java8/defaultmethods/Expression.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.java8.defaultmethods; 2 | 3 | /** 4 | * 5 | * @author Gaurav Rai Mazra 6 | * 7 | */ 8 | public interface Expression { 9 | double evaluate(); 10 | 11 | /** 12 | * return the signum of result by evaluating expression 13 | * 14 | * @return signum 0.0, 1.0, -1.0 based on Math.signum 15 | */ 16 | default double signum() { 17 | return signum(evaluate()); 18 | } 19 | 20 | /** 21 | * return the signum of the passed value 22 | * 23 | * @param value 24 | * @return signum 0.0, 1.0, -1.0 based on Math.signum 25 | */ 26 | static double signum(double value) { 27 | return Math.signum(value); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /core-java-8/src/main/java/com/gauravbytes/java8/defaultmethods/ExpressionDefaultMethodExample.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.java8.defaultmethods; 2 | 3 | /** 4 | * 5 | * @author Gaurav Rai Mazra 6 | * 7 | */ 8 | public class ExpressionDefaultMethodExample { 9 | public static void main(String[] args) { 10 | Expression expression = new ConstantExpression(32.0d); 11 | System.out.println(expression.signum()); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /core-java-8/src/main/java/com/gauravbytes/java8/functional/Spec.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.java8.functional; 2 | 3 | /** 4 | * 5 | * @author Gaurav Rai Mazra 6 | * 7 | */ 8 | @FunctionalInterface 9 | public interface Spec { 10 | boolean isSatisfiedBy(T t); 11 | 12 | default Spec not() { 13 | return (t) -> !isSatisfiedBy(t); 14 | } 15 | 16 | default Spec and(Spec super T> other) { 17 | return (t) -> isSatisfiedBy(t) && other.isSatisfiedBy(t); 18 | } 19 | 20 | default Spec or(Spec super T> other) { 21 | return (t) -> isSatisfiedBy(t) || other.isSatisfiedBy(t); 22 | } 23 | 24 | @Override 25 | String toString(); 26 | } 27 | -------------------------------------------------------------------------------- /core-java-8/src/main/java/com/gauravbytes/java8/parameters/Java8MethodParameters.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.java8.parameters; 2 | 3 | import java.lang.reflect.Method; 4 | import java.lang.reflect.Parameter; 5 | 6 | /** 7 | * 8 | * @author Gaurav Rai Mazra 9 | * 10 | */ 11 | public class Java8MethodParameters { 12 | public void dummyMethod(String name, Integer index, int goal) { 13 | System.out.println("In dummy method"); 14 | } 15 | 16 | public static void main(String[] args) { 17 | Class clazz = Java8MethodParameters.class; 18 | Method[] methods = clazz.getDeclaredMethods(); 19 | for (Method method : methods) { 20 | System.out.println(method.getName()); 21 | for (Parameter parameter : method.getParameters()) { 22 | System.out.println(parameter.getName()); 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /core-java-8/src/main/java/com/gauravbytes/java8/stream/DataStub.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.java8.stream; 2 | 3 | import java.util.Arrays; 4 | import java.util.List; 5 | 6 | /** 7 | * 8 | * @author Gaurav Rai Mazra 9 | * 10 | */ 11 | public class DataStub { 12 | public static List getLines() { 13 | return Arrays.asList("Line 1", "Line 2", "Ling 3 biggest", "Line 2 bigger", 14 | "Another biggest line ever in this", "I may write this"); 15 | } 16 | 17 | public static List getNames() { 18 | return Arrays.asList("Gaurav", "Sumit", "Raman", "Gagan"); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /core-java-8/src/main/java/com/gauravbytes/java8/stream/StreamDistinctExample.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.java8.stream; 2 | 3 | import java.util.Collection; 4 | import java.util.List; 5 | import java.util.stream.Collectors; 6 | 7 | import com.gauravbytes.java8.stream.StreamSamples.Person; 8 | 9 | /** 10 | * 11 | * @author Gaurav Rai Mazra 12 | * 13 | */ 14 | public class StreamDistinctExample { 15 | public static void main(String[] args) { 16 | Collection persons = StreamSamples.getPersons(); 17 | List uniqueFirstNames = persons.stream().map(Person::getFirstName).distinct() 18 | .collect(Collectors.toList()); 19 | 20 | System.out.println(uniqueFirstNames); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /core-java-8/src/main/java/com/gauravbytes/java8/stream/StreamExceptionExample.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.java8.stream; 2 | 3 | import java.util.List; 4 | import java.util.stream.Stream; 5 | 6 | /** 7 | * 8 | * @author Gaurav Rai Mazra 9 | * 10 | */ 11 | public class StreamExceptionExample { 12 | public static void main(String[] args) { 13 | List lines = DataStub.getLines(); 14 | Stream stream = lines.stream(); 15 | stream.reduce((a, b) -> a.length() > b.length() ? a : b) 16 | .ifPresent(System.out::println); 17 | 18 | // below line will throw the exception 19 | stream.forEach(System.out::println); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /core-java-8/src/main/java/com/gauravbytes/java8/stream/StreamMappingExample.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.java8.stream; 2 | 3 | import java.util.Collection; 4 | import java.util.List; 5 | import java.util.stream.Collectors; 6 | 7 | import com.gauravbytes.java8.stream.StreamSamples.Person; 8 | 9 | 10 | /** 11 | * 12 | * @author Gaurav Rai Mazra 13 | * 14 | */ 15 | public class StreamMappingExample { 16 | public static void main(String[] args) { 17 | Collection persons = StreamSamples.getPersons(); 18 | List firstNames = persons.stream() 19 | .map(Person::getFirstName) 20 | .collect(Collectors.toList()); 21 | System.out.println(firstNames); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /core-java-8/src/main/java/com/gauravbytes/java8/stream/StreamMinMaxExample.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.java8.stream; 2 | 3 | import java.util.Comparator; 4 | import java.util.List; 5 | 6 | /** 7 | * 8 | * @author Gaurav Rai Mazra 9 | * 10 | */ 11 | public class StreamMinMaxExample { 12 | public static void main(String[] args) { 13 | List lines = DataStub.getLines(); 14 | // max line 15 | lines.stream().max(Comparator.comparingInt(String::length)) 16 | .ifPresent(System.out::println); 17 | 18 | // min line 19 | lines.stream().min(Comparator.comparingInt(String::length)) 20 | .ifPresent(System.out::println); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /core-java-8/src/main/java/com/gauravbytes/java8/types/NonNull.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.java8.types; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Target; 5 | 6 | /** 7 | * 8 | * @author Gaurav Rai Mazra 9 | * 10 | */ 11 | @Target(value = ElementType.TYPE_USE) 12 | public @interface NonNull { 13 | 14 | } 15 | -------------------------------------------------------------------------------- /core-java-8/src/main/java/com/gauravbytes/java8/types/TypeCheckingPlaybook.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.java8.types; 2 | 3 | /** 4 | * 5 | * @author Gaurav Rai Mazra 6 | * 7 | */ 8 | public class TypeCheckingPlaybook { 9 | 10 | 11 | private @NonNull String name; 12 | 13 | public static void main(String[] args) { 14 | 15 | } 16 | 17 | public void methodTwo(String name, String profile) { 18 | System.out.println(name + " : " + profile); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /core-java-8/src/main/java/com/gauravbytes/serialization/custom/Collar.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.serialization.custom; 2 | 3 | /** 4 | * 5 | * @author Gaurav Rai Mazra 6 | * Catch me 7 | * 8 | */ 9 | public class Collar { 10 | private int size; 11 | 12 | public Collar(int size) { 13 | super(); 14 | this.size = size; 15 | } 16 | 17 | public int getSize() { 18 | return size; 19 | } 20 | 21 | public void setSize(int size) { 22 | this.size = size; 23 | } 24 | 25 | @Override 26 | public String toString() { 27 | return "Collar [size=" + size + "]"; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /data-analytics-kibana-reporting/mailcontent.txt: -------------------------------------------------------------------------------- 1 | Found {{payload.collector.length}} Events 2 | {{#payload.collector}} 3 | {{#.}} 4 | ip : {{ip}}, identifier: {{identifier}}, count: {{count}} 5 | {{/.}} 6 | {{/payload.collector}} -------------------------------------------------------------------------------- /data-analytics-kibana-reporting/watcher-condition.json: -------------------------------------------------------------------------------- 1 | { 2 | "script": { 3 | "script": "var requestIPbuckets = payload.aggregations.group_by_requestIP.buckets; payload.collector = []; requestIPbuckets.filter(function(requestIP) { return requestIP.key; }).forEach(function(requestIP) { var requestIPKey = requestIP.key; var users = requestIP.group_by_identifier.buckets; if (users.length > 1) { users.filter(function(user) { return user.key; }).forEach(function(user) { payload.collector.push({ 'ip': requestIPKey, 'identifier': user.key, 'count': user.doc_count }); }); }}); payload.collector.length > 0;" 4 | } 5 | } -------------------------------------------------------------------------------- /design-patterns/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | /.settings/ 3 | .classpath 4 | .project 5 | -------------------------------------------------------------------------------- /design-patterns/src/main/java/in/lineofcode/patterns/observer/Observer.java: -------------------------------------------------------------------------------- 1 | package in.lineofcode.patterns.observer; 2 | 3 | /** 4 | * @author Gaurav Rai Mazra 5 | * Blog - GauravBytes 6 | * 7 | */ 8 | public interface Observer { 9 | public void update(Observable owner, E event); 10 | } 11 | -------------------------------------------------------------------------------- /elasticpluginexample/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | .project 3 | .classpath 4 | /.settings/* 5 | -------------------------------------------------------------------------------- /elasticpluginexample/src/main/assemblies/plugin.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | plugin 4 | 5 | zip 6 | 7 | false 8 | 9 | 10 | ${project.basedir}/src/main/resources/plugin-descriptor.properties 11 | elasticsearch 12 | true 13 | 14 | 15 | 16 | 17 | elasticsearch 18 | true 19 | true 20 | 21 | 22 | -------------------------------------------------------------------------------- /elasticpluginexample/src/main/resources/plugin-descriptor.properties: -------------------------------------------------------------------------------- 1 | description=${project.description}. 2 | version=${project.version} 3 | name=${project.artifactId} 4 | classname=in.lineofcode.elasticsearch.ElasticSearchDemoPlugin 5 | java.version=1.8 6 | elasticsearch.version=${elasticsearch.version} -------------------------------------------------------------------------------- /elasticpluginexample/src/test/resources/log4j.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /elasticsearch-clientexample/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | /.settings/ 3 | .classpath 4 | .project 5 | -------------------------------------------------------------------------------- /es6-lessons/Cheetah.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gauravrmazra/gauravbytes/1e16b62514054bf145df4bf1b5b137ce9d05dd19/es6-lessons/Cheetah.jpg -------------------------------------------------------------------------------- /es6-lessons/Lesson 10 - Sets.js: -------------------------------------------------------------------------------- 1 | const uniqueNumbers = new Set([0, 0, 2, 2, 3, 1, 1, 6, 7, 8, 9, 10]) 2 | console.log(uniqueNumbers); 3 | 4 | uniqueNumbers.add(100); 5 | console.log(uniqueNumbers); 6 | 7 | uniqueNumbers.remove(1); 8 | console.log(uniqueNumbers); 9 | 10 | //clear all items from set 11 | uniqueNumbers.clear(); 12 | 13 | //WeakSet example 14 | const weakSetFlavors = new WeakSet(); 15 | 16 | const chocochip = { flavor: 'chocochip' }; 17 | const redvelvet = { flavor: 'redvelvet' }; 18 | weakSetFlavors.add(chocochip); 19 | weakSetFlavors.add(redvelvet); -------------------------------------------------------------------------------- /es6-lessons/Lesson 11 - Maps.js: -------------------------------------------------------------------------------- 1 | const employees = new Map(); 2 | 3 | //Add key-value pairs to map 4 | employees.set("gaurav.r.mazra@gmail.com", { 5 | firstName: 'Gaurav Rai', 6 | lastName: 'Mazra', 7 | department: 'Product development', 8 | role: 'Senior Software Developer' 9 | }); 10 | 11 | //remove from single key-value pair from map 12 | employees.delete('gaurav.r.mazra@gmail.com'); 13 | 14 | //clear all key-value pairs from map 15 | employees.clear(); 16 | 17 | // Check if particular key-value pair exists in the map 18 | const hasGauravEmployee = employees.has('gaurav.r.mazra@gmail.com'); 19 | 20 | 21 | // reterive value from map by passing key 22 | const gaurav = employees.get('gaurav.r.mazra@gmail.com'); 23 | 24 | 25 | -------------------------------------------------------------------------------- /es6-lessons/Lesson 4 - Object Literals.js: -------------------------------------------------------------------------------- 1 | let name = "Gaurav Mazra"; 2 | let id = 1818; 3 | let designation = "Senior Software Developer"; 4 | let dateOfBirth = '13/10/1988' 5 | 6 | 7 | var olderWayEmployee = { 8 | name: name, 9 | id: id, 10 | designation: designation, 11 | dateOfBirth: dateOfBirth 12 | }; 13 | 14 | 15 | let objectLiteralWayEmployee = { name, id, designation, dateOfBirth, calcuateAge() { 16 | 17 | } }; -------------------------------------------------------------------------------- /es6-lessons/Lesson 5 - ForOf Loop.js: -------------------------------------------------------------------------------- 1 | const numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13] 2 | 3 | // Newer forOf Loop 4 | for (const number of numbers) { 5 | console.log(number); 6 | } 7 | 8 | // Older for loop 9 | for (let i = 0; i < numbers.length; i++) { 10 | console.log(numbers[i]); 11 | } 12 | 13 | //for in loop. Only downside is if you prototyped array, then will iterate over added properties as well. 14 | for (let index in numbers) { 15 | console.log(numbers[index]); 16 | } -------------------------------------------------------------------------------- /es6-lessons/Lesson 5 - Spread Operator.js: -------------------------------------------------------------------------------- 1 | const evens = [2, 4, 6, 8, 10] 2 | const odds = [1, 3, 5, 7, 9] 3 | 4 | //Concat arrays old way 5 | const oldWayConcatedNumbers = evens.concat(odds); 6 | console.log('Older way concated array results: ', oldWayConcatedNumbers); 7 | 8 | //Concat Arrays with Spread operator 9 | const numbers = [...evens, ...odds] 10 | 11 | console.log('Concated arrays with spread operator: ', numbers); -------------------------------------------------------------------------------- /es6-lessons/Lesson 6 - Arrow Functions.js: -------------------------------------------------------------------------------- 1 | const names = ['Gaurav', 'Rasham', 'Gagan', 'Aman']; 2 | 3 | // Older way of function 4 | const upperCaseNames = names.map(function(name) { 5 | return name.toUpperCase(); 6 | }); 7 | 8 | // Arrow function example 9 | const arrowFuncUpperCaseNames = names.map(name => name.toUpperCase()); -------------------------------------------------------------------------------- /es6-lessons/Lesson 8 - Classes.js: -------------------------------------------------------------------------------- 1 | class Animal { 2 | constructor(category = 'Unknown') { 3 | this.category = category; 4 | } 5 | 6 | getCategory() { 7 | return this.category; 8 | } 9 | 10 | whoAmI(){ 11 | return `I am ${getName()}. My species is ${getCategory()}.` 12 | } 13 | 14 | getName() { 15 | return 'Animal' 16 | } 17 | } 18 | 19 | class Lion extends Animal { 20 | constructor() { 21 | super('Mammal'); 22 | } 23 | 24 | getName() { 25 | return 'Lion'; 26 | } 27 | } 28 | 29 | class Snake extends Animal { 30 | constructor() { 31 | super('Reptile') 32 | } 33 | 34 | getName() { 35 | return 'Snake'; 36 | } 37 | } -------------------------------------------------------------------------------- /es6-lessons/Lesson 9 - Symbols.js: -------------------------------------------------------------------------------- 1 | // Unique and immutable data-type to identify object's properties 2 | const symb = Symbol('lion') 3 | 4 | const animals = { 5 | 'lion': { weight: 220.5, length: 155 }, 6 | 'monkey': { weight: 20.1, length: 35 }, 7 | 'lion': { weight: 300, length: 165 } 8 | } 9 | 10 | console.log(animals); // Will print only two objects 11 | 12 | const animalWithSymbols = { 13 | [Symbol('lion')]: { weight: 220.5, length: 155 }, 14 | [Symbol('monkey')]: { weight: 20.1, length: 35 }, 15 | [Symbol('lion')]: { weight: 300, length: 165 } 16 | } -------------------------------------------------------------------------------- /es6-lessons/Lesson1-NewVariableSyntax.js: -------------------------------------------------------------------------------- 1 | function getClothing(isCold) 2 | { 3 | if (isCold) { 4 | var freezing = 'Grab a jacket!'; 5 | } 6 | else { 7 | var hot = 'It\'s a shorts kind of day.'; 8 | console.log(freezing); 9 | } 10 | } 11 | 12 | function getClothingBlockScoped(isCold) { 13 | if (isCold) { 14 | let freezing = 'Grab a jacket!'; 15 | } 16 | else { 17 | let hot = 'It\'s a shorts kind of day.'; 18 | console.log(freezing); 19 | } 20 | } 21 | 22 | // Const scoped variables 23 | const PI = 3.14; 24 | 25 | 26 | function getClothingConstScoped(isCold) { 27 | if (isCold) { 28 | const freezing = 'Grab a jacket!'; 29 | } 30 | else { 31 | const hot = 'It\'s a shorts kind of day.'; 32 | console.log(freezing); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /es6-lessons/Lesson2 - TemplateLiterals.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Welcome to Lesson 2 - Template Literals 7 | 8 | 9 | 14 | 15 | -------------------------------------------------------------------------------- /es6-lessons/Lesson2 - TemplateLiterals.js: -------------------------------------------------------------------------------- 1 | let student = { 2 | name: 'Gaurav Rai Mazra' 3 | }; 4 | 5 | let teacher = { 6 | name: 'Rasham Chadha', 7 | room: 'N1818' 8 | } 9 | 10 | const message = `${student.name}, please see ${teacher.name} in ${teacher.room} to pick up your report card.`; -------------------------------------------------------------------------------- /es6-lessons/Lesson2-Quiz.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 13 | 14 | -------------------------------------------------------------------------------- /es6-lessons/Lesson3- Destructing.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 13 | 14 | -------------------------------------------------------------------------------- /fbgraph-location/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | /.settings/ 3 | .project 4 | .classpath -------------------------------------------------------------------------------- /fbgraph-location/src/main/java/com/gauravbytes/fbgraph/FBApp.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.fbgraph; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | /** 7 | * 8 | * @author Mazra, Gaurav Rai 9 | * 10 | */ 11 | @SpringBootApplication 12 | public class FBApp { 13 | public static void main(String[] args) { 14 | SpringApplication.run(FBApp.class, args); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /fbgraph-location/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8082 3 | undertow: 4 | ioThreads: 15 5 | workerThreads: 150 6 | accesslog: 7 | enabled: true 8 | compression: 9 | enabled: true 10 | mimeTypes: text/xml, text/css, text/html, application/json 11 | minResponseSize: 4096 12 | 13 | spring: 14 | application: 15 | name: fbgraph-location 16 | 17 | security: 18 | basic: 19 | enabled: false 20 | 21 | logging: 22 | level: 23 | root: INFO -------------------------------------------------------------------------------- /ignite-examples/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | 3 | /.settings/ 4 | .classpath 5 | .project -------------------------------------------------------------------------------- /java-openclose-principle/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gauravrmazra/gauravbytes/1e16b62514054bf145df4bf1b5b137ce9d05dd19/java-openclose-principle/.DS_Store -------------------------------------------------------------------------------- /java-openclose-principle/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /java-openclose-principle/.settings/org.eclipse.jdt.apt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.apt.aptEnabled=false 3 | -------------------------------------------------------------------------------- /java-openclose-principle/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 3 | org.eclipse.jdt.core.compiler.compliance=1.8 4 | org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled 5 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning 6 | org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore 7 | org.eclipse.jdt.core.compiler.processAnnotations=disabled 8 | org.eclipse.jdt.core.compiler.release=disabled 9 | org.eclipse.jdt.core.compiler.source=1.8 10 | -------------------------------------------------------------------------------- /java-openclose-principle/.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /java-openclose-principle/src/main/java/com/gauravbytes/openclose/bad/ImageEditor.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.openclose.bad; 2 | 3 | /** 4 | * 5 | * @author Gaurav Rai Mazra 6 | * 7 | */ 8 | public class ImageEditor { 9 | public void drawShape(Shape shape) { 10 | if (shape.getType() == ShapeType.RECTANGLE) { 11 | drawRectangle(shape); 12 | } 13 | else if (shape.getType() == ShapeType.SQUARE) { 14 | drawSquare(shape); 15 | } 16 | } 17 | 18 | private void drawSquare(Shape shape) { 19 | // logic to draw square 20 | } 21 | 22 | private void drawRectangle(Shape shape) { 23 | // LOGIC to draw triangle 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /java-openclose-principle/src/main/java/com/gauravbytes/openclose/bad/Rectangle.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.openclose.bad; 2 | 3 | /** 4 | * 5 | * @author Gaurav Rai Mazra 6 | * 7 | */ 8 | public class Rectangle extends Shape { 9 | 10 | public Rectangle() { 11 | super(ShapeType.RECTANGLE); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /java-openclose-principle/src/main/java/com/gauravbytes/openclose/bad/Shape.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.openclose.bad; 2 | 3 | /** 4 | * 5 | * @author Gaurav Rai Mazra 6 | * 7 | */ 8 | public abstract class Shape { 9 | private ShapeType type; 10 | 11 | public Shape(ShapeType type) { 12 | this.type = type; 13 | } 14 | 15 | public ShapeType getType() { 16 | return this.type; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /java-openclose-principle/src/main/java/com/gauravbytes/openclose/bad/ShapeType.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.openclose.bad; 2 | 3 | public enum ShapeType { 4 | RECTANGLE, SQUARE; 5 | } 6 | -------------------------------------------------------------------------------- /java-openclose-principle/src/main/java/com/gauravbytes/openclose/bad/Square.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.openclose.bad; 2 | 3 | public class Square extends Shape { 4 | 5 | public Square() { 6 | super(ShapeType.SQUARE); 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /java-openclose-principle/src/main/java/com/gauravbytes/openclose/notbad/ImageEditor.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.openclose.notbad; 2 | 3 | /** 4 | * 5 | * @author Gaurav Rai Mazra 6 | * 7 | */ 8 | public class ImageEditor { 9 | public void drawShape(Shape shape) { 10 | shape.draw(); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /java-openclose-principle/src/main/java/com/gauravbytes/openclose/notbad/Rectangle.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.openclose.notbad; 2 | 3 | /** 4 | * 5 | * @author Gaurav Rai Mazra 6 | * 7 | */ 8 | public class Rectangle extends Shape { 9 | 10 | public Rectangle() { 11 | super(ShapeType.RECTANGLE); 12 | } 13 | 14 | @Override 15 | public void draw() { 16 | // logic to draw rectangle 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /java-openclose-principle/src/main/java/com/gauravbytes/openclose/notbad/Shape.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.openclose.notbad; 2 | 3 | /** 4 | * 5 | * @author Gaurav Rai Mazra 6 | * 7 | */ 8 | public abstract class Shape { 9 | private ShapeType type; 10 | 11 | public Shape(ShapeType type) { 12 | this.type = type; 13 | } 14 | 15 | public ShapeType getType() { 16 | return this.type; 17 | } 18 | 19 | public abstract void draw(); 20 | } 21 | -------------------------------------------------------------------------------- /java-openclose-principle/src/main/java/com/gauravbytes/openclose/notbad/ShapeType.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.openclose.notbad; 2 | 3 | /** 4 | * 5 | * @author Gaurav Rai Mazra 6 | * 7 | */ 8 | public enum ShapeType { 9 | RECTANGLE, SQUARE; 10 | } 11 | -------------------------------------------------------------------------------- /java-openclose-principle/src/main/java/com/gauravbytes/openclose/notbad/Square.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.openclose.notbad; 2 | 3 | /** 4 | * 5 | * @author Gaurav Rai Mazra 6 | * 7 | */ 8 | public class Square extends Shape { 9 | 10 | public Square() { 11 | super(ShapeType.SQUARE); 12 | } 13 | 14 | @Override 15 | public void draw() { 16 | //logic to draw square 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /java-srp-improved/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | .classpath 3 | .project 4 | /.settings/ 5 | 6 | -------------------------------------------------------------------------------- /java-srp-improved/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | com.gauravbytes 5 | java-srp-improved 6 | 0.0.1-SNAPSHOT 7 | 8 | 1.8 9 | 10 | 11 | 12 | 13 | org.apache.maven.plugins 14 | maven-compiler-plugin 15 | 3.6.0 16 | 17 | ${java.version} 18 | ${java.version} 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /java-srp-improved/src/main/java/com/gauravbytes/good/srp/parser/CSVFileParser.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.good.srp.parser; 2 | 3 | import java.io.File; 4 | 5 | /** 6 | * 7 | * @author Mazra, Gaurav Rai 8 | * 9 | */ 10 | public class CSVFileParser implements Parser { 11 | 12 | @Override 13 | public void parse(File file) { 14 | // logic to parse CSV file goes here 15 | } 16 | 17 | @Override 18 | public FileType getFileType() { 19 | return FileType.XML; 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /java-srp-improved/src/main/java/com/gauravbytes/good/srp/parser/FileParser.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.good.srp.parser; 2 | 3 | import java.io.File; 4 | 5 | /** 6 | * 7 | * @author Mazra, Gaurav Rai 8 | * 9 | */ 10 | public class FileParser { 11 | private Parser parser; 12 | 13 | public FileParser(Parser parser) { 14 | this.parser = parser; 15 | } 16 | 17 | public void setParser(Parser parser) { 18 | this.parser = parser; 19 | } 20 | 21 | public void parseFile(File file) { 22 | if (parser.canParse(file)) { 23 | parser.parse(file); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /java-srp-improved/src/main/java/com/gauravbytes/good/srp/parser/FileType.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.good.srp.parser; 2 | 3 | /** 4 | * 5 | * @author Mazra, Gaurav Rai 6 | * 7 | */ 8 | public enum FileType { 9 | 10 | CSV(".csv"), XML(".xml"), JSON(".json"), PDF(".pdf"), RICHTEXT(".rtf"), TXT(".txt"); 11 | 12 | private String extension; 13 | 14 | private FileType(String extension) { 15 | this.extension = extension; 16 | } 17 | 18 | public String getExtension() { 19 | return this.extension; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /java-srp-improved/src/main/java/com/gauravbytes/good/srp/parser/JsonFileParser.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.good.srp.parser; 2 | 3 | import java.io.File; 4 | 5 | /** 6 | * 7 | * @author Mazra, Gaurav Rai 8 | * 9 | */ 10 | public class JsonFileParser implements Parser { 11 | 12 | @Override 13 | public void parse(File file) { 14 | // Logic to parse json file 15 | } 16 | 17 | @Override 18 | public FileType getFileType() { 19 | return FileType.JSON; 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /java-srp-improved/src/main/java/com/gauravbytes/good/srp/parser/Parser.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.good.srp.parser; 2 | 3 | import java.io.File; 4 | import java.util.Objects; 5 | 6 | /** 7 | * 8 | * @author Mazra, Gaurav Rai 9 | * 10 | */ 11 | public interface Parser { 12 | public void parse(File file); 13 | 14 | public FileType getFileType(); 15 | 16 | public default boolean canParse(File file) { 17 | return Objects.nonNull(file) && file.getName().endsWith(getFileType().getExtension()); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /java-srp-improved/src/main/java/com/gauravbytes/good/srp/parser/XmlFileParser.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.good.srp.parser; 2 | 3 | import java.io.File; 4 | 5 | /** 6 | * 7 | * @author Mazra, Gaurav Rai 8 | * 9 | */ 10 | public class XmlFileParser implements Parser { 11 | 12 | @Override 13 | public void parse(File file) { 14 | // logic to parse xml file 15 | } 16 | 17 | @Override 18 | public FileType getFileType() { 19 | return FileType.XML; 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /java-srp/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | 3 | .classpath 4 | .project 5 | /.settings/ 6 | 7 | -------------------------------------------------------------------------------- /java-srp/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | com.gauravbytes 5 | java-srp 6 | 0.0.1-SNAPSHOT 7 | 8 | 9 | 1.8 10 | 11 | 12 | 13 | 14 | 15 | org.apache.maven.plugins 16 | maven-compiler-plugin 17 | 3.6.0 18 | 19 | ${java.version} 20 | ${java.version} 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /java-srp/src/main/java/com/gauravbytes/good/srp/parser/CSVFileParser.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.good.srp.parser; 2 | 3 | import java.io.File; 4 | 5 | /** 6 | * 7 | * @author Mazra, Gaurav Rai 8 | * 9 | */ 10 | public class CSVFileParser implements Parser { 11 | 12 | @Override 13 | public void parse(File file) { 14 | // logic to parse CSV file goes here 15 | } 16 | 17 | @Override 18 | public FileType getFileType() { 19 | return FileType.XML; 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /java-srp/src/main/java/com/gauravbytes/good/srp/parser/FileParser.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.good.srp.parser; 2 | 3 | import java.io.File; 4 | 5 | /** 6 | * 7 | * @author Mazra, Gaurav Rai 8 | * 9 | */ 10 | public class FileParser { 11 | private Parser parser; 12 | 13 | public FileParser(Parser parser) { 14 | this.parser = parser; 15 | } 16 | 17 | public void setParser(Parser parser) { 18 | this.parser = parser; 19 | } 20 | 21 | public void parseFile(File file) { 22 | if (FileValidationUtils.isValidFile(file, parser.getFileType())) { 23 | parser.parse(file); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /java-srp/src/main/java/com/gauravbytes/good/srp/parser/FileType.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.good.srp.parser; 2 | 3 | /** 4 | * 5 | * @author Mazra, Gaurav Rai 6 | * 7 | */ 8 | public enum FileType { 9 | 10 | CSV(".csv"), XML(".xml"), JSON(".json"), PDF(".pdf"), RICHTEXT(".rtf"), TXT(".txt"); 11 | 12 | private String extension; 13 | 14 | private FileType(String extension) { 15 | this.extension = extension; 16 | } 17 | 18 | public String getExtension() { 19 | return this.extension; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /java-srp/src/main/java/com/gauravbytes/good/srp/parser/JsonFileParser.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.good.srp.parser; 2 | 3 | import java.io.File; 4 | 5 | /** 6 | * 7 | * @author Mazra, Gaurav Rai 8 | * 9 | */ 10 | public class JsonFileParser implements Parser { 11 | 12 | @Override 13 | public void parse(File file) { 14 | // Logic to parse json file 15 | } 16 | 17 | @Override 18 | public FileType getFileType() { 19 | return FileType.JSON; 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /java-srp/src/main/java/com/gauravbytes/good/srp/parser/Parser.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.good.srp.parser; 2 | 3 | import java.io.File; 4 | 5 | /** 6 | * 7 | * @author Mazra, Gaurav Rai 8 | * 9 | */ 10 | public interface Parser { 11 | // method to parse file 12 | public void parse(File file); 13 | 14 | // return filetype to validate 15 | public FileType getFileType(); 16 | } 17 | -------------------------------------------------------------------------------- /java-srp/src/main/java/com/gauravbytes/good/srp/parser/XmlFileParser.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.good.srp.parser; 2 | 3 | import java.io.File; 4 | 5 | /** 6 | * 7 | * @author Mazra, Gaurav Rai 8 | * 9 | */ 10 | public class XmlFileParser implements Parser { 11 | 12 | @Override 13 | public void parse(File file) { 14 | // logic to parse xml file 15 | } 16 | 17 | @Override 18 | public FileType getFileType() { 19 | return FileType.XML; 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /java-srp/src/main/java/com/gauravbytes/srp/parser/FileType.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.srp.parser; 2 | 3 | /** 4 | * 5 | * @author Mazra, Gaurav Rai 6 | * 7 | */ 8 | public enum FileType { 9 | 10 | CSV(".csv"), XML(".xml"), JSON(".json"), PDF(".pdf"), RICHTEXT(".rtf"), TXT(".txt"); 11 | 12 | private String extension; 13 | 14 | private FileType(String extension) { 15 | this.extension = extension; 16 | } 17 | 18 | public String getExtension() { 19 | return this.extension; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /java-vertx/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | /.settings/ 3 | .classpath 4 | .project 5 | -------------------------------------------------------------------------------- /java-vertx/src/main/java/com/gauravbytes/vertx/VerticleExample.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.vertx; 2 | 3 | import io.vertx.core.AbstractVerticle; 4 | import io.vertx.core.DeploymentOptions; 5 | import io.vertx.core.Vertx; 6 | 7 | public class VerticleExample { 8 | public static class MyTestVerticle extends AbstractVerticle { 9 | @Override 10 | public void start() throws Exception { 11 | System.out.println("starting mytestverticle"); 12 | } 13 | 14 | @Override 15 | public void stop() throws Exception { 16 | System.out.println("stoping mytestverticle"); 17 | } 18 | } 19 | 20 | public static void main(String[] args) { 21 | Vertx vertx = Vertx.vertx(); 22 | DeploymentOptions options = new DeploymentOptions().setWorker(true); 23 | vertx.deployVerticle(new MyTestVerticle(), options); 24 | vertx.close(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /java-vertx/src/main/java/com/gauravbytes/vertx/VertxPeriodicTimerExample.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.vertx; 2 | 3 | import java.util.concurrent.TimeUnit; 4 | 5 | import io.vertx.core.Vertx; 6 | 7 | /** 8 | * 9 | * @author Vert.x periodic task example 10 | * 11 | */ 12 | public class VertxPeriodicTimerExample { 13 | public static void main(String[] args) { 14 | Vertx vertx = Vertx.vertx(); 15 | vertx.setPeriodic(2000, id -> { 16 | System.out.println("Timer fired with id : " + id); 17 | }); 18 | vertx.setPeriodic(5000, id -> { 19 | throw new RuntimeException("I failed in second timer"); 20 | }); 21 | 22 | try { 23 | TimeUnit.SECONDS.sleep(10); 24 | } catch (InterruptedException e) { 25 | } 26 | vertx.close(); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /java10-project/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | /.settings/ 3 | .project 4 | .classpath 5 | -------------------------------------------------------------------------------- /kafka-begineer/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | .classpath 3 | .project 4 | /.settings/ 5 | -------------------------------------------------------------------------------- /my-first-react-app-with-typescript/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /my-first-react-app-with-typescript/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gauravrmazra/gauravbytes/1e16b62514054bf145df4bf1b5b137ce9d05dd19/my-first-react-app-with-typescript/public/favicon.ico -------------------------------------------------------------------------------- /my-first-react-app-with-typescript/public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gauravrmazra/gauravbytes/1e16b62514054bf145df4bf1b5b137ce9d05dd19/my-first-react-app-with-typescript/public/logo192.png -------------------------------------------------------------------------------- /my-first-react-app-with-typescript/public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gauravrmazra/gauravbytes/1e16b62514054bf145df4bf1b5b137ce9d05dd19/my-first-react-app-with-typescript/public/logo512.png -------------------------------------------------------------------------------- /my-first-react-app-with-typescript/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /my-first-react-app-with-typescript/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /my-first-react-app-with-typescript/src/App.css: -------------------------------------------------------------------------------- 1 | .App { 2 | text-align: center; 3 | } 4 | 5 | .App-logo { 6 | height: 40vmin; 7 | pointer-events: none; 8 | } 9 | 10 | @media (prefers-reduced-motion: no-preference) { 11 | .App-logo { 12 | animation: App-logo-spin infinite 20s linear; 13 | } 14 | } 15 | 16 | .App-header { 17 | background-color: #282c34; 18 | min-height: 100vh; 19 | display: flex; 20 | flex-direction: column; 21 | align-items: center; 22 | justify-content: center; 23 | font-size: calc(10px + 2vmin); 24 | color: white; 25 | } 26 | 27 | .App-link { 28 | color: #61dafb; 29 | } 30 | 31 | @keyframes App-logo-spin { 32 | from { 33 | transform: rotate(0deg); 34 | } 35 | to { 36 | transform: rotate(360deg); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /my-first-react-app-with-typescript/src/App.test.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { render } from '@testing-library/react'; 3 | import App from './App'; 4 | 5 | test('renders learn react link', () => { 6 | const { getByText } = render(); 7 | const linkElement = getByText(/Welcome Reader!/i); 8 | expect(linkElement).toBeInTheDocument(); 9 | }); 10 | -------------------------------------------------------------------------------- /my-first-react-app-with-typescript/src/App.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import logo from './gaurav-bytes.png'; 3 | import './App.css'; 4 | import Welcome from './Welcome'; 5 | 6 | function App() { 7 | return ( 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | ); 16 | } 17 | 18 | export default App; 19 | -------------------------------------------------------------------------------- /my-first-react-app-with-typescript/src/Welcome.css: -------------------------------------------------------------------------------- 1 | .welcome { 2 | font-size: 20px; 3 | font-weight: bold; 4 | color: #2a7112; 5 | } -------------------------------------------------------------------------------- /my-first-react-app-with-typescript/src/Welcome.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import './Welcome.css'; 3 | 4 | interface IWelcomeProps { 5 | message?: string 6 | } 7 | 8 | function Welcome(props: IWelcomeProps) { 9 | const message = props?.message ?? 'Welcome! My first React app with Typescript.' 10 | return ({message}); 11 | } 12 | 13 | export default Welcome; -------------------------------------------------------------------------------- /my-first-react-app-with-typescript/src/gaurav-bytes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gauravrmazra/gauravbytes/1e16b62514054bf145df4bf1b5b137ce9d05dd19/my-first-react-app-with-typescript/src/gaurav-bytes.png -------------------------------------------------------------------------------- /my-first-react-app-with-typescript/src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 5 | sans-serif; 6 | -webkit-font-smoothing: antialiased; 7 | -moz-osx-font-smoothing: grayscale; 8 | } 9 | 10 | code { 11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', 12 | monospace; 13 | } 14 | -------------------------------------------------------------------------------- /my-first-react-app-with-typescript/src/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import './index.css'; 4 | import App from './App'; 5 | import * as serviceWorker from './serviceWorker'; 6 | 7 | ReactDOM.render( 8 | 9 | 10 | , 11 | document.getElementById('root') 12 | ); 13 | 14 | // If you want your app to work offline and load faster, you can change 15 | // unregister() to register() below. Note this comes with some pitfalls. 16 | // Learn more about service workers: https://bit.ly/CRA-PWA 17 | serviceWorker.unregister(); 18 | -------------------------------------------------------------------------------- /my-first-react-app-with-typescript/src/react-app-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /my-first-react-app-with-typescript/src/setupTests.ts: -------------------------------------------------------------------------------- 1 | // jest-dom adds custom jest matchers for asserting on DOM nodes. 2 | // allows you to do things like: 3 | // expect(element).toHaveTextContent(/react/i) 4 | // learn more: https://github.com/testing-library/jest-dom 5 | import '@testing-library/jest-dom/extend-expect'; 6 | -------------------------------------------------------------------------------- /my-first-react-app-with-typescript/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "lib": [ 5 | "dom", 6 | "dom.iterable", 7 | "esnext" 8 | ], 9 | "allowJs": true, 10 | "skipLibCheck": true, 11 | "esModuleInterop": true, 12 | "allowSyntheticDefaultImports": true, 13 | "strict": true, 14 | "forceConsistentCasingInFileNames": true, 15 | "module": "esnext", 16 | "moduleResolution": "node", 17 | "resolveJsonModule": true, 18 | "isolatedModules": true, 19 | "noEmit": true, 20 | "jsx": "react" 21 | }, 22 | "include": [ 23 | "src" 24 | ] 25 | } 26 | -------------------------------------------------------------------------------- /my-first-react-app/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /my-first-react-app/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gauravrmazra/gauravbytes/1e16b62514054bf145df4bf1b5b137ce9d05dd19/my-first-react-app/public/favicon.ico -------------------------------------------------------------------------------- /my-first-react-app/public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gauravrmazra/gauravbytes/1e16b62514054bf145df4bf1b5b137ce9d05dd19/my-first-react-app/public/logo192.png -------------------------------------------------------------------------------- /my-first-react-app/public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gauravrmazra/gauravbytes/1e16b62514054bf145df4bf1b5b137ce9d05dd19/my-first-react-app/public/logo512.png -------------------------------------------------------------------------------- /my-first-react-app/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /my-first-react-app/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /my-first-react-app/src/App.css: -------------------------------------------------------------------------------- 1 | .App { 2 | text-align: center; 3 | } 4 | 5 | .App-logo { 6 | height: 40vmin; 7 | pointer-events: none; 8 | } 9 | 10 | @media (prefers-reduced-motion: no-preference) { 11 | .App-logo { 12 | animation: App-logo-spin infinite 20s linear; 13 | } 14 | } 15 | 16 | .App-header { 17 | background-color: #282c34; 18 | min-height: 100vh; 19 | display: flex; 20 | flex-direction: column; 21 | align-items: center; 22 | justify-content: center; 23 | font-size: calc(10px + 2vmin); 24 | color: white; 25 | } 26 | 27 | .App-link { 28 | color: #61dafb; 29 | } 30 | 31 | @keyframes App-logo-spin { 32 | from { 33 | transform: rotate(0deg); 34 | } 35 | to { 36 | transform: rotate(360deg); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /my-first-react-app/src/App.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import logo from './gaurav-bytes.png'; 3 | import './App.css'; 4 | import Welcome from './Welcome'; 5 | 6 | function App() { 7 | return ( 8 | 9 | 10 | 11 | 12 | 13 | 14 | ); 15 | } 16 | 17 | export default App; 18 | -------------------------------------------------------------------------------- /my-first-react-app/src/App.test.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { render } from '@testing-library/react'; 3 | import App from './App'; 4 | 5 | test('renders learn react link', () => { 6 | const { getByText } = render(); 7 | const linkElement = getByText(/Welcome/i); 8 | expect(linkElement).toBeInTheDocument(); 9 | }); 10 | -------------------------------------------------------------------------------- /my-first-react-app/src/Welcome.css: -------------------------------------------------------------------------------- 1 | .welcome { 2 | font-size: 20px; 3 | font-weight: bold; 4 | color: #2a7112; 5 | } -------------------------------------------------------------------------------- /my-first-react-app/src/Welcome.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import './Welcome.css'; 3 | 4 | function Welcome() { 5 | return Welcome! My first react app 6 | } 7 | 8 | export default Welcome; -------------------------------------------------------------------------------- /my-first-react-app/src/gaurav-bytes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gauravrmazra/gauravbytes/1e16b62514054bf145df4bf1b5b137ce9d05dd19/my-first-react-app/src/gaurav-bytes.png -------------------------------------------------------------------------------- /my-first-react-app/src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 5 | sans-serif; 6 | -webkit-font-smoothing: antialiased; 7 | -moz-osx-font-smoothing: grayscale; 8 | } 9 | 10 | code { 11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', 12 | monospace; 13 | } 14 | -------------------------------------------------------------------------------- /my-first-react-app/src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import './index.css'; 4 | import App from './App'; 5 | import * as serviceWorker from './serviceWorker'; 6 | 7 | ReactDOM.render( 8 | 9 | 10 | , 11 | document.getElementById('root') 12 | ); 13 | 14 | // If you want your app to work offline and load faster, you can change 15 | // unregister() to register() below. Note this comes with some pitfalls. 16 | // Learn more about service workers: https://bit.ly/CRA-PWA 17 | serviceWorker.unregister(); 18 | -------------------------------------------------------------------------------- /my-first-react-app/src/setupTests.js: -------------------------------------------------------------------------------- 1 | // jest-dom adds custom jest matchers for asserting on DOM nodes. 2 | // allows you to do things like: 3 | // expect(element).toHaveTextContent(/react/i) 4 | // learn more: https://github.com/testing-library/jest-dom 5 | import '@testing-library/jest-dom/extend-expect'; 6 | -------------------------------------------------------------------------------- /notes/HBase notes.txt: -------------------------------------------------------------------------------- 1 | HBASE notes 2 | 3 | ## creating namespace 4 | create_namespace '[NS_NAME]' 5 | 6 | ## create logical tables and Column family 7 | create '[NS_NAME]:employees', 'work', 'demographic' 8 | 9 | ## remove namespace 10 | drop_namespace '[NS_NAME]' 11 | 12 | ## Altering namespace 13 | alter_namespace '[NS_NAME]', {METHOD => 'set', 'PROPERTY_NAME' => 'PROPERTY_VALUE'} 14 | 15 | ## get command from shell 16 | get '[TABLE_NAME]', '[KEY]' 17 | 18 | ## put function is also called upsert insert or update 19 | put 'sales', '5099', 'order:orderID'm 'XX-2018-129A' 20 | 21 | ## remove data using delete command 22 | delete '[Table_Name]', '[ROW]', '[COL_NAME]', '[TIMESTAMP for specific version deletion only]' 23 | 24 | ## delete all related to particular row 25 | deleteall '[TABLE_NAME]', '[ROW]' 26 | -------------------------------------------------------------------------------- /product-find-java8/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | /.settings/ 3 | .classpath 4 | .project -------------------------------------------------------------------------------- /product-find-java8/src/main/java/com/gauravbytes/product/Color.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.product; 2 | 3 | /** 4 | * 5 | * @author Gaurav Rai Mazra 6 | * 7 | */ 8 | public enum Color { 9 | RED, WHITE, PINK, YELLOW; 10 | } 11 | -------------------------------------------------------------------------------- /product-find-java8/src/main/java/com/gauravbytes/product/ProductCatalog.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.product; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | import java.util.stream.Stream; 6 | import java.util.stream.StreamSupport; 7 | 8 | /** 9 | * 10 | * @author Gaurav Rai Mazra 11 | * 12 | */ 13 | public class ProductCatalog { 14 | private List products = new ArrayList<>(); 15 | 16 | public void add(Product product) { 17 | products.add(product); 18 | } 19 | 20 | private Stream getProductStream() { 21 | return StreamSupport.stream(this.products.spliterator(), false); 22 | } 23 | 24 | public Stream stream() { 25 | return products.stream(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /product-find-java8/src/main/java/com/gauravbytes/product/ProductSearcher.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.product; 2 | 3 | import java.util.List; 4 | import java.util.function.Predicate; 5 | import java.util.stream.Collectors; 6 | 7 | /** 8 | * 9 | * @author Gaurav Rai Mazra 10 | * 11 | */ 12 | public class ProductSearcher { 13 | private ProductCatalog catalog; 14 | 15 | public ProductSearcher(ProductCatalog catalog) { 16 | this.catalog = catalog; 17 | } 18 | 19 | public List selectBy(Predicate spec) { 20 | return catalog.stream().filter(spec).collect(Collectors.toList()); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /product-find-java8/src/main/java/com/gauravbytes/product/Size.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.product; 2 | 3 | /** 4 | * 5 | * @author Gaurav Rai Mazra 6 | * 7 | */ 8 | public enum Size { 9 | SMALL(0), MEDIUM(1), LARGE(2), NOT_APPLICABLE(3); 10 | private int size; 11 | 12 | Size(int size) { 13 | this.size = size; 14 | } 15 | 16 | public int getSize() { 17 | return this.size; 18 | } 19 | 20 | public static Size of(int size) { 21 | for (Size s : Size.values()) { 22 | if (s.getSize() == size) 23 | return s; 24 | } 25 | return Size.NOT_APPLICABLE; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /react-blog-post-nextjs-ssg/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gauravrmazra/gauravbytes/1e16b62514054bf145df4bf1b5b137ce9d05dd19/react-blog-post-nextjs-ssg/.DS_Store -------------------------------------------------------------------------------- /react-blog-post-nextjs-ssg/README.md: -------------------------------------------------------------------------------- 1 | # gauravbytesweb -------------------------------------------------------------------------------- /react-blog-post-nextjs-ssg/next-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | -------------------------------------------------------------------------------- /react-blog-post-nextjs-ssg/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gauravrmazra/gauravbytes/1e16b62514054bf145df4bf1b5b137ce9d05dd19/react-blog-post-nextjs-ssg/public/favicon.ico -------------------------------------------------------------------------------- /react-blog-post-nextjs-ssg/public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gauravrmazra/gauravbytes/1e16b62514054bf145df4bf1b5b137ce9d05dd19/react-blog-post-nextjs-ssg/public/logo192.png -------------------------------------------------------------------------------- /react-blog-post-nextjs-ssg/public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gauravrmazra/gauravbytes/1e16b62514054bf145df4bf1b5b137ce9d05dd19/react-blog-post-nextjs-ssg/public/logo512.png -------------------------------------------------------------------------------- /react-blog-post-nextjs-ssg/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "Gaurav Bytes", 3 | "name": "GauravBytes - Tutorials", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /react-blog-post-nextjs-ssg/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /react-blog-post-nextjs-ssg/src/models/IBlogPost.ts: -------------------------------------------------------------------------------- 1 | interface IBlogPost { 2 | id: string 3 | title: string 4 | content: string 5 | author: string 6 | postedOn: string 7 | tags: string[] 8 | postUrl: string 9 | } 10 | 11 | export default IBlogPost; -------------------------------------------------------------------------------- /react-blog-post-nextjs-ssg/src/pages/_app.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { AppProps } from 'next/app'; 3 | 4 | function MyApp({ Component, pageProps }: AppProps) { 5 | return ( 6 | 7 | 8 | 9 | ) 10 | } 11 | 12 | export default MyApp; -------------------------------------------------------------------------------- /react-blog-post-nextjs-ssg/src/react-app-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /react-blog-post-nextjs-ssg/src/setupTests.ts: -------------------------------------------------------------------------------- 1 | // jest-dom adds custom jest matchers for asserting on DOM nodes. 2 | // allows you to do things like: 3 | // expect(element).toHaveTextContent(/react/i) 4 | // learn more: https://github.com/testing-library/jest-dom 5 | import '@testing-library/jest-dom/extend-expect'; 6 | -------------------------------------------------------------------------------- /react-blog-post-nextjs-ssg/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "lib": [ 5 | "dom", 6 | "dom.iterable", 7 | "esnext" 8 | ], 9 | "allowJs": true, 10 | "skipLibCheck": true, 11 | "esModuleInterop": true, 12 | "allowSyntheticDefaultImports": true, 13 | "strict": true, 14 | "forceConsistentCasingInFileNames": true, 15 | "module": "esnext", 16 | "moduleResolution": "node", 17 | "resolveJsonModule": true, 18 | "isolatedModules": true, 19 | "noEmit": true, 20 | "jsx": "preserve" 21 | }, 22 | "include": [ 23 | "src" 24 | ], 25 | "exclude": [ 26 | "node_modules" 27 | ] 28 | } 29 | -------------------------------------------------------------------------------- /react-blog-post-redux-nextjs/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gauravrmazra/gauravbytes/1e16b62514054bf145df4bf1b5b137ce9d05dd19/react-blog-post-redux-nextjs/.DS_Store -------------------------------------------------------------------------------- /react-blog-post-redux-nextjs/README.md: -------------------------------------------------------------------------------- 1 | # react-blog-post-redux-nextjs -------------------------------------------------------------------------------- /react-blog-post-redux-nextjs/next-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | -------------------------------------------------------------------------------- /react-blog-post-redux-nextjs/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gauravrmazra/gauravbytes/1e16b62514054bf145df4bf1b5b137ce9d05dd19/react-blog-post-redux-nextjs/public/favicon.ico -------------------------------------------------------------------------------- /react-blog-post-redux-nextjs/public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gauravrmazra/gauravbytes/1e16b62514054bf145df4bf1b5b137ce9d05dd19/react-blog-post-redux-nextjs/public/logo192.png -------------------------------------------------------------------------------- /react-blog-post-redux-nextjs/public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gauravrmazra/gauravbytes/1e16b62514054bf145df4bf1b5b137ce9d05dd19/react-blog-post-redux-nextjs/public/logo512.png -------------------------------------------------------------------------------- /react-blog-post-redux-nextjs/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "Gaurav Bytes", 3 | "name": "GauravBytes - Tutorials", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /react-blog-post-redux-nextjs/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /react-blog-post-redux-nextjs/src/App.test.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { render } from '@testing-library/react'; 3 | import App from './App'; 4 | import { Provider } from 'react-redux'; 5 | import { store } from './redux/store'; 6 | 7 | test('renders learn react link', () => { 8 | const component = render(, { 9 | wrapper: ({children}) => {children}> 10 | }); 11 | expect(component.baseElement).toBeInTheDocument(); 12 | }); 13 | -------------------------------------------------------------------------------- /react-blog-post-redux-nextjs/src/App.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import styles from './App.module.css'; 3 | import BlogPosts from './components/BlogPosts'; 4 | 5 | function App() { 6 | return ( 7 | 8 | 9 | 10 | ); 11 | } 12 | 13 | export default App; 14 | -------------------------------------------------------------------------------- /react-blog-post-redux-nextjs/src/components/BlogPosts.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import styles from './BlogPosts.module.css'; 3 | import BlogListing from './BlogListing'; 4 | import BlogPost from './BlogPost'; 5 | 6 | 7 | function BlogPosts() { 8 | return ( 9 | 10 | 11 | 12 | 13 | ); 14 | } 15 | 16 | export default BlogPosts; -------------------------------------------------------------------------------- /react-blog-post-redux-nextjs/src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 5 | sans-serif; 6 | -webkit-font-smoothing: antialiased; 7 | -moz-osx-font-smoothing: grayscale; 8 | } 9 | 10 | code { 11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', 12 | monospace; 13 | } 14 | -------------------------------------------------------------------------------- /react-blog-post-redux-nextjs/src/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import './index.css'; 4 | import App from './App'; 5 | import { store } from './redux/store'; 6 | import { Provider } from 'react-redux'; 7 | import * as serviceWorker from './serviceWorker'; 8 | 9 | ReactDOM.render( 10 | 11 | 12 | 13 | 14 | , 15 | document.getElementById('root') 16 | ); 17 | 18 | // If you want your app to work offline and load faster, you can change 19 | // unregister() to register() below. Note this comes with some pitfalls. 20 | // Learn more about service workers: https://bit.ly/CRA-PWA 21 | serviceWorker.unregister(); 22 | -------------------------------------------------------------------------------- /react-blog-post-redux-nextjs/src/models/IBlogPost.ts: -------------------------------------------------------------------------------- 1 | interface IBlogPost { 2 | id: string 3 | title: string 4 | content: string 5 | author: string 6 | postedOn: string 7 | tags: string[] 8 | postUrl: string 9 | } 10 | 11 | export default IBlogPost; -------------------------------------------------------------------------------- /react-blog-post-redux-nextjs/src/models/IBlogPostListing.ts: -------------------------------------------------------------------------------- 1 | export interface IBlogPostListing { 2 | id: string 3 | title: string 4 | } -------------------------------------------------------------------------------- /react-blog-post-redux-nextjs/src/models/SearchOnFields.ts: -------------------------------------------------------------------------------- 1 | export enum SearchOnFields { 2 | TAG = 'tag', 3 | TITLE = 'title' 4 | } -------------------------------------------------------------------------------- /react-blog-post-redux-nextjs/src/pages/_app.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { AppProps } from 'next/app'; 3 | import { Provider } from 'react-redux'; 4 | import { store } from '../redux/store'; 5 | 6 | function MyApp({ Component, pageProps }: AppProps) { 7 | return ( 8 | 9 | 10 | 11 | 12 | 13 | ) 14 | } 15 | 16 | export default MyApp; -------------------------------------------------------------------------------- /react-blog-post-redux-nextjs/src/react-app-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /react-blog-post-redux-nextjs/src/redux/store.ts: -------------------------------------------------------------------------------- 1 | import { configureStore, ThunkAction, Action } from '@reduxjs/toolkit'; 2 | import blogPostsReducer from './reducer/blogPostsSlice'; 3 | 4 | export const store = configureStore({ 5 | reducer: { 6 | blogPosts: blogPostsReducer, 7 | }, 8 | }); 9 | 10 | export type RootState = ReturnType; 11 | export type AppThunk = ThunkAction< 12 | ReturnType, 13 | RootState, 14 | unknown, 15 | Action 16 | >; 17 | -------------------------------------------------------------------------------- /react-blog-post-redux-nextjs/src/setupTests.ts: -------------------------------------------------------------------------------- 1 | // jest-dom adds custom jest matchers for asserting on DOM nodes. 2 | // allows you to do things like: 3 | // expect(element).toHaveTextContent(/react/i) 4 | // learn more: https://github.com/testing-library/jest-dom 5 | import '@testing-library/jest-dom/extend-expect'; 6 | -------------------------------------------------------------------------------- /react-blog-post-redux-nextjs/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "lib": [ 5 | "dom", 6 | "dom.iterable", 7 | "esnext" 8 | ], 9 | "allowJs": true, 10 | "skipLibCheck": true, 11 | "esModuleInterop": true, 12 | "allowSyntheticDefaultImports": true, 13 | "strict": true, 14 | "forceConsistentCasingInFileNames": true, 15 | "module": "esnext", 16 | "moduleResolution": "node", 17 | "resolveJsonModule": true, 18 | "isolatedModules": true, 19 | "noEmit": true, 20 | "jsx": "preserve" 21 | }, 22 | "include": [ 23 | "src" 24 | ], 25 | "exclude": [ 26 | "node_modules" 27 | ] 28 | } 29 | -------------------------------------------------------------------------------- /react-blog-posts-redux/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /react-blog-posts-redux/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gauravrmazra/gauravbytes/1e16b62514054bf145df4bf1b5b137ce9d05dd19/react-blog-posts-redux/public/favicon.ico -------------------------------------------------------------------------------- /react-blog-posts-redux/public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gauravrmazra/gauravbytes/1e16b62514054bf145df4bf1b5b137ce9d05dd19/react-blog-posts-redux/public/logo192.png -------------------------------------------------------------------------------- /react-blog-posts-redux/public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gauravrmazra/gauravbytes/1e16b62514054bf145df4bf1b5b137ce9d05dd19/react-blog-posts-redux/public/logo512.png -------------------------------------------------------------------------------- /react-blog-posts-redux/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /react-blog-posts-redux/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /react-blog-posts-redux/src/App.css: -------------------------------------------------------------------------------- 1 | .App-Container { 2 | display: -webkit-flex; 3 | display: -ms-flexbox; 4 | display: flex; 5 | margin: auto; 6 | padding: 1rem; 7 | max-width: 1440px; 8 | } 9 | -------------------------------------------------------------------------------- /react-blog-posts-redux/src/App.test.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { render } from '@testing-library/react'; 3 | import App from './App'; 4 | import { Provider } from 'react-redux'; 5 | import { store } from './redux/store'; 6 | 7 | test('renders learn react link', () => { 8 | const component = render(, { 9 | wrapper: ({children}) => {children}> 10 | }); 11 | expect(component.baseElement).toBeInTheDocument(); 12 | }); 13 | -------------------------------------------------------------------------------- /react-blog-posts-redux/src/components/BlogPost.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import './BlogPost.css'; 3 | import { useSelector } from 'react-redux'; 4 | import { selectShowingPost } from '../redux/reducer/blogPostsSlice'; 5 | 6 | function BlogPost() { 7 | const post = useSelector(selectShowingPost); 8 | return !!post ? ( 9 | 10 | {post.title} 11 | {post.content} 12 | 13 | {`By ${post.author} at ${post.postedOn}`} 14 | 15 | Tags: 16 | {post.tags.map(tag => {tag})} 17 | 18 | 19 | 20 | ) : (<>>); 21 | } 22 | 23 | export default BlogPost; -------------------------------------------------------------------------------- /react-blog-posts-redux/src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 5 | sans-serif; 6 | -webkit-font-smoothing: antialiased; 7 | -moz-osx-font-smoothing: grayscale; 8 | } 9 | 10 | code { 11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', 12 | monospace; 13 | } 14 | -------------------------------------------------------------------------------- /react-blog-posts-redux/src/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import './index.css'; 4 | import App from './App'; 5 | import { store } from './redux/store'; 6 | import { Provider } from 'react-redux'; 7 | import * as serviceWorker from './serviceWorker'; 8 | 9 | ReactDOM.render( 10 | 11 | 12 | 13 | 14 | , 15 | document.getElementById('root') 16 | ); 17 | 18 | // If you want your app to work offline and load faster, you can change 19 | // unregister() to register() below. Note this comes with some pitfalls. 20 | // Learn more about service workers: https://bit.ly/CRA-PWA 21 | serviceWorker.unregister(); 22 | -------------------------------------------------------------------------------- /react-blog-posts-redux/src/models/IBlogPost.ts: -------------------------------------------------------------------------------- 1 | interface IBlogPost { 2 | id: number 3 | title: string 4 | content: string 5 | author: string 6 | postedOn: string 7 | tags: string[] 8 | } 9 | 10 | export default IBlogPost; -------------------------------------------------------------------------------- /react-blog-posts-redux/src/models/IBlogPostListing.ts: -------------------------------------------------------------------------------- 1 | export interface IBlogPostListing { 2 | id: number 3 | title: string 4 | } -------------------------------------------------------------------------------- /react-blog-posts-redux/src/models/SearchOnFields.ts: -------------------------------------------------------------------------------- 1 | export enum SearchOnFields { 2 | TAG = 'tag', 3 | TITLE = 'title' 4 | } -------------------------------------------------------------------------------- /react-blog-posts-redux/src/react-app-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /react-blog-posts-redux/src/redux/store.ts: -------------------------------------------------------------------------------- 1 | import { configureStore, ThunkAction, Action } from '@reduxjs/toolkit'; 2 | import blogPostsReducer from './reducer/blogPostsSlice'; 3 | 4 | export const store = configureStore({ 5 | reducer: { 6 | blogPosts: blogPostsReducer, 7 | }, 8 | }); 9 | 10 | export type RootState = ReturnType; 11 | export type AppThunk = ThunkAction< 12 | ReturnType, 13 | RootState, 14 | unknown, 15 | Action 16 | >; 17 | -------------------------------------------------------------------------------- /react-blog-posts-redux/src/setupTests.ts: -------------------------------------------------------------------------------- 1 | // jest-dom adds custom jest matchers for asserting on DOM nodes. 2 | // allows you to do things like: 3 | // expect(element).toHaveTextContent(/react/i) 4 | // learn more: https://github.com/testing-library/jest-dom 5 | import '@testing-library/jest-dom/extend-expect'; 6 | -------------------------------------------------------------------------------- /react-blog-posts-redux/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "lib": [ 5 | "dom", 6 | "dom.iterable", 7 | "esnext" 8 | ], 9 | "allowJs": true, 10 | "skipLibCheck": true, 11 | "esModuleInterop": true, 12 | "allowSyntheticDefaultImports": true, 13 | "strict": true, 14 | "forceConsistentCasingInFileNames": true, 15 | "module": "esnext", 16 | "moduleResolution": "node", 17 | "resolveJsonModule": true, 18 | "isolatedModules": true, 19 | "noEmit": true, 20 | "jsx": "react" 21 | }, 22 | "include": [ 23 | "src" 24 | ] 25 | } 26 | -------------------------------------------------------------------------------- /react-blog-posts/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /react-blog-posts/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gauravrmazra/gauravbytes/1e16b62514054bf145df4bf1b5b137ce9d05dd19/react-blog-posts/public/favicon.ico -------------------------------------------------------------------------------- /react-blog-posts/public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gauravrmazra/gauravbytes/1e16b62514054bf145df4bf1b5b137ce9d05dd19/react-blog-posts/public/logo192.png -------------------------------------------------------------------------------- /react-blog-posts/public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gauravrmazra/gauravbytes/1e16b62514054bf145df4bf1b5b137ce9d05dd19/react-blog-posts/public/logo512.png -------------------------------------------------------------------------------- /react-blog-posts/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /react-blog-posts/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /react-blog-posts/src/App.css: -------------------------------------------------------------------------------- 1 | .App-Container { 2 | display: -webkit-flex; 3 | display: -ms-flexbox; 4 | display: flex; 5 | margin: auto; 6 | padding: 1rem; 7 | max-width: 1440px; 8 | } 9 | -------------------------------------------------------------------------------- /react-blog-posts/src/App.test.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { render } from '@testing-library/react'; 3 | import App from './App'; 4 | 5 | test('renders learn react link', () => { 6 | const component = render(); 7 | expect(component.baseElement).toBeInTheDocument(); 8 | }); 9 | -------------------------------------------------------------------------------- /react-blog-posts/src/components/BlogPost.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import IBlogPost from '../models/IBlogPost'; 3 | import './BlogPost.css'; 4 | 5 | interface IBlogPostProps { 6 | post: IBlogPost 7 | } 8 | 9 | function BlogPost(props: IBlogPostProps) { 10 | const post = props.post 11 | return ( 12 | 13 | {post.title} 14 | {post.content} 15 | 16 | {`By ${post.author} at ${post.postedOn}`} 17 | 18 | Tags: 19 | {post.tags.map(tag => {tag})} 20 | 21 | 22 | 23 | ); 24 | } 25 | 26 | export default BlogPost; -------------------------------------------------------------------------------- /react-blog-posts/src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 5 | sans-serif; 6 | -webkit-font-smoothing: antialiased; 7 | -moz-osx-font-smoothing: grayscale; 8 | } 9 | 10 | code { 11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', 12 | monospace; 13 | } 14 | -------------------------------------------------------------------------------- /react-blog-posts/src/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import './index.css'; 4 | import App from './App'; 5 | import * as serviceWorker from './serviceWorker'; 6 | 7 | ReactDOM.render( 8 | 9 | 10 | , 11 | document.getElementById('root') 12 | ); 13 | 14 | // If you want your app to work offline and load faster, you can change 15 | // unregister() to register() below. Note this comes with some pitfalls. 16 | // Learn more about service workers: https://bit.ly/CRA-PWA 17 | serviceWorker.unregister(); 18 | -------------------------------------------------------------------------------- /react-blog-posts/src/models/IBlogPost.ts: -------------------------------------------------------------------------------- 1 | interface IBlogPost { 2 | id: number 3 | title: string 4 | content: string 5 | author: string 6 | postedOn: string 7 | tags: string[] 8 | } 9 | 10 | export default IBlogPost; -------------------------------------------------------------------------------- /react-blog-posts/src/models/SearchType.ts: -------------------------------------------------------------------------------- 1 | export enum SearchType { 2 | SEARCH_TEXT = 'SEARCH_TEXT', 3 | SEARCH_ON = 'SEARCH_ON' 4 | } -------------------------------------------------------------------------------- /react-blog-posts/src/react-app-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /react-blog-posts/src/setupTests.ts: -------------------------------------------------------------------------------- 1 | // jest-dom adds custom jest matchers for asserting on DOM nodes. 2 | // allows you to do things like: 3 | // expect(element).toHaveTextContent(/react/i) 4 | // learn more: https://github.com/testing-library/jest-dom 5 | import '@testing-library/jest-dom/extend-expect'; 6 | -------------------------------------------------------------------------------- /react-blog-posts/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "lib": [ 5 | "dom", 6 | "dom.iterable", 7 | "esnext" 8 | ], 9 | "allowJs": true, 10 | "skipLibCheck": true, 11 | "esModuleInterop": true, 12 | "allowSyntheticDefaultImports": true, 13 | "strict": true, 14 | "forceConsistentCasingInFileNames": true, 15 | "module": "esnext", 16 | "moduleResolution": "node", 17 | "resolveJsonModule": true, 18 | "isolatedModules": true, 19 | "noEmit": true, 20 | "jsx": "react" 21 | }, 22 | "include": [ 23 | "src" 24 | ] 25 | } 26 | -------------------------------------------------------------------------------- /serialization-avro-vs-java/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | .classpath 3 | .project 4 | /.settings/ 5 | -------------------------------------------------------------------------------- /serialization-avro-vs-java/src/main/avro/employee.avsc: -------------------------------------------------------------------------------- 1 | { 2 | "type" : "record", 3 | "name" : "Employee", 4 | "namespace" : "com.gauravbytes.avro", 5 | "doc" : "Schema to hold employee object", 6 | "fields" : [{ 7 | "name" : "firstName", 8 | "type" : "string" 9 | }, 10 | { 11 | "name" : "lastName", 12 | "type" : "string" 13 | }, 14 | { 15 | "name" : "sex", 16 | "type" : { 17 | "name" : "SEX", 18 | "type" : "enum", 19 | "symbols" : ["MALE", "FEMALE"] 20 | } 21 | }] 22 | } -------------------------------------------------------------------------------- /serialization-avro-vs-java/src/main/avro/node.avsc: -------------------------------------------------------------------------------- 1 | { 2 | "type" : "record", 3 | "name" : "Node", 4 | "namespace" : "com.gauravbytes.avro", 5 | "doc" : "Schema to hold employee object", 6 | "fields" : [{ 7 | "name" : "value", 8 | "type" : "string" 9 | }, 10 | { 11 | "name" : "next", 12 | "type" : ["null", "Node"] 13 | }] 14 | } -------------------------------------------------------------------------------- /serialization-avro-vs-java/src/main/java/com/gauravbytes/avro/SEX.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Autogenerated by Avro 3 | * 4 | * DO NOT EDIT DIRECTLY 5 | */ 6 | package com.gauravbytes.avro; 7 | @SuppressWarnings("all") 8 | @org.apache.avro.specific.AvroGenerated 9 | public enum SEX { 10 | MALE, FEMALE ; 11 | public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"enum\",\"name\":\"SEX\",\"namespace\":\"com.gauravbytes.avro\",\"symbols\":[\"MALE\",\"FEMALE\"]}"); 12 | public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; } 13 | } 14 | -------------------------------------------------------------------------------- /serialization-avro-vs-java/src/main/java/com/gauravbytes/model/Node.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.model; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * 7 | * @author Gaurav Rai Mazra 8 | * 9 | */ 10 | public class Node implements Serializable { 11 | private static final long serialVersionUID = -4544953880547632256L; 12 | 13 | private String value; 14 | private Node next; 15 | 16 | public Node (String value) { 17 | this.value = value; 18 | } 19 | 20 | public void setNode(Node next) { 21 | this.next = next; 22 | } 23 | 24 | public Node getNode() { 25 | return this.next; 26 | } 27 | 28 | @Override 29 | public String toString() { 30 | return "Node [value=" + value + "]"; 31 | } 32 | 33 | 34 | } 35 | -------------------------------------------------------------------------------- /serialization-avro-vs-java/src/main/java/com/gauravbytes/model/Sex.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.model; 2 | 3 | public enum Sex { 4 | MALE, FEMALE; 5 | } 6 | -------------------------------------------------------------------------------- /singleton-java/singleton-java/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /singleton-java/singleton-java/.settings/org.eclipse.jdt.apt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.apt.aptEnabled=false 3 | -------------------------------------------------------------------------------- /singleton-java/singleton-java/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 3 | org.eclipse.jdt.core.compiler.compliance=1.8 4 | org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled 5 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning 6 | org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore 7 | org.eclipse.jdt.core.compiler.processAnnotations=disabled 8 | org.eclipse.jdt.core.compiler.release=disabled 9 | org.eclipse.jdt.core.compiler.source=1.8 10 | -------------------------------------------------------------------------------- /singleton-java/singleton-java/.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /singleton-java/singleton-java/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | com.gauravbytes 5 | singleton-java 6 | 0.0.1-SNAPSHOT 7 | 8 | 1.8 9 | 10 | 11 | 12 | 13 | 14 | org.apache.maven.plugins 15 | maven-compiler-plugin 16 | 3.6.0 17 | 18 | ${java.version} 19 | ${java.version} 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /singleton-java/singleton-java/src/main/java/com/gauravbytes/singleton/eager/Singleton.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.singleton.eager; 2 | 3 | /** 4 | * Eager initialized Singleton 5 | * @author Mazra, Gaurav Rai 6 | * 7 | */ 8 | public final class Singleton { 9 | private static final Singleton INSTANCE = new Singleton(); 10 | 11 | private Singleton() { 12 | 13 | } 14 | 15 | public static Singleton getInstance() { 16 | return INSTANCE; 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /singleton-java/singleton-java/src/main/java/com/gauravbytes/singleton/lazy/LazySingleton.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.singleton.lazy; 2 | 3 | /** 4 | * 5 | * @author Mazra, Gaurav Rai 6 | * 7 | */ 8 | public class LazySingleton { 9 | 10 | private static final class InstanceHolder { 11 | private static final LazySingleton INSTANCE = new LazySingleton(); 12 | } 13 | 14 | private LazySingleton() { 15 | 16 | } 17 | 18 | // with instance holder class 19 | public static final LazySingleton getInstance() { 20 | return InstanceHolder.INSTANCE; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /singleton-java/singleton-java/src/main/java/com/gauravbytes/singleton/lazy/LazySingletonDCL.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.singleton.lazy; 2 | 3 | import java.util.Objects; 4 | 5 | /** 6 | * @author Mazra, Gaurav Rai 7 | * 8 | */ 9 | public class LazySingletonDCL { 10 | private static LazySingletonDCL INSTANCE; 11 | private static final Object MUTEX = new Object(); 12 | 13 | private LazySingletonDCL() { 14 | 15 | } 16 | 17 | //Double check locking 18 | public static LazySingletonDCL getInstance() { 19 | LazySingletonDCL instance = INSTANCE; 20 | if (Objects.isNull(instance)) { 21 | synchronized (MUTEX) { 22 | if (Objects.isNull(instance)) 23 | INSTANCE = instance = new LazySingletonDCL(); 24 | } 25 | } 26 | return instance; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /singleton-java/singleton-java/src/main/java/com/gauravbytes/singleton/perclassloader/Singleton.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.singleton.perclassloader; 2 | 3 | /** 4 | * 5 | * @author Mazra, Gaurav Rai 6 | * 7 | */ 8 | public enum Singleton { 9 | INSTANCE; 10 | 11 | public void doStuff() { 12 | // 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /spring-DI/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | /.settings/ 3 | .classpath 4 | .project 5 | -------------------------------------------------------------------------------- /spring-DI/src/main/java/com/gauravbytes/di/parser/CSVFileParser.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.di.parser; 2 | 3 | import java.io.File; 4 | import java.util.logging.Logger; 5 | 6 | /** 7 | * 8 | * @author Mazra, Gaurav Rai 9 | * 10 | */ 11 | public class CSVFileParser implements Parser { 12 | private static final Logger logger = Logger.getLogger(CSVFileParser.class.getName()); 13 | 14 | @Override 15 | public void parse(File file) { 16 | // logic to parse CSV file goes here 17 | logger.info("Inside CSVFileParser"); 18 | } 19 | 20 | @Override 21 | public FileType getFileType() { 22 | return FileType.XML; 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /spring-DI/src/main/java/com/gauravbytes/di/parser/FileType.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.di.parser; 2 | 3 | /** 4 | * 5 | * @author Mazra, Gaurav Rai 6 | * 7 | */ 8 | public enum FileType { 9 | 10 | CSV(".csv"), XML(".xml"), JSON(".json"), PDF(".pdf"), RICHTEXT(".rtf"), TXT(".txt"); 11 | 12 | private String extension; 13 | 14 | private FileType(String extension) { 15 | this.extension = extension; 16 | } 17 | 18 | public String getExtension() { 19 | return this.extension; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /spring-DI/src/main/java/com/gauravbytes/di/parser/JsonFileParser.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.di.parser; 2 | 3 | import java.io.File; 4 | import java.util.logging.Logger; 5 | 6 | /** 7 | * 8 | * @author Mazra, Gaurav Rai 9 | * 10 | */ 11 | public class JsonFileParser implements Parser { 12 | private static final Logger logger = Logger.getLogger(JsonFileParser.class.getName()); 13 | 14 | @Override 15 | public void parse(File file) { 16 | // Logic to parse json file 17 | logger.info("Inside JSON Parser"); 18 | } 19 | 20 | @Override 21 | public FileType getFileType() { 22 | return FileType.JSON; 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /spring-DI/src/main/java/com/gauravbytes/di/parser/Parser.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.di.parser; 2 | 3 | import java.io.File; 4 | import java.util.Objects; 5 | 6 | /** 7 | * 8 | * @author Mazra, Gaurav Rai 9 | * 10 | */ 11 | public interface Parser { 12 | public void parse(File file); 13 | 14 | public FileType getFileType(); 15 | 16 | public default boolean canParse(File file) { 17 | return Objects.nonNull(file) && file.getName().endsWith(getFileType().getExtension()); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /spring-DI/src/main/java/com/gauravbytes/di/parser/XmlFileParser.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.di.parser; 2 | 3 | import java.io.File; 4 | import java.util.logging.Logger; 5 | 6 | /** 7 | * 8 | * @author Mazra, Gaurav Rai 9 | * 10 | */ 11 | public class XmlFileParser implements Parser { 12 | private static final Logger logger = Logger.getLogger(XmlFileParser.class.getName()); 13 | 14 | @Override 15 | public void parse(File file) { 16 | // logic to parse xml file 17 | logger.info("Inside XMLFileParser"); 18 | } 19 | 20 | @Override 21 | public FileType getFileType() { 22 | return FileType.XML; 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /spring-DI/src/main/java/com/gauravbytes/di/parser/config/ConstructorBasedDIConfig.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.di.parser.config; 2 | 3 | import org.springframework.context.annotation.ComponentScan; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.context.annotation.Import; 6 | 7 | /** 8 | * 9 | * @author Gaurav Rai Mazra 10 | * Catch me 11 | */ 12 | @Configuration 13 | @Import(value = ParserConfig.class) 14 | @ComponentScan(basePackages = "com.gauravbytes.di.parser.constructor") 15 | public class ConstructorBasedDIConfig { 16 | 17 | } 18 | -------------------------------------------------------------------------------- /spring-DI/src/main/java/com/gauravbytes/di/parser/config/ParserConfig.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.di.parser.config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | 6 | import com.gauravbytes.di.parser.JsonFileParser; 7 | import com.gauravbytes.di.parser.Parser; 8 | 9 | /** 10 | * 11 | * @author Gaurav Rai Mazra 12 | * Catch me 13 | */ 14 | @Configuration 15 | public class ParserConfig { 16 | @Bean 17 | Parser jsonFileParser() { 18 | return new JsonFileParser(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /spring-DI/src/main/java/com/gauravbytes/di/parser/config/SetterBasedDIConfig.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.di.parser.config; 2 | 3 | import org.springframework.context.annotation.ComponentScan; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.context.annotation.Import; 6 | 7 | /** 8 | * 9 | * @author Gaurav Rai Mazra 10 | * Catch me 11 | */ 12 | @Configuration 13 | @Import(value = ParserConfig.class) 14 | @ComponentScan(basePackages = "com.gauravbytes.di.parser.setter") 15 | public class SetterBasedDIConfig { 16 | 17 | } 18 | -------------------------------------------------------------------------------- /spring-DI/src/main/java/com/gauravbytes/di/parser/constructor/ConstructorBasedFileParser.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.di.parser.constructor; 2 | 3 | import java.io.File; 4 | 5 | import org.springframework.stereotype.Component; 6 | 7 | import com.gauravbytes.di.parser.Parser; 8 | 9 | /** 10 | * 11 | * @author Mazra, Gaurav Rai 12 | * 13 | */ 14 | @Component 15 | public class ConstructorBasedFileParser { 16 | private Parser parser; 17 | 18 | public ConstructorBasedFileParser(Parser parser) { 19 | this.parser = parser; 20 | } 21 | 22 | public void setParser(Parser parser) { 23 | this.parser = parser; 24 | } 25 | 26 | public void parseFile(File file) { 27 | if (parser.canParse(file)) { 28 | parser.parse(file); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /spring-DI/src/main/java/com/gauravbytes/di/parser/setter/SetterBasedFileParser.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.di.parser.setter; 2 | 3 | import java.io.File; 4 | 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Component; 7 | 8 | import com.gauravbytes.di.parser.Parser; 9 | 10 | /** 11 | * 12 | * @author Mazra, Gaurav Rai 13 | * 14 | */ 15 | @Component 16 | public class SetterBasedFileParser { 17 | private Parser parser; 18 | 19 | public SetterBasedFileParser() { 20 | } 21 | 22 | @Autowired 23 | public void setParser(Parser parser) { 24 | this.parser = parser; 25 | } 26 | 27 | public void parseFile(File file) { 28 | if (parser.canParse(file)) { 29 | parser.parse(file); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /spring-basic-auth-example/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | /.settings/ 3 | .classpath 4 | .project 5 | /logs/ 6 | -------------------------------------------------------------------------------- /spring-basic-auth-example/src/main/java/com/gauravbytes/hellogb/controller/HelloGbController.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.hellogb.controller; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | /** 7 | * 8 | * @author Gaurav Rai Mazra 9 | * Catch me 10 | */ 11 | @RestController 12 | public class HelloGbController { 13 | @GetMapping 14 | public String helloGb() { 15 | return "Gaurav Bytes says, \"Hello There!!!\""; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /spring-basic-auth-example/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8082 3 | undertow: 4 | ioThreads: 15 5 | workerThreads: 150 6 | accesslog: 7 | enabled: true 8 | compression: 9 | enabled: true 10 | mimeTypes: text/xml, text/css, text/html, application/json 11 | minResponseSize: 4096 12 | 13 | spring: 14 | application: 15 | name: gaurav-bytes-rest-jpa 16 | 17 | security: 18 | basic: 19 | enabled: true 20 | realm: gaurav-bytes 21 | user: 22 | name: gaurav 23 | password: bytes -------------------------------------------------------------------------------- /spring-bean-scope/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | /.settings/ 3 | .classpath 4 | .project 5 | -------------------------------------------------------------------------------- /spring-bean-scope/src/main/java/com/gauravbytes/springbeanscope/Dictionary.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.springbeanscope; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | /** 7 | * 8 | * @author Gaurav Rai Mazra 9 | * Catch me 10 | */ 11 | public class Dictionary { 12 | private List words; 13 | public Dictionary() { 14 | words = new ArrayList<>(); 15 | } 16 | 17 | public void addWord(String word) { 18 | this.words.add(word); 19 | } 20 | 21 | public int totalWords() { 22 | return this.words.size(); 23 | } 24 | 25 | @Override 26 | public String toString() { 27 | return words.toString(); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /spring-bean-scope/src/main/java/com/gauravbytes/springbeanscope/config/ScopeConfig.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.springbeanscope.config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.context.annotation.Scope; 6 | 7 | import com.gauravbytes.springbeanscope.Dictionary; 8 | 9 | @Configuration 10 | public class ScopeConfig { 11 | @Bean(name = "prototypeDictionary") 12 | @Scope("prototype") 13 | Dictionary prototypeDictionary() { 14 | return new Dictionary(); 15 | } 16 | 17 | @Bean(name = "singletonDictionary") 18 | @Scope("singleton") 19 | //you can omit the scope by default it is singleton 20 | Dictionary singletonDictionary() { 21 | return new Dictionary(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /spring-boot-angularjs-example/.bowerrc: -------------------------------------------------------------------------------- 1 | { 2 | "directory": "src/main/resources/static/bower_components", 3 | "json": "bower.json" 4 | } -------------------------------------------------------------------------------- /spring-boot-angularjs-example/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | /src/main/resources/static/bower_components/ 3 | /logs/ 4 | .classpath 5 | .project 6 | /.settings/ -------------------------------------------------------------------------------- /spring-boot-angularjs-example/bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "spring-boot-angularjs", 3 | "dependencies": { 4 | "angular": "~1.3.0", 5 | "angular-resource": "~1.3.0", 6 | "bootstrap-css-only": "~3.2.0", 7 | "lodash": "~4.17.4" 8 | } 9 | } -------------------------------------------------------------------------------- /spring-boot-angularjs-example/src/main/java/com/gauravbytes/feapp/UserApplication.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.feapp; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | /** 7 | * 8 | * @author Mazra, Gaurav Rais 9 | * 10 | */ 11 | @SpringBootApplication 12 | public class UserApplication { 13 | public static void main(String[] args) { 14 | SpringApplication.run(UserApplication.class, args); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-angularjs-example/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8082 3 | jpa: 4 | generate-ddl: true 5 | undertow: 6 | ioThreads: 15 7 | workerThreads: 150 8 | accesslog: 9 | enabled: true 10 | compression: 11 | enabled: true 12 | mimeTypes: text/xml, text/css, text/html, application/json 13 | minResponseSize: 4096 14 | 15 | spring: 16 | datasource: 17 | name: productdb 18 | application: 19 | name: spring-boot-angularjs-example -------------------------------------------------------------------------------- /spring-boot-angularjs-example/src/main/resources/static/js/app.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var App = angular.module('myApp',[]); 4 | 5 | 6 | -------------------------------------------------------------------------------- /spring-boot-hook-runner/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | /.settings/ 3 | .classpath 4 | .project 5 | -------------------------------------------------------------------------------- /spring-boot-hook-runner/src/main/java/com/gauravbytes/hellogb/App.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.hellogb; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | /** 7 | * 8 | * @author Gaurav Rai Mazra 9 | * Catch me 10 | */ 11 | @SpringBootApplication 12 | public class App { 13 | public static void main(String[] args) { 14 | SpringApplication.run(App.class, args); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-hook-runner/src/main/java/com/gauravbytes/hellogb/component/AppStartupRunner.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.hellogb.component; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import org.springframework.boot.ApplicationArguments; 6 | import org.springframework.boot.ApplicationRunner; 7 | import org.springframework.stereotype.Component; 8 | 9 | /** 10 | * 11 | * @author Gaurav Rai Mazra Catch me 12 | */ 13 | @Component 14 | public class AppStartupRunner implements ApplicationRunner { 15 | private static final Logger logger = LoggerFactory.getLogger(AppStartupRunner.class); 16 | 17 | @Override 18 | public void run(ApplicationArguments args) throws Exception { 19 | logger.info("Your application started with option names : {}", args.getOptionNames()); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /spring-boot-hook-runner/src/main/java/com/gauravbytes/hellogb/controller/HelloGbController.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.hellogb.controller; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | /** 7 | * 8 | * @author Gaurav Rai Mazra 9 | * Catch me 10 | */ 11 | @RestController 12 | public class HelloGbController { 13 | @GetMapping 14 | public String helloGb() { 15 | return "Gaurav Bytes says, \"Hello There!!!\""; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /spring-boot-quickstart/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | /.settings/ 3 | .classpath 4 | .project 5 | -------------------------------------------------------------------------------- /spring-boot-quickstart/src/main/java/com/gauravbytes/hellogb/App.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.hellogb; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | /** 7 | * 8 | * @author Gaurav Rai Mazra 9 | * Catch me 10 | */ 11 | @SpringBootApplication 12 | public class App { 13 | public static void main(String[] args) { 14 | SpringApplication.run(App.class, args); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-quickstart/src/main/java/com/gauravbytes/hellogb/controller/HelloGbController.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.hellogb.controller; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | /** 7 | * 8 | * @author Gaurav Rai Mazra 9 | * Catch me 10 | */ 11 | @RestController 12 | public class HelloGbController { 13 | @GetMapping 14 | public String helloGb() { 15 | return "Gaurav Bytes says, \"Hello There!!!\""; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /spring-boot-rest-jersey/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | /.settings/ 3 | .classpath 4 | .project 5 | /logs/ 6 | -------------------------------------------------------------------------------- /spring-boot-rest-jersey/src/main/java/com/gauravbytes/hellogb/App.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.hellogb; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | /** 7 | * 8 | * @author Gaurav Rai Mazra 9 | * Catch me 10 | */ 11 | @SpringBootApplication 12 | public class App { 13 | public static void main(String[] args) { 14 | SpringApplication.run(App.class, args); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-rest-jersey/src/main/java/com/gauravbytes/hellogb/GenericExceptionMapper.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.hellogb; 2 | 3 | import javax.ws.rs.core.Response; 4 | import javax.ws.rs.ext.ExceptionMapper; 5 | import javax.ws.rs.ext.Provider; 6 | 7 | /** 8 | * 9 | * @author Gaurav Rai Mazra 10 | * Catch me 11 | */ 12 | @Provider 13 | public class GenericExceptionMapper implements ExceptionMapper { 14 | 15 | @Override 16 | public Response toResponse(Throwable exception) { 17 | return Response.serverError().entity(exception.getMessage()).build(); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /spring-boot-rest-jersey/src/main/java/com/gauravbytes/hellogb/JerseyConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.hellogb; 2 | 3 | import javax.annotation.PostConstruct; 4 | import javax.ws.rs.ApplicationPath; 5 | 6 | import org.glassfish.jersey.server.ResourceConfig; 7 | import org.springframework.context.annotation.Configuration; 8 | 9 | import com.gauravbytes.hellogb.controller.BookController; 10 | 11 | /** 12 | * 13 | * @author Gaurav Rai Mazra 14 | * Catch me 15 | */ 16 | @Configuration 17 | @ApplicationPath("rest") 18 | public class JerseyConfiguration extends ResourceConfig { 19 | public JerseyConfiguration() { 20 | 21 | } 22 | 23 | @PostConstruct 24 | public void setUp() { 25 | register(BookController.class); 26 | register(GenericExceptionMapper.class); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /spring-boot-rest-jersey/src/main/java/com/gauravbytes/hellogb/model/Category.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.hellogb.model; 2 | 3 | public enum Category { 4 | FICTION, TECHNOLOGY, ROMMANCE, FREE_GYAN, NONE; 5 | } 6 | -------------------------------------------------------------------------------- /spring-boot-rest-jersey/src/main/java/com/gauravbytes/hellogb/service/BookNotFoundException.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.hellogb.service; 2 | 3 | public class BookNotFoundException extends RuntimeException { 4 | 5 | public BookNotFoundException(String message) { 6 | super(message); 7 | } 8 | 9 | /** 10 | * 11 | */ 12 | private static final long serialVersionUID = -8069763198347163909L; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /spring-boot-rest-jersey/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8082 3 | undertow: 4 | ioThreads: 15 5 | workerThreads: 150 6 | accesslog: 7 | enabled: true 8 | compression: 9 | enabled: true 10 | mimeTypes: text/xml, text/css, text/html, application/json 11 | minResponseSize: 4096 12 | 13 | spring: 14 | application: 15 | name: gaurav-bytes-embedded-server-example -------------------------------------------------------------------------------- /spring-boot-rest-jpa/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | /.settings/ 3 | .classpath 4 | .project 5 | /logs/ 6 | -------------------------------------------------------------------------------- /spring-boot-rest-jpa/src/main/java/com/gauravbytes/gkart/App.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.gkart; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.data.jpa.repository.config.EnableJpaRepositories; 6 | 7 | /** 8 | * 9 | * @author Gaurav Rai Mazra Catch me 10 | */ 11 | @SpringBootApplication 12 | @EnableJpaRepositories 13 | public class App { 14 | public static void main(String[] args) { 15 | SpringApplication.run(App.class, args); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /spring-boot-rest-jpa/src/main/java/com/gauravbytes/gkart/entity/Color.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.gkart.entity; 2 | 3 | /** 4 | * 5 | * @author Gaurav Rai Mazra 6 | * 7 | */ 8 | public enum Color { 9 | RED, WHITE, PINK, YELLOW; 10 | } 11 | -------------------------------------------------------------------------------- /spring-boot-rest-jpa/src/main/java/com/gauravbytes/gkart/entity/Size.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.gkart.entity; 2 | 3 | /** 4 | * 5 | * @author Gaurav Rai Mazra 6 | * 7 | */ 8 | public enum Size { 9 | SMALL(0), MEDIUM(1), LARGE(2), NOT_APPLICABLE(3); 10 | private int size; 11 | 12 | Size(int size) { 13 | this.size = size; 14 | } 15 | 16 | public int getSize() { 17 | return this.size; 18 | } 19 | 20 | public static Size of(int size) { 21 | for (Size s : Size.values()) { 22 | if (s.getSize() == size) 23 | return s; 24 | } 25 | return Size.NOT_APPLICABLE; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /spring-boot-rest-jpa/src/main/java/com/gauravbytes/gkart/jpa/ProductRepository.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.gkart.jpa; 2 | 3 | import javax.transaction.Transactional; 4 | 5 | import org.springframework.data.jpa.repository.JpaRepository; 6 | 7 | import com.gauravbytes.gkart.entity.Product; 8 | 9 | /** 10 | * 11 | * @author Gaurav Rai Mazra 12 | * Catch me 13 | */ 14 | @Transactional 15 | public interface ProductRepository extends JpaRepository { 16 | 17 | } 18 | -------------------------------------------------------------------------------- /spring-boot-rest-jpa/src/main/java/com/gauravbytes/gkart/jpa/RatingRepository.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.gkart.jpa; 2 | 3 | import javax.transaction.Transactional; 4 | 5 | import org.springframework.data.jpa.repository.JpaRepository; 6 | 7 | import com.gauravbytes.gkart.entity.Rating; 8 | 9 | /** 10 | * 11 | * @author Gaurav Rai Mazra 12 | * Catch me 13 | */ 14 | @Transactional 15 | public interface RatingRepository extends JpaRepository { 16 | public Iterable getRatingsByProductId(final String productId); 17 | } 18 | -------------------------------------------------------------------------------- /spring-boot-rest-jpa/src/main/java/com/gauravbytes/gkart/jpa/UserRepository.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.gkart.jpa; 2 | 3 | import javax.transaction.Transactional; 4 | 5 | import org.springframework.data.jpa.repository.JpaRepository; 6 | 7 | import com.gauravbytes.gkart.entity.User; 8 | 9 | /** 10 | * 11 | * @author Gaurav Rai Mazra 12 | * Catch me 13 | */ 14 | @Transactional 15 | public interface UserRepository extends JpaRepository { 16 | 17 | } 18 | -------------------------------------------------------------------------------- /spring-boot-rest-jpa/src/main/java/com/gauravbytes/gkart/service/exception/GenericServiceException.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.gkart.service.exception; 2 | 3 | /** 4 | * 5 | * @author Gaurav Rai Mazra 6 | * Catch me 7 | */ 8 | public class GenericServiceException extends RuntimeException { 9 | 10 | /** 11 | * 12 | */ 13 | private static final long serialVersionUID = -3681636607322599994L; 14 | 15 | public GenericServiceException(String message) { 16 | super(message); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /spring-boot-rest-jpa/src/main/java/com/gauravbytes/gkart/vo/ResponseVO.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.gkart.vo; 2 | 3 | /** 4 | * 5 | * @author Gaurav Rai Mazra 6 | * Catch me 7 | * @param of type 8 | */ 9 | public class ResponseVO { 10 | private T results; 11 | 12 | public ResponseVO(T results) { 13 | this.results = results; 14 | } 15 | 16 | public T getResults() { 17 | return this.results; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /spring-boot-rest-jpa/src/main/java/schema.sql: -------------------------------------------------------------------------------- 1 | create schema PRODUCT; -------------------------------------------------------------------------------- /spring-boot-rest-jpa/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8082 3 | jpa: 4 | generate-ddl: true 5 | undertow: 6 | ioThreads: 15 7 | workerThreads: 150 8 | accesslog: 9 | enabled: true 10 | compression: 11 | enabled: true 12 | mimeTypes: text/xml, text/css, text/html, application/json 13 | minResponseSize: 4096 14 | 15 | spring: 16 | datasource: 17 | name: productdb 18 | application: 19 | name: gaurav-bytes-rest-jpa -------------------------------------------------------------------------------- /spring-embedded-server-example/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | /.settings/ 3 | .classpath 4 | .project 5 | -------------------------------------------------------------------------------- /spring-embedded-server-example/src/main/java/com/gauravbytes/hellogb/App.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.hellogb; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | /** 7 | * 8 | * @author Gaurav Rai Mazra 9 | * Catch me 10 | */ 11 | @SpringBootApplication 12 | public class App { 13 | public static void main(String[] args) { 14 | SpringApplication.run(App.class, args); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /spring-embedded-server-example/src/main/java/com/gauravbytes/hellogb/controller/HelloGbController.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.hellogb.controller; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | /** 7 | * 8 | * @author Gaurav Rai Mazra 9 | * Catch me 10 | */ 11 | @RestController 12 | public class HelloGbController { 13 | @GetMapping 14 | public String helloGb() { 15 | return "Gaurav Bytes says, \"Hello There!!!\""; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /spring-embedded-server-example/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8082 3 | undertow: 4 | ioThreads: 15 5 | workerThreads: 150 6 | accesslog: 7 | enabled: true 8 | compression: 9 | enabled: true 10 | mimeTypes: text/xml, text/css, text/html, application/json 11 | minResponseSize: 4096 12 | 13 | spring: 14 | application: 15 | name: gaurav-bytes-embedded-server-example -------------------------------------------------------------------------------- /spring-import-example/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | /.settings/ 3 | .classpath 4 | .project 5 | -------------------------------------------------------------------------------- /spring-import-example/src/main/java/com/gauravbytes/hellogb/config/DBConfig.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.hellogb.config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | 6 | import com.gauravbytes.hellogb.dao.FunnyDao; 7 | 8 | /** 9 | * 10 | * @author Gaurav Rai Mazra 11 | * 12 | */ 13 | @Configuration 14 | public class DBConfig { 15 | // beans related to various database/ Daos/ Templates etc 16 | // I am creating funny dao 17 | @Bean(name = "funny") 18 | FunnyDao funnyDao() { 19 | return new FunnyDao(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /spring-import-example/src/main/java/com/gauravbytes/hellogb/config/HelloGbAppConfig.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.hellogb.config; 2 | 3 | import org.springframework.context.annotation.Configuration; 4 | import org.springframework.context.annotation.Import; 5 | 6 | /** 7 | * 8 | * @author Gaurav Rai Mazra 9 | * 10 | */ 11 | @Configuration 12 | @Import(value = { DBConfig.class, WelcomeGbConfig.class }) 13 | public class HelloGbAppConfig { 14 | 15 | } 16 | -------------------------------------------------------------------------------- /spring-import-example/src/main/java/com/gauravbytes/hellogb/config/WelcomeGbConfig.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.hellogb.config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | 6 | import com.gauravbytes.hellogb.service.GreetingService; 7 | 8 | /** 9 | * 10 | * @author Gaurav Rai Mazra 11 | * 12 | */ 13 | @Configuration 14 | public class WelcomeGbConfig { 15 | 16 | @Bean 17 | GreetingService greetingService() { 18 | return new GreetingService(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /spring-import-example/src/main/java/com/gauravbytes/hellogb/dao/FunnyDao.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.hellogb.dao; 2 | 3 | import java.util.logging.Logger; 4 | 5 | /** 6 | * 7 | * @author Gaurav Rai Mazra 8 | * 9 | */ 10 | public class FunnyDao { 11 | private static final Logger logger = Logger.getLogger(FunnyDao.class.getName()); 12 | 13 | public FunnyDao() { 14 | 15 | } 16 | 17 | public void save(String message) { 18 | logger.info(String.format("I log funny on console in a funny mode: %s", message)); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /spring-import-example/src/main/java/com/gauravbytes/hellogb/service/GreetingService.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.hellogb.service; 2 | 3 | import java.util.logging.Logger; 4 | 5 | /** 6 | * 7 | * @author Gaurav Rai Mazra 8 | * 9 | */ 10 | public class GreetingService { 11 | private static final Logger logger = Logger.getLogger(GreetingService.class.getName()); 12 | 13 | public GreetingService() { 14 | 15 | } 16 | 17 | public void greet() { 18 | logger.info("Gaurav Bytes: Your first tutorial on Spring!!!"); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /spring-java-config/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | /.settings/ 3 | .classpath 4 | .project 5 | -------------------------------------------------------------------------------- /spring-java-config/src/main/java/com/gauravbytes/hellogb/App.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.hellogb; 2 | 3 | import org.springframework.context.ConfigurableApplicationContext; 4 | import org.springframework.context.annotation.AnnotationConfigApplicationContext; 5 | 6 | import com.gauravbytes.hellogb.config.WelcomeGbConfig; 7 | import com.gauravbytes.hellogb.service.GreetingService; 8 | 9 | /** 10 | * 11 | * @author Gaurav Rai Mazra 12 | * 13 | */ 14 | public class App { 15 | public static void main(String[] args) { 16 | // using try with resources so that this context closes automatically 17 | try (ConfigurableApplicationContext context = new AnnotationConfigApplicationContext( 18 | WelcomeGbConfig.class);) { 19 | GreetingService greetingService = context.getBean(GreetingService.class); 20 | greetingService.greet(); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /spring-java-config/src/main/java/com/gauravbytes/hellogb/config/WelcomeGbConfig.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.hellogb.config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | 6 | import com.gauravbytes.hellogb.service.GreetingService; 7 | 8 | /** 9 | * 10 | * @author Gaurav Rai Mazra 11 | * 12 | */ 13 | @Configuration 14 | public class WelcomeGbConfig { 15 | 16 | @Bean 17 | GreetingService greetingService() { 18 | return new GreetingService(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /spring-java-config/src/main/java/com/gauravbytes/hellogb/service/GreetingService.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.hellogb.service; 2 | 3 | import java.util.logging.Logger; 4 | 5 | /** 6 | * 7 | * @author Gaurav Rai Mazra 8 | * 9 | */ 10 | public class GreetingService { 11 | private static final Logger logger = Logger.getLogger(GreetingService.class.getName()); 12 | 13 | public GreetingService() { 14 | 15 | } 16 | 17 | public void greet() { 18 | logger.info("Gaurav Bytes: Your first tutorial on Spring!!!"); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /spring-new-request-mapping/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | /.settings/ 3 | .classpath 4 | .project -------------------------------------------------------------------------------- /spring-new-request-mapping/src/main/java/com/gaurabytes/api/SpringBootApp.java: -------------------------------------------------------------------------------- 1 | package com.gaurabytes.api; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | 7 | /** 8 | * 9 | * @author Gaurav Rai Mazra 10 | * 11 | */ 12 | @SpringBootApplication 13 | @EnableAutoConfiguration 14 | public class SpringBootApp { 15 | public static void main(String[] args) { 16 | SpringApplication.run(SpringBootApp.class, args); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /spring-property-file/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | /.settings/ 3 | .classpath 4 | .project 5 | -------------------------------------------------------------------------------- /spring-property-file/src/main/resources/application-db.properties: -------------------------------------------------------------------------------- 1 | db.username=gaurav 2 | db.password=mys3cr3t 3 | db.url=localhost:3306 -------------------------------------------------------------------------------- /spring-quickstart/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | .classpath 3 | .project 4 | /.settings/ 5 | -------------------------------------------------------------------------------- /spring-quickstart/src/main/java/com/gauravbytes/hellogb/App.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.hellogb; 2 | 3 | import org.springframework.context.ConfigurableApplicationContext; 4 | import org.springframework.context.annotation.AnnotationConfigApplicationContext; 5 | 6 | import com.gauravbytes.hellogb.service.GreetingService; 7 | 8 | /** 9 | * 10 | * @author Gaurav Rai Mazra 11 | * 12 | */ 13 | public class App { 14 | public static void main(String[] args) { 15 | // using try with resources so that this context closes automatically 16 | try (ConfigurableApplicationContext context = new AnnotationConfigApplicationContext( 17 | "com.gauravbytes.hellogb.service");) { 18 | GreetingService greetingService = context.getBean(GreetingService.class); 19 | greetingService.greet(); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /spring-quickstart/src/main/java/com/gauravbytes/hellogb/service/GreetingService.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.hellogb.service; 2 | 3 | import java.util.logging.Logger; 4 | 5 | import org.springframework.stereotype.Service; 6 | 7 | /** 8 | * 9 | * @author Gaurav Rai Mazra 10 | * 11 | */ 12 | @Service 13 | public class GreetingService { 14 | private static final Logger logger = Logger.getLogger(GreetingService.class.getName()); 15 | 16 | public GreetingService() { 17 | 18 | } 19 | 20 | public void greet() { 21 | logger.info("Gaurav Bytes welcomes you for your first tutorial on Spring!!!"); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /spring-security-digest-example/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | /.settings/ 3 | .classpath 4 | .project 5 | /logs/ 6 | -------------------------------------------------------------------------------- /spring-security-digest-example/src/main/java/com/gauravbytes/hellogb/controller/HelloGbController.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.hellogb.controller; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | /** 7 | * 8 | * @author Gaurav Rai Mazra 9 | * Catch me 10 | */ 11 | @RestController 12 | public class HelloGbController { 13 | @GetMapping 14 | public String helloGb() { 15 | return "Gaurav Bytes says, \"Hello There!!!\""; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /spring-security-digest-example/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8082 3 | undertow: 4 | ioThreads: 15 5 | workerThreads: 150 6 | accesslog: 7 | enabled: true 8 | compression: 9 | enabled: true 10 | mimeTypes: text/xml, text/css, text/html, application/json 11 | minResponseSize: 4096 12 | 13 | spring: 14 | application: 15 | name: gaurav-bytes-spring-security-digest 16 | 17 | security: 18 | basic: 19 | enabled: false -------------------------------------------------------------------------------- /spring-security-form-based-auth/.bowerrc: -------------------------------------------------------------------------------- 1 | { 2 | "directory": "src/main/resources/static/bower_components", 3 | "json": "bower.json" 4 | } -------------------------------------------------------------------------------- /spring-security-form-based-auth/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | /.settings/ 3 | .classpath 4 | .project 5 | /logs/ 6 | /src/main/resources/static/bower_components/ 7 | -------------------------------------------------------------------------------- /spring-security-form-based-auth/bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "spring-boot-angularjs", 3 | "dependencies": { 4 | "angular": "~1.3.0", 5 | "angular-resource": "~1.3.0", 6 | "bootstrap-css-only": "~3.2.0", 7 | "lodash": "~4.17.4" 8 | } 9 | } -------------------------------------------------------------------------------- /spring-security-form-based-auth/src/main/java/com/gauravbytes/feapp/UserApplication.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.feapp; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | 7 | /** 8 | * 9 | * @author Mazra, Gaurav Rais 10 | * 11 | */ 12 | @SpringBootApplication 13 | @EnableAutoConfiguration 14 | public class UserApplication { 15 | public static void main(String[] args) { 16 | SpringApplication.run(UserApplication.class, args); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /spring-security-form-based-auth/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8082 3 | undertow: 4 | ioThreads: 15 5 | workerThreads: 150 6 | accesslog: 7 | enabled: true 8 | compression: 9 | enabled: true 10 | mimeTypes: text/xml, text/css, text/html, application/json 11 | minResponseSize: 4096 12 | 13 | spring: 14 | thymeleaf: 15 | prefix: classpath:/static/ 16 | application: 17 | name: spring-security-form-based-auth 18 | 19 | security: 20 | basic: 21 | enabled: false 22 | 23 | logging: 24 | level: 25 | root: INFO -------------------------------------------------------------------------------- /spring-security-form-based-auth/src/main/resources/static/index.html: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | GauravBytes.com: Your first Spring Security example 6 | 7 | 9 | 10 | 11 | 12 | 13 | 14 | Welcome to your first example on Spring Security Form-based authentication 15 | You can read the step by step tutorial on gauravbytes 16 | Go to the View Users 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /spring-security-form-based-auth/src/main/resources/static/js/app.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var App = angular.module('myApp',[]); 4 | 5 | 6 | -------------------------------------------------------------------------------- /springjdbc-examples/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | .classpath 3 | .project 4 | /.settings/* 5 | -------------------------------------------------------------------------------- /springjdbc-examples/src/main/java/com/gauravbytes/springjdbc/ProductRowMapper.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.springjdbc; 2 | 3 | import java.sql.ResultSet; 4 | import java.sql.SQLException; 5 | 6 | import org.springframework.jdbc.core.RowMapper; 7 | 8 | import com.gauravbytes.springjdbc.dto.Product; 9 | 10 | /** 11 | * 12 | * @author Gaurav Rai Mazra 13 | * 14 | */ 15 | class ProductRowMapper implements RowMapper { 16 | 17 | @Override 18 | public Product mapRow(ResultSet rs, int rowNum) throws SQLException { 19 | Product product = new Product(); 20 | product.setId(rs.getInt("id")); 21 | product.setName(rs.getString("name")); 22 | product.setDescription(rs.getString("description")); 23 | product.setCategory(rs.getString("category")); 24 | return product; 25 | } 26 | 27 | } -------------------------------------------------------------------------------- /springjdbc-examples/src/main/java/com/gauravbytes/springjdbc/ds/JdbcDataSourceUtils.java: -------------------------------------------------------------------------------- 1 | package com.gauravbytes.springjdbc.ds; 2 | 3 | import javax.sql.DataSource; 4 | 5 | import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder; 6 | import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType; 7 | 8 | /** 9 | * Config class for embedded datasource 10 | * @author Gaurav Rai Mazra 11 | * My blog 12 | * Website 13 | */ 14 | public class JdbcDataSourceUtils { 15 | public static DataSource getH2Database() 16 | { 17 | return new EmbeddedDatabaseBuilder().setType(EmbeddedDatabaseType.H2) 18 | .addScript("classpath:/create-db.sql") 19 | .addScript("classpath:/insert-data.sql") 20 | .build(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /springjdbc-examples/src/main/resources/create-db.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE IF NOT EXISTS product ( 2 | id INTEGER PRIMARY KEY AUTO_INCREMENT, 3 | name VARCHAR(50), 4 | category varchar(50), 5 | description VARCHAR(100) 6 | ); -------------------------------------------------------------------------------- /springjdbc-examples/src/main/resources/insert-data.sql: -------------------------------------------------------------------------------- 1 | insert into product VALUES(1, 'Apple IPhone 6s', 'mobile', 'A very good build phone'); 2 | insert into product VALUES(2, 'Apple IPhone 7', 'mobile', 'A very good build phone'); 3 | insert into product VALUES(3, 'Apple IPhone 8', 'mobile', 'A very good build phone'); 4 | insert into product VALUES(4, 'Apple IPhone 8 plus', 'mobile', 'A very good build phone'); 5 | insert into product VALUES(5, 'Apple IPhone X', 'mobile', 'A very good build phone'); 6 | insert into product VALUES(6, 'Apple Ipad 2', 'tablet', 'Tablet built for your taste'); 7 | insert into product VALUES(7, 'Apple Ipad Pro', 'tablet', 'Tablet built for your taste'); -------------------------------------------------------------------------------- /tdd-refactoring/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | .project 3 | .classpath 4 | /.settings/* 5 | -------------------------------------------------------------------------------- /tdd-refactoring/pom.xml: -------------------------------------------------------------------------------- 1 | 4 | 4.0.0 5 | com.gauravbytes.tdd 6 | tdd-refactoring 7 | 0.0.1-SNAPSHOT 8 | 9 | 1.8 10 | 1.8 11 | 12 | 13 | -------------------------------------------------------------------------------- /xml-builder-tdd/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | .classpath 3 | .project 4 | /.settings/* 5 | --------------------------------------------------------------------------------
{{ product.description }}
You can read the step by step tutorial on gauravbytes
Go to the View Users