Skip to content

Instantly share code, notes, and snippets.

@gocs
gocs / .md
Last active April 26, 2023 07:31
loop over font styles and its font weights in faces

loop over font styles and its font weights in faces

make sure ./assets/static exists:

for angular, its should be located in ./src/assets/static

@gocs
gocs / form-control.html
Last active April 26, 2023 03:20
input with label full width tailwind
<label for="serial-no" class="flex">
<span>serial no</span>
<div class="flex-1"><input id="serial-no" class="w-full h-full" placeholder="serial-no"></div>
</label>
@gocs
gocs / middleware.go
Last active April 22, 2023 03:31
basic net/http compatible middleware
func main() {
r := chi.Router()
r.Use(Basic())
r.Use(Static("/static", "server2/static"))
http.ListenAndServe(":3000", r)
}
type Middleware func(next http.Handler) http.Handler
func Basic() Middleware {
@gocs
gocs / .dockerignore
Created April 20, 2023 07:09
.dockerignore template
.git/
@gocs
gocs / read-body.js
Created April 8, 2023 15:40
async readbody of a http request
function readBody(req) {
return new Promise((resolve, reject) => {
let body = "";
req.on("data", (chunk) => { body += "" + chunk; });
req.on("end", () => { resolve(body); });
req.on("error", (err) => { reject(err); });
});
}
import sys
class BinTree():
def __init__(self, value):
self.__value = value
self.__left = None
self.__right = None
def value(self):
return self.__value
@gocs
gocs / .sh
Created April 1, 2023 08:52
get host automatically
ng serve --host $(hostname -I | cut -f1 -d' ')
@gocs
gocs / .sh
Last active May 25, 2023 07:23
create angular app
# basic
npx -p @angular/cli ng new myappshop
# create angular app in the current directory especially when the current folder is already a git repo
npx -p @angular/cli ng new $(basename "$PWD") --directory=./ --skip-git
# with scss and defaults
npx -p @angular/cli ng new $(basename "$PWD") --directory=./ --skip-git --style=scss --defaults
# with version 16
@gocs
gocs / .sh
Created March 24, 2023 06:56
new golang mod for open source
go mod init $(git remote -v | head -n 1 | sed -E 's/.*:([^\.]+)\..*/\1/' | awk '{print "github.com/"$1}')
@gocs
gocs / WRONGPASS.md
Last active March 6, 2023 01:34
if you have "WRONGPASS invalid username-password pair" error

one cause is if you have quotes on your .env file

REDIS_PASSWORD="1_secret_password"

remove the quotes

REDIS_PASSWORD=1_secret_password