Skip to content

Instantly share code, notes, and snippets.

@gocs
gocs / goroutine.go
Last active April 8, 2019 13:39
goroutine lifecycle
package main
import (
"fmt"
"time"
)
func sync() {
time.Sleep(time.Second / 2)
fmt.Println("1")
@gocs
gocs / goroutine.go
Created April 8, 2019 14:19
goroutine with channels life cycle
package main
import "fmt"
func do_stuff(done chan bool) {
fmt.Println("2")
done <- true
fmt.Println("3")
}
@gocs
gocs / goroutine.go
Created April 8, 2019 14:44
goroutine that counts while sleeping
package main
import (
"fmt"
"time"
)
func count(quit chan bool) {
count := 0
for {
@gocs
gocs / ~\.omnisharp\omnisharp.json
Last active December 20, 2019 15:27
vscode omnisharp inside whole pc userspace k and r braces
{
"FormattingOptions": {
"NewLinesForBracesInLambdaExpressionBody": false,
"NewLinesForBracesInAnonymousMethods": false,
"NewLinesForBracesInAnonymousTypes": false,
"NewLinesForBracesInControlBlocks": false,
"NewLinesForBracesInTypes": false,
"NewLinesForBracesInMethods": false,
"NewLinesForBracesInProperties": false,
"NewLinesForBracesInAccessors": false,
@gocs
gocs / hugo.sh
Created April 18, 2020 14:34
hugo new site in current folder/directory or without making a folder inside the repo
#!/usr/bin/env bash
hugo new site quickstart && mv ./quickstart/* . && rm -rf ./quickstart
@gocs
gocs / go-contracts-proposal-thingy.go
Created May 1, 2020 19:08
go contracts proposal thingy
// Copyright 2020 github.com/gocs
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
@gocs
gocs / jsfrick.js
Last active May 2, 2020 13:54
javascript's available alphabets without using alphabets
// javascript available alphabets got without using alphabets
// one of the limitiations are some uppercase layers
// which could only be solved if I have uppercase `C`
/******************************************************************************
* below are some strings generated by some identities
*
* true
* false
package main
import (
"fmt"
)
func main() {
js := []Job{
{pno: 1, prio: 2, at: 0, bt: 4},
{pno: 2, prio: 4, at: 1, bt: 2},
@gocs
gocs / http.go
Created January 17, 2021 10:32
http: superfluous response.WriteHeader call from
func Error(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusBadRequest)
// w.Write's order must be written after you set the w.Writeheader
w.Write([]byte("error message"))
}
@gocs
gocs / docker-compose.yml
Created June 18, 2021 09:42
adminer docker with custom css
version: '3.3'
services:
adminer:
image: adminer
restart: always
ports:
- 8080:8080
volumes:
- type: bind