Sunday, December 27, 2020

First steps with git: clone, add, commit, push Intro version control git

 Create a new repository on GitHub

  1. To begin, sign in to your user account on GitHub.
  2. In the upper right corner, click the + sign icon, then choose New repository. This will take you to a page where you can enter a repository name (this tutorial uses test-repo as the repository name), description, and choose to initialize with a README (a good idea!).
  3. It is a good idea to add a .gitignore file by selecting one of the languages from the drop down menu, though for this tutorial it will not be necessary.
  4. Similarly, in practice you should choose a license to that people know whether and how they can use your code.
  5. Once you have entered a repository name and made your selection, select Create repository, and you will be taken to your new repository web page.

Git at the command line

Below you will learn a series of commands that you can run at the command line in git bash, terminal of whatever bash tool you are using. There are 2 types of commands that you will use

  1. Bash commands: These are commands that are native to bash / shell. They allow you to navigate around your computer, explore directory structures, create and manipulate files and directories, and more. (e.g. ls, cd, mkdir, etc)

  2. Git commands: These are commands that are specific to git and will only be available if you have git installed on your computer. Git specific commands will always started with a call to git (e.g. git status, git clone, etc)

Clone your repository to your local machine

Next, clone your newly created repository from GitHub to your local computer. From your repository page on GitHub, click the green button labeled Clone or download, and in the “Clone with HTTPs” section, copy the URL for your repository.

Next, on your local machine, open your bash shell and change your current working directory to the location where you would like to clone your repository. Note that here we are using a bash command - cd (change directory).

For example, on a Unix based system, if you wanted to have your repository in your Documents folder, you change directories as follows:

cd Documents

Once you have navigated to the directory where you want to put your repository, you can use:

git clone https://github.com/URL-TO-REPO-HERE

The git clone command copies your repository from GitHub to your local computer. Note that this is a git specific command.

When you run git clone repo-path-here, You should see output like:

Cloning into 'test-repo'...
remote: Counting objects: 5, done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 5 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (5/5), done.
Checking connectivity... done.

Note: The repository name and output numbers that you see on your computer, representing the total file size, etc, may differ from the example provided above.

To verify that your repository now exists locally, type ls in your terminal. The ls command lists the files & folders available in your current directory. You should see a directory with the same name as the repository that you created previously on GitHub.

Tracking changes with git add and git commit

Next use cd to change directories using the syntax:

cd my-repo-name

Replace my-repo-name with the folder name of your repo (this should be your repo name - e.g. 14ers-git)

cd test-repo

If you list all the files in this directory (using ls -a), you should see all of the files that exist in your GitHub repository:

ls -a
.git  .gitignore  LICENSE  README.md

Alternatively, we can view the local repository in the finder (Mac), a Windows Explorer (Windows) window, or GUI file browser (Linux).

Simply open your file browser and navigate to the new local repo.

 Important Tip The .git element is listed when you use the ls -a command shows up is actually a directory which will keep track of your changes (the commits that you make) in git. Warning: Do not edit the files in this directory manually!

Using either method, we can see that the file structure of our cloned repo mirrors the file structure of our forked GitHub repo.

Edit a file in your repo

Next, open up your favorite text editor and make a few edits to the README.md file. Save your changes.

Once you are happy with your changes and have saved them, go back to your terminal window and type git status and hit return to execute the command.

git status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

	modified:   README.md

no changes added to commit (use "git add" and/or "git commit -a")

The output from git status indicates that you have modified the file README.md. To keep track of this change to this file, you need to

  1. add the changes, then
  2. commit the changes.

Add and commit changes

You will use the add and commit functions to add and commit changes that you make to git.

  • git add: takes a modified file in your working directory and places the modified version in a staging area.
  • git commit takes everything from the staging area and makes a permanent snapshot of the current state of your repository that is associated with a unique identifier.

These two commands make up the bulk of many workflows that use git for version control.

Modified files are staged using git add, and following a commit, all files in the staging area are snapshotted and become part of the repository's history, receiving a unique SHA-1 hash identifier.
Modified files are staged using git add, and following a commit, all files in the staging area are snapshotted and become part of the repository's history, receiving a unique SHA-1 hash identifier. Source: Maxwell Joseph, adapted from Pro Git by Chacon and Straub (2014).

Add files

You can add an individual file or groups of files to git tracking. To add a single file, use

git add file-name-here-with-extension

To add the README.md file that you just modified, you’d use:

git add README.md

To add ALL of the files that you have edited at the same time, you can use:

git add --all

Use git add --all with caution. You do not want to accidentally add things like credential files, .DS_Store files, or history files.

Commit files

Once you are ready to make a snapshot of the current state of your repository, you can use git commit. The git commit command requires a commit message that describes the snapshot / changes that you made in that commit.

A commit message should outline what changed and why. These messages

  1. help collaborators and your future self understand what was changed and why
  2. allow you and your collaborators to find (and undo if necessary) changes that were previously made.

If you are not committing a lot of changes, you can create a short one line commit message using the -m flag:

git commit -m "Editing the README to try out git add/commit"

Alternatively, if you are committing many changes, or a small number of changes that require explanation, you’ll want to write a detailed multi-line commit message using a text editor.

If you have configured git to use your favorite text editor (via git config --global core.editor your-fav-editor-here), then you can open that editor to write your commit message using the git commit command:

git commit

Once you save your commit message and exit the text editor, the file that you created will contain your commit message.

Multiple Choice Questions - Angular2 Events

Answers

