Skip to content

Commit 4dc66a0

Browse files
committed
Updated By Github Actions With Build 265 of Build my gitbook and deploy to gh-pages For Github Pages
0 parents  commit 4dc66a0

File tree

521 files changed

+555509
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

521 files changed

+555509
-0
lines changed

.github/workflows/build.yml

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Build my gitbook and deploy to gh-pages
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- master
8+
9+
jobs:
10+
master-to-gh-pages:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: checkout master
15+
uses: actions/checkout@v2
16+
with:
17+
submodules: recursive
18+
ref: master
19+
20+
- name: install nodejs
21+
uses: actions/setup-node@v3
22+
with:
23+
node-version: 10.14.1
24+
25+
- name: configue gitbook
26+
run: |
27+
npm install
28+
npm install -g gitbook-cli
29+
gitbook install
30+
npm install -g gitbook-summary
31+
32+
- name: generate _book folder
33+
run: |
34+
book sm
35+
ln -s -f SUMMARY.md Content.md
36+
gitbook build
37+
cp SUMMARY.md _book
38+
39+
- name: push _book to branch gh-pages
40+
env:
41+
TOKEN: ${{ secrets.GH_ACCESS_TOKEN }}
42+
REF: github.com/${{github.repository}}
43+
44+
MYNAME: ${{github.repository_owner}}
45+
run: |
46+
cd _book
47+
git config --global user.email "${MYEMAIL}"
48+
git config --global user.name "${MYNAME}"
49+
git init
50+
git remote add origin https://${REF}
51+
git add .
52+
git commit -m "Updated By Github Actions With Build ${{github.run_number}} of ${{github.workflow}} For Github Pages"
53+
git branch -M master
54+
git push --force --quiet "https://${TOKEN}@${REF}" master:gh-pages

.github/workflows/releace.yml

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: Build latest tag
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
tags:
7+
- "v*.*.*"
8+
9+
jobs:
10+
build:
11+
name: Build
12+
runs-on: macos-latest
13+
steps:
14+
- name: checkout master
15+
uses: actions/checkout@v2
16+
with:
17+
submodules: recursive
18+
ref: master
19+
20+
- name: install nodejs
21+
uses: actions/setup-node@v1
22+
23+
- name: install calibre
24+
run: |
25+
brew install calibre
26+
27+
- name: configue gitbook
28+
run: |
29+
npm install -g gitbook-cli
30+
gitbook install
31+
npm install -g gitbook-summary
32+
33+
- name: generate pdf file
34+
run: |
35+
book sm
36+
ln -s -f SUMMARY.md README.md
37+
gitbook pdf
38+
gitbook epub
39+
gitbook mobi
40+
mkdir -p path/to/artifact
41+
cp book.pdf path/to/artifact
42+
cp book.epub path/to/artifact
43+
cp book.mobi path/to/artifact
44+
45+
- name: Upload file
46+
uses: actions/upload-artifact@v2
47+
with:
48+
name: book.pdf
49+
path: path/to/artifact/book.pdf
50+
51+
- name: Download file
52+
id: download
53+
uses: actions/download-artifact@v2
54+
with:
55+
name: book.pdf
56+
path: path/to/artifact
57+
58+
- name: Display structure of downloaded files
59+
run: ls -R
60+
working-directory: path/to/artifact
61+
62+
- name: 'Echo download path'
63+
run: echo ${{steps.download.outputs.download-path}}
64+
65+
- name: Release
66+
uses: softprops/action-gh-release@v1
67+
if: startsWith(github.ref, 'refs/tags/')
68+
with:
69+
files: |
70+
path/to/artifact/book.pdf
71+
path/to/artifact/book.epub
72+
path/to/artifact/book.mobi
73+
LICENSE
74+
env:
75+
GITHUB_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }}

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
_book
2+
node_modules
3+
.obsidian/*

.gitmodules

Whitespace-only changes.

.vscode/launch.json

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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+
"name": "Launch Package",
9+
"type": "go",
10+
"request": "launch",
11+
"mode": "auto",
12+
"program": "${fileDirname}"
13+
}
14+
]
15+
}

.vscode/settings.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"vue.features.codeActions.enable": false
3+
}

Algorithms/A1B2C3/a1b2c3.go

+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
package a1b2c3
2+
3+
import (
4+
"sync"
5+
)
6+
7+
func ChannelWBuffer() {
8+
abc := make(chan struct{}, 1)
9+
num := make(chan struct{}, 1)
10+
done := make(chan struct{})
11+
abc <- struct{}{}
12+
13+
go func() {
14+
for i := 65; i <= 90; i++ {
15+
<-abc
16+
// fmt.Printf("%v", string(rune(i)))
17+
num <- struct{}{}
18+
}
19+
}()
20+
go func() {
21+
for i := 1; i <= 26; i++ {
22+
<-num
23+
// fmt.Printf("%v", i)
24+
abc <- struct{}{}
25+
}
26+
done <- struct{}{}
27+
}()
28+
// time.Sleep(1 * time.Second)
29+
<-done
30+
}
31+
32+
func ChannelWOBuffer() {
33+
abc := make(chan struct{})
34+
num := make(chan struct{})
35+
done := make(chan struct{})
36+
37+
go func() {
38+
for i := 65; i <= 90; i++ {
39+
// fmt.Printf("%v", string(rune(i)))
40+
abc <- struct{}{}
41+
<-num
42+
}
43+
}()
44+
go func() {
45+
for i := 1; i <= 26; i++ {
46+
<-abc
47+
// fmt.Printf("%v", i)
48+
num <- struct{}{}
49+
}
50+
done <- struct{}{}
51+
}()
52+
// time.Sleep(1 * time.Second)
53+
<-done
54+
}
55+
56+
func WGLock() {
57+
abcMux := sync.Mutex{}
58+
numMux := sync.Mutex{}
59+
60+
numMux.Lock()
61+
wg := sync.WaitGroup{}
62+
wg.Add(2)
63+
go func() {
64+
defer wg.Done()
65+
for i := 65; i <= 90; i++ {
66+
abcMux.Lock()
67+
// fmt.Printf("%v", string(rune(i)))
68+
numMux.Unlock()
69+
}
70+
}()
71+
go func() {
72+
defer wg.Done()
73+
for i := 1; i <= 26; i++ {
74+
numMux.Lock()
75+
// fmt.Printf("%v", i)
76+
abcMux.Unlock()
77+
}
78+
}()
79+
wg.Wait()
80+
}

Algorithms/A1B2C3/a1b2c3_test.go

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package a1b2c3
2+
3+
import "testing"
4+
5+
func TestChannelWBuffer(t *testing.T) {
6+
ChannelWBuffer()
7+
}
8+
9+
func TestChannelWOBuffer(t *testing.T) {
10+
ChannelWOBuffer()
11+
}
12+
func TestWGLock(t *testing.T) {
13+
WGLock()
14+
}
15+
16+
func BenchmarkChannelWBuffer(b *testing.B) {
17+
b.ResetTimer()
18+
for i := 0; i < b.N; i++ {
19+
ChannelWBuffer()
20+
}
21+
}
22+
23+
func BenchmarkChannelWOBuffer(b *testing.B) {
24+
b.ResetTimer()
25+
for i := 0; i < b.N; i++ {
26+
ChannelWOBuffer()
27+
}
28+
}
29+
30+
func BenchmarkWGLock(b *testing.B) {
31+
b.ResetTimer()
32+
for i := 0; i < b.N; i++ {
33+
WGLock()
34+
}
35+
}
36+
37+
// go test -benchmem -run=none LeetcodeGolang/Algorithms/A1B2C3 -bench=.
38+
/*
39+
goos: darwin
40+
goarch: amd64
41+
pkg: LeetcodeGolang/Algorithms/A1B2C3
42+
cpu: Intel(R) Core(TM) i5-6400 CPU @ 2.70GHz
43+
BenchmarkChannelWBuffer-4 79159 14612 ns/op 344 B/op 5 allocs/op
44+
BenchmarkChannelWOBuffer-4 83068 14451 ns/op 344 B/op 5 allocs/op
45+
BenchmarkWGLock-4 51303 23072 ns/op 96 B/op 5 allocs/op
46+
PASS
47+
ok LeetcodeGolang/Algorithms/A1B2C3 4.092s
48+
*/

0 commit comments

Comments
 (0)