Information digest
The original release address: Digest | algorithm: power set, a startup architecture
Learn algorithms every day
Power Set | Power Set
The power set of a set is the set of all its subsets. Write a function that, given a set, generates its power set.
The power set of a set is the set of all its subsets. Write a function that, given a set, generates its power set.
For example, given the set {1, 2, 3}
, it should return {{}, {1}, {2}, {3}, {1, 2}, {1, 3}, {2, 3}, {1, 2, 3}}
.
# https://tutorialspoint.dev/algorithm/mathematical-algorithms/power-set
# python3 program for power set
import math;
def printPowerSet(set,set_size) :
# set_size of power set of a set
# with set_size n is (2**n -1)
pow_set_size = (int) (math.pow(2, set_size));
counter = 0;
j = 0;
# Run from counter 000.. 0 to 111.. 1
for counter in range(0, pow_set_size):
for j in range(0, set_size):
# Check if jth bit in the
# counter is set If set then
# print jth element from set
if((counter & (1 << j)) > 0) :print(set[j], end = "");
print("");
# Driver program to test printPowerSet
set = ['a'.'b'.'c'];
printPowerSet(set.3);
# This code is contributed by mits.
Copy the code
Learn Golang every day
Simple paging in Golang using GORM and GIN
原文 : Implement Pagination In Golang Using GORM and GIN
The packages you need to install in our project is:
go get github.com/go-sql-driver/mysql
go get github.com/gin-gonic/gin
go get github.com/jinzhu/gorm
Copy the code
The directory structure
- /first-api
- /Config
- /Controllers
- /Model
- /Routes
- go.mod
- go.sum
- main.go
Copy the code
Core paging section.
-
The config. Go: DB instance
-
repo.go
import (
"first/src/first-api/Config"
models "first/src/first-api/Model"
)
func GetAllUsers(user *models.User, pagination *models.Pagination) (*[]models.User, error) {
var users []models.User
offset := (pagination.Page - 1) * pagination.Limit
queryBuider := Config.DB.Limit(pagination.Limit).Offset(offset).Order(pagination.Sort)
result := queryBuider.Model(&models.User{}).Where(user).Find(&users)
ifresult.Error ! =nil {
msg := result.Error
return nil, msg
}
return &users, nil
}
Copy the code
Others worth reading
A Startup architecture overview
Architecture for a startup
- Static Foreground (Static Web App) :
- S3 + CloudFront CDN + Route53
- Backend Production System
- EC2 (Auto-scaling Group) + AWS ElasticCache + MySQL (RDS) + ALB + Cognito
- Analysis system
- Metabase + ALB + Cognito
- Monitoring
- NewRelic free tier + self-hosted Sentry server
- Deployment
- Jenkins
- Terraform is used for infrastructure as code
- Ansible is used as configuration management.
My mom is using Arch Linux
My Mom Uses Arch Linux
This gist covers the whole step-by-step procedure I followed to get it up and running.
- Desktop Environment: Cinnamon
- Window Manager: Mutter
- File Manager: Nemo
- Video Player: mpv
- Image Viewer: feh
- Browser: Firefox
Four best practices for Large-scale Vue.js applications
译 文 : 4 Best Practices for Large Scale Vue.js Projects
-
Use Vue Slots
-
F.I.R.S. PRINCIPLE: Build & Share independent Components
- Bit
-
well organized VUEX Store
└ ─ ─ store ├ ─ ─ index. Js ├ ─ ─ actions. Js ├ ─ ─ mutations. Js └ ─ ─ modulesCopy the code
-
Unit Tests
- Jest, Karma, or Mocha
A bit in the
- Life is a long run without a track. Persistence is more important than intensity.
- GPT-3 learning corpus consists of the common-craw dataset. The dataset includes 45TB of textual data or most of the Gpt-3 is 175 Billion parameter models as compared to 10 — 100 Trillion parameters in a human brain. — GPT-3 Explained to a 5-year-old