• 微信公众号:美女很有趣。 工作之余,放松一下,关注即送10G+美女照片!

Digest | 算法:幂集, 一个startup架构

互联网 diligentman 2周前 (04-09) 9次浏览

2021年04月08日信息消化

原发布地址:Digest | 算法:幂集, 一个startup架构

每天学点算法

幂集 | 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. 

每天学点Golang

使用GORM和GIN在Golang中实现简单分页功能

原文: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

目录结构

- /first-api
	- /Config
  - /Controllers
  - /Model
  - /Routes
  - go.mod
  - go.sum
  - main.go

核心分页部分。

  • config.go: DB实例

  • 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)
	if result.Error != nil {
		msg := result.Error
		return nil, msg
	}
	return &users, nil
}

其他值得阅读

一个startup架构概览

原文:Architecture for a startup

<img src=”https://raw.githubusercontent.com/Phalacrocorax/memo-image-host/master/uPic/1*E5y8hDXoZ23Ll_FQkH4g0Q.png” alt=”img” style=”zoom: 50%;” />

  • 静态前台(Static web app):
    • S3 + CloudFront CDN + Route53
  • 后台(Backend production system)
    • EC2(auto-scaling group)+ AWS ElasticCache + MySQL (RDS) + ALB + Cognito
  • 分析(Analytics 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.

我的妈妈在用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

大规模Vue.js应用的4个最佳实践

原文:4 Best Practices for Large Scale Vue.js Projects

  • Use Vue Slots

  • F.I.R.S.T principle: Build & share independent components

    • Bit
  • well organized VUEX Store

    └── store
        ├── index.js          
        ├── actions.js
        ├── mutations.js
        └── modules
    
  • Unit Tests

    • Jest, Karma, or Mocha

一点收获

  • 人生是一场没有赛道的长跑。持续比强度重要。
  • GPT-3 learning corpus consists of the common-craw dataset. The dataset includes 45TB of textual data or most of the internet. 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

展开阅读全文

gopaginationgingithubgormvue.jsjavascriptarch linux

© 著作权归作者所有

举报

打赏

0


0 收藏

微信
QQ
微博

分享

作者的其它热门文章

常用dns收集,拯救网速慢会死症候
AI多种设计字体的方法与英文字体收藏
Laravel学习
[three.js]学习笔记


程序员灯塔
转载请注明原文链接:Digest | 算法:幂集, 一个startup架构
喜欢 (0)