Skip to content

Instantly share code, notes, and snippets.

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 / 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); });
});
}
@gocs
gocs / .dockerignore
Created April 20, 2023 07:09
.dockerignore template
.git/
@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 / 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 / .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 / center.html
Created April 28, 2023 02:21
centering div inside div in tailwind
<div class="grid items-center justify-center">
<div>centered</div>
</div>
@gocs
gocs / .md
Last active August 20, 2023 03:05
angular tailwind template (angular 15)

Angular Tailwind Template

this should work for angular version 12 above

this template will automate the creation process of angular and tailwind as manually instructed here: https://tailwindcss.com/docs/guides/angular

create angular app

@gocs
gocs / .sh
Created May 17, 2023 08:37
basic vite
# fuck you starter pack ICANT ALERT
npm create vite
npm i
npm install -D tailwindcss postcss autoprefixer
npx tailwindcss init -p
npm i jquery
npm i --save-dev @types/jquery
@gocs
gocs / responsive.html
Created May 21, 2023 09:47
responsive svg
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.1/normalize.min.css"