Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Nir Galon committed Aug 14, 2022
1 parent 2555081 commit 52cbec3
Show file tree
Hide file tree
Showing 20 changed files with 650 additions and 732 deletions.
9 changes: 6 additions & 3 deletions content/posts/2014/learn-git-part-1-introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ math:
lightgallery: true
license: ""
---

I think everybody here at least heard about [GitHub](https://github.com) and maybe even about the file management system called [git](https://git-scm.com) which is everywhere in the development world those days. So, as a computer science student I choose to learn it, and what batter way to learn something then to write about it.

So in this series of posts I'll document my journey to learn git (which is the base of GitHub as the only version control you can use on the platform). I hope more people can use it as a learning document or even to deepen their knowledge in the tool.
Expand Down Expand Up @@ -105,6 +106,7 @@ nothing added to commit but untracked files present (use "git add" to track)
```

We can see we got couple of pieces of information back:

- We are on branch `master` (we'll take about branches later)
- There is no commits yet in this repo.
- We have a new file (file that `git` doesn't track) in the name of `README.md`
Expand All @@ -126,7 +128,7 @@ Changes to be committed:

We see almost the same pieces of information, but now `git` have a file in his _staging area_ (a file ready to be `commit`ed). So, it's time to do our first `commit`. To do this we'll use the `commit` command. A flag that the `commit` command have is `m` which means _"message"_, with this flag we can add a message to the `commit` to describe the changes this `commit` is do.

When we do the `commit` we basically take a snapshot of our file system in this exact time. Even a space means a change. This commit is added to the repo (project) timeline (it's accepted to draw it and imagine it as a timeline, because every `commit` has a timestamp, so we can place them all on a big timeline from the start of the project until now).
When we do the `commit` we basically take a snapshot of our file system in this exact time. Even a space means a change. This commit is added to the repo (project) timeline (it's accepted to draw it and imagine it as a timeline, because every `commit` has a timestamp, so we can place them all on a big timeline from the start of the project until now).

```bash
$ git commit -m "Created an empty README file"
Expand Down Expand Up @@ -188,6 +190,7 @@ $ git commit -m "Add a new LICENSE file and finish README"
```

To look at the history, the log, of the current timeline we can use the `log` command. We see there're two `commit`s in the branch (timeline) we're currently at. And also much more information:

- We're in the `master` branch (timeline).
- The `commit`s hash, which is a unique string of number and letters to represent that `commit`. It's basically the name of the `commit`, with it we can reference that `commit`.
- The author and the exact time and date of the `commit`.
Expand Down Expand Up @@ -215,8 +218,8 @@ gitGraph:
options
{ "nodeSpacing": 150, "nodeRadius": 10 }
end
commit
commit
commit
commit
{{< /mermaid >}}

&nbsp;
Expand Down
44 changes: 23 additions & 21 deletions content/posts/2014/learn-git-part-2-getting-our-hands-dirty.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ math:
lightgallery: true
license: ""
---

This part is a direct continuation of [Learn Git - Part 1: introduction](https://lifelongstudent.io/2014/06/learn-git-part-1-introduction/), so if you haven't read it, go and read it first. We based on the things we learned and do there, so make sure you don't delete the repo we created in the part 1.

&nbsp;
Expand Down Expand Up @@ -166,7 +167,7 @@ To github.com:nirgn975/test.git

If we refresh the GitHub repo page we'll see the `README` file there, and a new _"Network"_ button (at the right menu, next to the _"Settings"_) where we can see all the `branch`s and all the `commit`s, with their messages, who're their author, when they `commit`ed, and more (basically like writing the `log` command on our terminal).

So, we `push`ed our repo to a `remote` source on GitHub (or any other `git` hosting), but how can Bob take this code to his local machine? Like we said before, with the `pull` command (we'll also use the `pull` command to sync our local repo with the `remote` one, so get changes other team members did and `push`).
So, we `push`ed our repo to a `remote` source on GitHub (or any other `git` hosting), but how can Bob take this code to his local machine? Like we said before, with the `pull` command (we'll also use the `pull` command to sync our local repo with the `remote` one, so get changes other team members did and `push`).

```bash
$ git pull origin master
Expand Down Expand Up @@ -269,6 +270,7 @@ Now let's create a new `branch` to work on a new task, the branch will be called
$ git checkout -b basic-main
Switched to a new branch 'basic-main'
```

Then we'll add the `<a href="detailed.html">Go to detailed page!</a>` line right after `content of website ..`.

```html
Expand Down Expand Up @@ -305,12 +307,12 @@ gitGraph:
options
{ "nodeSpacing": 100, "nodeRadius": 10 }
end
commit
commit
branch basicmain
checkout basicmain
commit
commit
commit
commit
branch basicmain
checkout basicmain
commit
commit
{{< /mermaid >}}

Right in the middle of our work on the `basic-main` branch, we get an email from our boss that there are bugs in `master` and we need to take care of it immediately. So let's head over to `master` (you can run `git branch` after you `checkout` to `master` just to make sure you're on `master`).
Expand Down Expand Up @@ -372,18 +374,18 @@ gitGraph:
options
{ "nodeSpacing": 100, "nodeRadius": 10 }
end
commit
commit
branch basicmain
checkout basicmain
commit
commit
checkout master
commit
checkout basicmain
commit
checkout master
merge basicmain
commit
commit
branch basicmain
checkout basicmain
commit
commit
checkout master
commit
checkout basicmain
commit
checkout master
merge basicmain
{{< /mermaid >}}

