Skip to content

Instantly share code, notes, and snippets.

View up1's full-sized avatar

Somkiat Puisungnoen up1

View GitHub Profile
@zcaceres
zcaceres / Error-Handling-Patterns-Express.md
Last active August 3, 2023 13:40
error handling patterns in Express

Handling Errors

Express.js makes it a breeze to handle errors in your routes.

Express lets you centralizes your error-handling through middleware.

Let's look at patterns for how to get the most out of your error-handling.

First, our error-handling middleware looks like this:

@robertpainsi
robertpainsi / commit-message-guidelines.md
Last active April 5, 2025 15:33
Commit message guidelines

Commit Message Guidelines

Short (72 chars or less) summary

More detailed explanatory text. Wrap it to 72 characters. The blank
line separating the summary from the body is critical (unless you omit
the body entirely).

Write your commit message in the imperative: "Fix bug" and not "Fixed
bug" or "Fixes bug." This convention matches up with commit messages
@narate
narate / docker_service_report.py
Last active August 12, 2023 08:07
Show all running docker services details for usable Copy and Paste
import docker
import json
def to_mounts_string(mounts):
l = []
for m in mounts:
l.append('Type = {}, Source = {}, Target = {}'
.format(m.get('Type'), m.get('Source'), m.get('Target')))
return json.dumps(l, sort_keys=True, indent=4, ensure_ascii=False)
@deviantony
deviantony / README.md
Last active September 4, 2024 02:41
Portainer HTTP API by example

DEPRECATION NOTICE

This gist is now deprecated in favor of our official documentation: https://documentation.portainer.io/api/api-examples/ which contains up to date examples!

THE FOLLOWING DOCUMENTATION IS DEPRECATED

Please refer to the link above to get access to our updated API documentation and examples.

@Geoff-Ford
Geoff-Ford / composing-software.md
Last active March 14, 2025 20:26
Eric Elliott's Composing Software Series

Eric Elliott's "Composing Software" Series

A collection of links to the excellent "Composing Software" series of medium stories by Eric Elliott.

Edit: I see that each post in the series now has index, previous and next links. However, they don't follow a linear flow through all the articles with some pointing back to previous posts effectively locking you in a loop.

@posener
posener / go-shebang-story.md
Last active March 15, 2025 16:08
Story: Writing Scripts with Go

Story: Writing Scripts with Go

This is a story about how I tried to use Go for scripting. In this story, I’ll discuss the need for a Go script, how we would expect it to behave and the possible implementations; During the discussion I’ll deep dive to scripts, shells, and shebangs. Finally, we’ll discuss solutions that will make Go scripts work.

Why Go is good for scripting?

While python and bash are popular scripting languages, C, C++ and Java are not used for scripts at all, and some languages are somewhere in between.

@enricofoltran
enricofoltran / main.go
Last active April 6, 2025 09:48
A simple golang web server with basic logging, tracing, health check, graceful shutdown and zero dependencies
package main
import (
"context"
"flag"
"fmt"
"log"
"net/http"
"os"
"os/signal"
@dstroot
dstroot / handlers.go
Last active April 10, 2023 13:22 — forked from enricofoltran/main.go
A simple golang web server with basic logging, tracing, health check, graceful shutdown and zero dependencies
package main
import (
"io"
"net/http"
"sync/atomic"
)
func index() http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
@iCyLand
iCyLand / w3c.conf
Last active April 18, 2022 15:25
W3C json log format for nginx
## this GeoIP dat file relate on centos environment please change to your OS path
geoip_country /usr/share/GeoIP/GeoIP-initial.dat;
map $request_uri $request_uri_path {
"~^(?P<path>[^?]*)(\?.*)?$" $path;
}
map $upstream_response_time $new_upstream_response_time {
default $upstream_response_time;
'' null;
@dalegaspi
dalegaspi / spring_boot_zuul_finchley.md
Last active April 8, 2020 09:20
Spring Boot + Zuul Finchley Notes

Preface

Listen, if you want to use Zuul, the easiest path is just use the Spring Boot version. I'm not exactly a fan of Spring in general, but this is the only solution available that's the least painful. Recent release of Spring Cloud Gateway looks promising but I'm satisfied so far with Spring Boot + Zuul that I'm not that interested in evaluating Spring Cloud Gateway,

We are also talking about Zuul 1.x here. Zuul 2.x is a whole can of worms I'd rather not rant about here.

This applies to Finchley (2.x) from SR1 release (may apply to other releases but not guaranteed)

  • Re: using logback. The documentation says it's recommended to use logback-spring.xml in your classpath, but it doesn't work. You should actually use logback.xml or your logging configuration is not recognized at all. While at the subject, it is recommended not to use asynchronous logging at all. U