Skip to content

Instantly share code, notes, and snippets.

View iraniamir's full-sized avatar
💪
Let's Dance

Amir Irani iraniamir

💪
Let's Dance
  • Internet
View GitHub Profile
@ykyuen
ykyuen / main.go
Created November 19, 2018 06:19
setup-nested-html-template-in-go-echo-web-framework-05
package main
import (
"html/template"
"io"
"github.com/labstack/echo"
"gitlab.com/ykyuen/golang-echo-template-example/handler"
)
thread goroutine
OS threads are managed by kernal and has hardware dependencies. goroutines are managed by go runtime and has no hardware dependencies.
OS threads generally have fixed stack size of 1-2MB goroutines typically have 8KB (2KB since Go 1.4) of stack size in newer versions of go
Stack size is determined during compile time and can not grow Stack size of go is managed in run-time and can grow up to 1GB which is possible by allocating and freeing heap storage
There is no easy communication medium between threads. There is huge latency between inter-thread communication. goroutine use channels to communicate with other goroutines with low latency (read more).
Threads have identity. There is TID which identifies each thread in a process. goroutine do not have any identity. go implemented this because go does not have TLS([Thread Local Storage](https://msdn.microsoft.com/en-us/library/win
package grpc
import (
"context"
"log"
"net"
"os"
"os/signal"
"google.golang.org/grpc"
@ArVan
ArVan / Form.css
Last active October 28, 2018 09:53
A React component with custom HTML5 validation error layouts
.was-validated .form-control:valid~.invalid-feedback {
display: none;
}
@iraniamir
iraniamir / preview-form.jsx
Created January 28, 2018 08:31
Mithril Bootstrap Forms
import m from "mithril";
module.exports = (options, ...elements) => {
return (
<form {...options.attrs} class="form needs-validation">
{
elements.map(e => {

Various command line applications use an Interpreter Directive to define how they should be run.

#! js -m foo
#! node foo
@fearblackcat
fearblackcat / proxy_for_terminal.md
Last active April 13, 2024 18:53
Set proxy for terminal on mac

Shadowsocks Proxy

apt-get install python-pip
pip install shadowsocks

sudo ssserver -p 443 -k password -m aes-256-cfb --user nobody -d start
@PurpleBooth
PurpleBooth / Dockerfile
Last active March 21, 2024 09:33
Create a static binary in go and put it in a from scratch docker container
FROM golang:1.9
WORKDIR /go/src/github.com/purplebooth/example
COPY . .
RUN go build -ldflags "-linkmode external -extldflags -static" -a main.go
FROM scratch
COPY --from=0 /go/src/github.com/purplebooth/example/main /main
CMD ["/main"]
@asukakenji
asukakenji / 0-go-os-arch.md
Last active April 24, 2024 06:51
Go (Golang) GOOS and GOARCH

Go (Golang) GOOS and GOARCH

All of the following information is based on go version go1.17.1 darwin/amd64.

GOOS Values

GOOS Out of the Box
aix
android
@rambabusaravanan
rambabusaravanan / apache.conf
Last active December 21, 2023 12:01
SPA - Apache, Nginx Configuration for Single Page Application like React.js on a custom path
# To host on root path just use "<Location />" for http://mydomainname.in
# To host on non-root path use "<Location /myreactapp>" for http://mydomainname.in/mypath
# If non-root path, don't forgot to add "homepage": "/myreactapp" in your app's package.json
<VirtualHost *:80>
ServerName mydomainname.in
DirectoryIndex index.html
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined