Skip to content

Commit

Permalink
Updated By Github Actions With Build 251 of Build my gitbook and depl…
Browse files Browse the repository at this point in the history
…oy to gh-pages For Github Pages
  • Loading branch information
kimi0230 committed Mar 28, 2024
0 parents commit 0e6bd91
Show file tree
Hide file tree
Showing 500 changed files with 524,480 additions and 0 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Build my gitbook and deploy to gh-pages

on:
workflow_dispatch:
push:
branches:
- master

jobs:
master-to-gh-pages:
runs-on: ubuntu-latest

steps:
- name: checkout master
uses: actions/checkout@v2
with:
submodules: recursive
ref: master

- name: install nodejs
uses: actions/setup-node@v3
with:
node-version: 10.14.1

- name: configue gitbook
run: |
npm install
npm install -g gitbook-cli
gitbook install
npm install -g gitbook-summary
- name: generate _book folder
run: |
book sm
ln -s -f SUMMARY.md Content.md
gitbook build
cp SUMMARY.md _book
- name: push _book to branch gh-pages
env:
TOKEN: ${{ secrets.GH_ACCESS_TOKEN }}
REF: github.com/${{github.repository}}
MYEMAIL: kimi0230@gmail.com
MYNAME: ${{github.repository_owner}}
run: |
cd _book
git config --global user.email "${MYEMAIL}"
git config --global user.name "${MYNAME}"
git init
git remote add origin https://${REF}
git add .
git commit -m "Updated By Github Actions With Build ${{github.run_number}} of ${{github.workflow}} For Github Pages"
git branch -M master
git push --force --quiet "https://${TOKEN}@${REF}" master:gh-pages
75 changes: 75 additions & 0 deletions .github/workflows/releace.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: Build latest tag

on:
workflow_dispatch:
push:
tags:
- "v*.*.*"

jobs:
build:
name: Build
runs-on: macos-latest
steps:
- name: checkout master
uses: actions/checkout@v2
with:
submodules: recursive
ref: master

- name: install nodejs
uses: actions/setup-node@v1

- name: install calibre
run: |
brew install calibre
- name: configue gitbook
run: |
npm install -g gitbook-cli
gitbook install
npm install -g gitbook-summary
- name: generate pdf file
run: |
book sm
ln -s -f SUMMARY.md README.md
gitbook pdf
gitbook epub
gitbook mobi
mkdir -p path/to/artifact
cp book.pdf path/to/artifact
cp book.epub path/to/artifact
cp book.mobi path/to/artifact
- name: Upload file
uses: actions/upload-artifact@v2
with:
name: book.pdf
path: path/to/artifact/book.pdf

- name: Download file
id: download
uses: actions/download-artifact@v2
with:
name: book.pdf
path: path/to/artifact

- name: Display structure of downloaded files
run: ls -R
working-directory: path/to/artifact

- name: 'Echo download path'
run: echo ${{steps.download.outputs.download-path}}

- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
path/to/artifact/book.pdf
path/to/artifact/book.epub
path/to/artifact/book.mobi
LICENSE
env:
GITHUB_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
_book
node_modules
.obsidian/*
Empty file added .gitmodules
Empty file.
15 changes: 15 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch Package",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${fileDirname}"
}
]
}
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"vue.features.codeActions.enable": false
}
80 changes: 80 additions & 0 deletions Algorithms/A1B2C3/a1b2c3.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package a1b2c3

import (
"sync"
)

func ChannelWBuffer() {
abc := make(chan struct{}, 1)
num := make(chan struct{}, 1)
done := make(chan struct{})
abc <- struct{}{}

go func() {
for i := 65; i <= 90; i++ {
<-abc
// fmt.Printf("%v", string(rune(i)))
num <- struct{}{}
}
}()
go func() {
for i := 1; i <= 26; i++ {
<-num
// fmt.Printf("%v", i)
abc <- struct{}{}
}
done <- struct{}{}
}()
// time.Sleep(1 * time.Second)
<-done
}

func ChannelWOBuffer() {
abc := make(chan struct{})
num := make(chan struct{})
done := make(chan struct{})

go func() {
for i := 65; i <= 90; i++ {
// fmt.Printf("%v", string(rune(i)))
abc <- struct{}{}
<-num
}
}()
go func() {
for i := 1; i <= 26; i++ {
<-abc
// fmt.Printf("%v", i)
num <- struct{}{}
}
done <- struct{}{}
}()
// time.Sleep(1 * time.Second)
<-done
}

func WGLock() {
abcMux := sync.Mutex{}
numMux := sync.Mutex{}

numMux.Lock()
wg := sync.WaitGroup{}
wg.Add(2)
go func() {
defer wg.Done()
for i := 65; i <= 90; i++ {
abcMux.Lock()
// fmt.Printf("%v", string(rune(i)))
numMux.Unlock()
}
}()
go func() {
defer wg.Done()
for i := 1; i <= 26; i++ {
numMux.Lock()
// fmt.Printf("%v", i)
abcMux.Unlock()
}
}()
wg.Wait()
}
48 changes: 48 additions & 0 deletions Algorithms/A1B2C3/a1b2c3_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package a1b2c3

import "testing"

func TestChannelWBuffer(t *testing.T) {
ChannelWBuffer()
}

func TestChannelWOBuffer(t *testing.T) {
ChannelWOBuffer()
}
func TestWGLock(t *testing.T) {
WGLock()
}

func BenchmarkChannelWBuffer(b *testing.B) {
b.ResetTimer()
for i := 0; i < b.N; i++ {
ChannelWBuffer()
}
}

func BenchmarkChannelWOBuffer(b *testing.B) {
b.ResetTimer()
for i := 0; i < b.N; i++ {
ChannelWOBuffer()
}
}

func BenchmarkWGLock(b *testing.B) {
b.ResetTimer()
for i := 0; i < b.N; i++ {
WGLock()
}
}

// go test -benchmem -run=none LeetcodeGolang/Algorithms/A1B2C3 -bench=.
/*
goos: darwin
goarch: amd64
pkg: LeetcodeGolang/Algorithms/A1B2C3
cpu: Intel(R) Core(TM) i5-6400 CPU @ 2.70GHz
BenchmarkChannelWBuffer-4 79159 14612 ns/op 344 B/op 5 allocs/op
BenchmarkChannelWOBuffer-4 83068 14451 ns/op 344 B/op 5 allocs/op
BenchmarkWGLock-4 51303 23072 ns/op 96 B/op 5 allocs/op
PASS
ok LeetcodeGolang/Algorithms/A1B2C3 4.092s
*/
Loading

0 comments on commit 0e6bd91

Please sign in to comment.