1) a,d, 2) a, 3) b, 4) c,d, 5) c, 6) a, 7) b, 8) d, 9) c, 10) a 

1. Event binding can be defined . . . . . . . . .


A) by wrapping the event in (parenthesis)
B) by prefixing it with in-
C) by wrapping the event in {curly brackets}
D) by prefixing it with on-

2. EventEmitter class acts both as an observer and observable.

A) True
B) False

3. Events in Angular 2 behave like normal DOM events. They can bubble up but cannot propagate down.

A) True
B) False

4. EventEmitter class’s simple interface, which basically encompass two methods . . . . . . . . . can therefore be used to trigger custom events and listen to events as well, both synchronously or asynchronously.

A) exit()
B) superscript()
C) subscribe()
D) emit()

5. Angular framework provides event binding using in-built event as well as custom event. Custom events are the EventEmitter instances. To create a custom event we need to create an instance of EventEmitter annotated by . . . . . . .

A) @Input()
B) @Get()
C) @Output()
D) @Set()

6. EventEmitter class is used by directives and components to emit custom Events.

A) True
B) False

7. @Output() myEvent = new EventEmitter();

A) Declares an output property that fires events that you cannot subscribe to with an event binding.
B) Declares an output property that fires events that you can subscribe to with an event binding.

C) Declares an output property that overrides events that you can subscribe to with an event binding.
D) Declares an output property that subscribes events that you can subscribe to with an event binding.

8. . . . . . . . . need to be passed as a parameter in the event callback from the template to capture the event object.

A) $event.start
B) $events
C) $eventobj
D) $event

9. Calling . . . . . . . . on the event prevents propagation.

A) stopEventPropagation
B) preventEventPropagation
C) stopPropagation
D) preventPropagation

10. Events on child elements are propagated upwards, and hence event binding is also possible on a parent element.

A) True
B) False


Multiple Choice Questions - Angular 2

 1. Angular 2 is a cross platform framework.


A) True
B) False

2. Angular 2 is entirely component based. Controllers and $scope are no longer used. They have been replaced by . . . . . . . and . . . . . . . .

A) components, controllers
B) $scopes, components
C) components, directives
D) controllers, directives

3. Angular 2 still does not provide nested components.

A) True
B) False

4. Angular 2 components can be described using . . . . . . A . . . . . . is a way to do some meta-programming.

A) controllers, controller
B) loaders, loader
C) typescripts, typescript
D) decorators, decorator

5. Angular 2 uses . . . . . . . . syntax for built-in directives.

A) Pascal case
B) Snake case
C) Camel case
D) Underscore case

6. You can use languages like . . . . . . . . . to write Angular 2 code.

A) ES5
B) ES6
C) TypeScriptor
D) Dart

7. Angular 2 uses . . . . . . . . . for fast views on mobile.

A) client side rendering
B) server side rendering

8. The . . . . . . . . . . directive substitutes the normal href property and makes it easier to work with route links in Angular 2.

A) RouterLink
B) RouterRend
C) RouterLike
D) RouterLayer

9. There are two ways to build forms in Angular 2, namely . . . . and . . . . . .

A) interface-driven
B) model-driven
C) template-driven
D) modular-driven

10. Angular 2 is an open source JavaScript framework to build web applications in HTML and JavaScript and has been conceived as a . . . . . . . . .

A) mobile first approach
B) UI first approach
C) web first approach
D) all of above

11. Angular 1 core concept was $scope, and you will not find $scope in angular 2.0. Angular 2 is using . . . . . . . . to detect changes.

A) zone$.js
B) Scope.js
C) zone.js
D) zones.js

12. Angular 2 integrates easily with NativeScript, allowing you to code your native app in a . . . . . . . . . style that can run on any mobile device platform.

A) declarative
B) imperative
C) interrogative
D) exclamatory

13. Angular 2 make use of the . . . . . . . module syntax.

A) ES2016a
B) ES2017
C) ES2016
D) ES2015

14. In Angular 2, applications rely upon the . . . . . . . method to load top-level components

A) loadstrap
B) bootstrap
C) bootload
D) none of above

15. In Angular 2.0, the template compilation process is . . . . . . .

A) synchronous
B) asynchronous

16. On the opposite side of event bindings (()) lie Angular's square-bracket syntax ([]) which signify a . . . . . .

A) property binding
B) class binding
C) style binding
D) both A & B

17. Angular 2.0 contains a logging service called . . . . . which is very useful feature measuring where time is spent in your application.

A) config.js
B) logging.js
C) diary.js
D) none of above

18. The router in Angular 2.0 has been reworked to be simple, yet extensible. It will include the following basic features:

A) Simple JSON-based Route Config
B) Optional Convention over Configuration
C) Static, Parameterized and Splat Route Patterns
D) URL Unresolver
E) All of above

19. Angular 2 has a . . . . . . . service that allows us to dynamically load a component in a certain position on the page.

A) DynamicControlLoader
B) DynamicControllerLoader
C) DynaCompLoader
D) DynamicComponentLoader

20. Angular 2 can detect when component data changes, and then automatically re-render the view to reflect that change.

A) True
B) False


Answers

1) a, 2) c, 3) b, 4) d, 5) c, 6) a,b,c,d, 7) b, 8) a, 9) b,c, 10) a, 11) c, 12) a, 13) d, 14) b, 15) b, 16) a, 17) c, 18) a,b,c, 19) d, 20) a






Lab 09: Publish and subscribe to Event Grid events

  Microsoft Azure user interface Given the dynamic nature of Microsoft cloud tools, you might experience Azure UI changes that occur after t...