Skip to content

Instantly share code, notes, and snippets.

View tuannvm's full-sized avatar
🎯
Focusing

Tommy Nguyen tuannvm

🎯
Focusing
View GitHub Profile
@tuannvm
tuannvm / Makefile
Last active January 10, 2024 14:38 — forked from isaacs/Makefile
#makefile #cheatsheet
# Hello, and welcome to makefile basics.
#
# You will learn why `make` is so great, and why, despite its "weird" syntax,
# it is actually a highly expressive, efficient, and powerful way to build
# programs.
#
# Once you're done here, go to
# http://www.gnu.org/software/make/manual/make.html
# to learn SOOOO much more.
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
creationTimestamp: null
name: test
spec:
replicas: 1
template:
metadata:
creationTimestamp: null

You've launched a revolutionary service not long ago, and were busy improving it for the last couple of months. When you finally decided that the service is perfect, you remembered that you created a feedbacks page long time ago, which you never checked out since then. Now that you have nothing left to do, you would like to have a look at what the community thinks of your service.

Unfortunately it looks like the feedbacks page is far from perfect: each feedback is displayed as a one-line string, and if it's too long there's no way to see what it is about. Naturally, this horrible bug should be fixed. Implement a function that, given a feedback and the size of the screen, splits the feedback into lines so that:

each token (i.e. sequence of non-whitespace characters) belongs to one of the lines entirely; each line is at most size characters long; no line has trailing or leading spaces; each line should have the maximum possible length, assuming that all lines before it were also the longest possible. Example

@tuannvm
tuannvm / 0.12.tf
Last active December 3, 2022 18:50
#terraform #hashicorp #cheatsheet #0.12
#### first class expresssion
variable "ami" {}
resource "aws_instance" "example" {
ami = var.ami
}
#### list & map
resource "aws_instance" "example" {
vpc_security_group_ids = var.security_group_id != "" ? [var.security_group_id] : []
}
@tuannvm
tuannvm / cd.md
Last active October 9, 2022 00:34
#argo #cd #rollout #workflow #event
@tuannvm
tuannvm / python-cheatsheet.md
Last active September 11, 2022 00:05
python cheatsheet! #cheatsheet

Introduction

Set

a = {1, 2, 3}

a.add(1)

{1,2,3}