&nbsp;
Expand Down Expand Up @@ -419,7 +421,7 @@ It's time to practice. Remember that the best practice is through your fingertip
8. Use the `remote add` command like so: `git remote add origin https://github.com/example/importantProject.git`.
9. You need the `push` command with the `-u` flag: `git push -u origin master`.
10. Use the `clone` command like so: `git clone https://github.com/nirgn975/test.git`.
11. Use the `checkout` command with the `b` flag, like so: `git checkout -b fix457`.
11. Use the `checkout` command with the `b` flag, like so: `git checkout -b fix457`.
12. `git merge fix457`.

&nbsp;
Expand All @@ -428,6 +430,6 @@ It's time to practice. Remember that the best practice is through your fingertip

We now know how to see the changes that were made from the last `commit`, how to go back if we regret something we did in a `commit` or the commit message, or even forget to add something to the `commit`.

We upload the project to a remote repository (GitHub in this case), we created new branches, worked with other team members, and merge our code to the `master` branch (we go over a `merge` with no changes in `master` and with one **with** changes in `master`, but not in the same file - we'll talk about it in future chapter).
We upload the project to a remote repository (GitHub in this case), we created new branches, worked with other team members, and merge our code to the `master` branch (we go over a `merge` with no changes in `master` and with one **with** changes in `master`, but not in the same file - we'll talk about it in future chapter).

We definitely learned a lot in this chapter! Don't forget to practice it through your fingers, it's the best way to learn something new. And don't hesitate to ask questions in the comments if something is not clear - I'll do my best to help.
11 changes: 7 additions & 4 deletions content/posts/2014/learn-git-part-3-introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: "Learn Git - Part 3: introduction"
subtitle: ""
date: 2014-08-03T09:00:00+03:00
lastmod: 2014-08-03T09:00:00+03:00
draft: false
draft: true
author: "Nir Galon"
authorLink: "https://nir.galon.io"
description: ""
Expand All @@ -24,6 +24,7 @@ math:
lightgallery: true
license: ""
---

I think everybody here at least heard about [GitHub](https://github.com) and maybe even about the file management system called [git](https://git-scm.com) which is everywhere in the development world those days. So, as a computer science student I choose to learn it, and what batter way to learn something then to write about it.

So in this series of posts I'll document my journey to learn git (which is the base of GitHub as the only version control you can use on the platform). I hope more people can use it as a learning document or even to deepen their knowledge in the tool.
Expand Down Expand Up @@ -105,6 +106,7 @@ nothing added to commit but untracked files present (use "git add" to track)
```

We can see we got couple of pieces of information back:

- We are on branch `master` (we'll take about branches later)
- There is no commits yet in this repo.
- We have a new file (file that `git` doesn't track) in the name of `README.md`
Expand All @@ -126,7 +128,7 @@ Changes to be committed:

We see almost the same pieces of information, but now `git` have a file in his _staging area_ (a file ready to be `commit`ed). So, it's time to do our first `commit`. To do this we'll use the `commit` command. A flag that the `commit` command have is `m` which means _"message"_, with this flag we can add a message to the `commit` to describe the changes this `commit` is do.

When we do the `commit` we basically take a snapshot of our file system in this exact time. Even a space means a change. This commit is added to the repo (project) timeline (it's accepted to draw it and imagine it as a timeline, because every `commit` has a timestamp, so we can place them all on a big timeline from the start of the project until now).
When we do the `commit` we basically take a snapshot of our file system in this exact time. Even a space means a change. This commit is added to the repo (project) timeline (it's accepted to draw it and imagine it as a timeline, because every `commit` has a timestamp, so we can place them all on a big timeline from the start of the project until now).

```bash
$ git commit -m "Created an empty README file"
Expand Down Expand Up @@ -188,6 +190,7 @@ $ git commit -m "Add a new LICENSE file and finish README"
```

To look at the history, the log, of the current timeline we can use the `log` command. We see there're two `commit`s in the branch (timeline) we're currently at. And also much more information:

- We're in the `master` branch (timeline).
- The `commit`s hash, which is a unique string of number and letters to represent that `commit`. It's basically the name of the `commit`, with it we can reference that `commit`.
- The author and the exact time and date of the `commit`.
Expand Down Expand Up @@ -215,8 +218,8 @@ gitGraph:
options
{ "nodeSpacing": 150, "nodeRadius": 10 }
end
commit
commit
commit
commit
{{< /mermaid >}}

&nbsp;
Expand Down
21 changes: 11 additions & 10 deletions content/posts/2017/jekyll-starter-kit-generator-2.1.0-is-out.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ math:
lightgallery: true
license: ""
---

Creating Jekyll progressive web apps has never been easier!

&nbsp;
Expand All @@ -36,16 +37,16 @@ It’ll create for you the default Jekyll website template, with all the best pr

What more cool stuff? Here are couple of examples.

* You can write [pug](https://github.com/pugjs/pug) instead of HTML.
* You can use CSS or SASS or SCSS.
* Automagically minifies HTML, and automagically autoprefixing CSS.
* You can choose to write ES2015 with [babel](https://github.com/babel/babel).
* Concatenate and minify JavaScript.
* Built-in preview and auto update with BrowserSync.
* Automagically generates a service worker for your website for offline support.
* Test the website against [lighthouse](https://github.com/GoogleChrome/lighthouse) and fail Travis-CI if the score is below 80.
* Automagically optimizes image before deploy.
* Deploy the website to gh-pages or firebase with only one command.
- You can write [pug](https://github.com/pugjs/pug) instead of HTML.
- You can use CSS or SASS or SCSS.
- Automagically minifies HTML, and automagically autoprefixing CSS.
- You can choose to write ES2015 with [babel](https://github.com/babel/babel).
- Concatenate and minify JavaScript.
- Built-in preview and auto update with BrowserSync.
- Automagically generates a service worker for your website for offline support.
- Test the website against [lighthouse](https://github.com/GoogleChrome/lighthouse) and fail Travis-CI if the score is below 80.
- Automagically optimizes image before deploy.
- Deploy the website to gh-pages or firebase with only one command.

![The generator in action](/posts/2017/jekyll-starter-kit-generator-2.1.0-is-out/the-generator-in-action.webp "The generator in action")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ math:
lightgallery: true
license: ""
---

A tutorial for a real world docker use case.

Recently I read a lot of articles about load balancing applications with Docker, Docker Compose, and Docker Swarm for my work. We have a couple of hundreds of instances and we need to manage them and do load balancing between them.
Expand All @@ -43,12 +44,14 @@ For that reason I decided to write this post and present the way we use. It’s
Let’s start by creating our simple Node.js application. Create a file named `index.js` with the following code:

```javascript
var http = require('http');
var os = require('os');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/html'});
var http = require("http");
var os = require("os");
http
.createServer(function (req, res) {
res.writeHead(200, { "Content-Type": "text/html" });
res.end(`<h1>I'm ${os.hostname()}</h1>`);
}).listen(8080);
})
.listen(8080);
```

Now we need to dockerize the app, so we’ll create a file named `Dockerfile` with the following code:
Expand All @@ -72,26 +75,26 @@ Now we have a docker image of our simple (and awesome) Node.js app, and we can c
For our HTTP server we’ll use HAProxy, that means we need to create a container with HAProxy that will listen to port 80 and load balance the requests to the different Node.js containers on port 8080. To create our containers (Node.js apps and HAProxy) we’ll use Docker Compose, let’s write our `docker-compose.yml` file:

```yaml
version: '3'
version: "3"

services:
awesome:
image: awesome
ports:
- 8080
environment:
- SERVICE_PORTS=8080
deploy:
replicas: 20
update_config:
parallelism: 5
delay: 10s
restart_policy:
condition: on-failure
max_attempts: 3
window: 120s
networks:
- web
image: awesome
ports:
- 8080
environment:
- SERVICE_PORTS=8080
deploy:
replicas: 20
update_config:
parallelism: 5
delay: 10s
restart_policy:
condition: on-failure
max_attempts: 3
window: 120s
networks:
- web

proxy:
image: dockercloud/haproxy
Expand Down Expand Up @@ -145,12 +148,14 @@ Now let’s look at our services by writing `docker service ls` and we’ll see
We can also create a second version of our `awesome` app. Let’s change the code a little bit (let’s add some exclamation marks at the end):

```javascript
var http = require('http');
var os = require('os');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/html'});
var http = require("http");
var os = require("os");
http
.createServer(function (req, res) {
res.writeHead(200, { "Content-Type": "text/html" });
res.end(`<h1>I'm ${os.hostname()}!!!</h1>`);
}).listen(8080);
})
.listen(8080);
```

So we need to build the image again, but this time it’s the second version of the app so we’ll write `docker build -t awesome:v2 .` and we’ll create an image called `awesome` but with a `v2` tag. To update our containers in the `awesome` service to use the `v2` version of our app (without stop the service) we’ll write `docker service update --image awesome:v2 prod_awesome` and our service called `awesome`, in `prod` stack, will update it’s containers five by five to use the second version of our app (why 5 containers at a time? because we wrote `parallelism: 5` in our `docker-compose.yml` file.
Expand Down
2 changes: 1 addition & 1 deletion content/posts/2020/chapter-1-simple-twitter.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ That's it, now if you'll write `git` on your command line of choice you'll get a

### 1.2. Open a GitHub account

GitHub is a web based git with some extra features. We don't need to install anything to use GitHub, just open an account and configure some stuff. So let's do it! Let's go to https://github.com and pick a `username`, `email`, and `password` and click on the big green button says *Sign up for GitHub*.
GitHub is a web based git with some extra features. We don't need to install anything to use GitHub, just open an account and configure some stuff. So let's do it! Let's go to https://github.com and pick a `username`, `email`, and `password` and click on the big green button says _Sign up for GitHub_.

![GitHub Sign Up Page](/posts/2020/chapter-1-simple-twitter/github_sign_up_page.webp "GitHub Sign Up Page")

Expand Down
Loading

0 comments on commit 52cbec3

Please sign in to comment.