Skip to content

Instantly share code, notes, and snippets.

View ilyabrin's full-sized avatar
Go, JavaScript

Ilya Brin ilyabrin

Go, JavaScript
View GitHub Profile
@billyfbrain
billyfbrain / graceful_tcp_server.go
Last active December 18, 2022 07:45
golang graceful shutdown tcp listener
cmdAddr, _ := net.ResolveTCPAddr("tcp", n.cfg.Addr)
lcmd, err := net.ListenTCP("tcp", cmdAddr)
if err != nil {
log.Fatalln(err)
}
defer lcmd.Close()
quitChan := make(chan os.Signal, 1)
signal.Notify(quitChan, os.Interrupt, os.Kill, syscall.SIGTERM)
wg := sync.WaitGroup{}
for {
@ilyabrin
ilyabrin / golang.nanorc.sh
Last active November 18, 2022 05:45
Golang for Nano editor (golang.nanorc)
# Syntax highlighting for Golang with nano editor
wget -O /usr/share/nano/go.nanorc http://go-lang.cat-v.org/text-editors/nano/go.nanorc
# Golang for nano editor
echo '## Go'$'\n''include "/usr/share/nano/go.nanorc"' >> /etc/nanorc
@husobee
husobee / validation-main.go
Created January 8, 2016 20:07
input validation sanely
package main
import (
"encoding/json"
"errors"
"net/http"
"github.com/asaskevich/govalidator"
)
@maxim
maxim / gh-dl-release
Last active December 31, 2025 12:22
Download assets from private Github releases
#!/usr/bin/env bash
#
# gh-dl-release! It works!
#
# This script downloads an asset from latest or specific Github release of a
# private repo. Feel free to extract more of the variables into command line
# parameters.
#
# PREREQUISITES
#
@ygotthilf
ygotthilf / jwtRS256.sh
Last active January 26, 2026 13:38
How to generate JWT RS256 key
ssh-keygen -t rsa -b 4096 -m PEM -f jwtRS256.key
# Don't add passphrase
openssl rsa -in jwtRS256.key -pubout -outform PEM -out jwtRS256.key.pub
cat jwtRS256.key
cat jwtRS256.key.pub
@ik5
ik5 / colors.go
Last active January 3, 2025 00:23
Simple golang expirement with ANSI colors
package main
// http://play.golang.org/p/jZ5pa944O1 <- will not display the colors
import "fmt"
const (
InfoColor = "\033[1;34m%s\033[0m"
NoticeColor = "\033[1;36m%s\033[0m"
WarningColor = "\033[1;33m%s\033[0m"
ErrorColor = "\033[1;31m%s\033[0m"
DebugColor = "\033[0;36m%s\033[0m"
@lolzballs
lolzballs / HelloWorld.java
Created March 22, 2015 00:21
Hello World Enterprise Edition
import java.io.FileDescriptor;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
public class HelloWorld{
private static HelloWorld instance;
public static void main(String[] args){
instantiateHelloWorldMainClassAndRun();
@ilyabrin
ilyabrin / reporter.rb
Created March 20, 2015 15:05
Reporter.rb - pattern Strategy
class HTMLFormatter
def output_report(context)
p %Q{
<html>
<head>
<title>#{context.title}</title>
</head>
<body>
}
context.text.each do |line|
@honkskillet
honkskillet / byte-sizetuts.md
Last active August 22, 2024 14:19
A series of golang tutorials with youtube videos.
@jay
jay / PostJSON.c
Last active May 15, 2025 23:22
Use libcurl to POST JSON data.
/* Use libcurl to POST JSON data.
Usage: PostJSON <name> <value>
curl-library mailing list thread:
'how do i post json to a https ?'
https://curl.haxx.se/mail/lib-2015-01/0049.html
* Copyright (C) 2015 Jay Satiro <raysatiro@yahoo.com>
https://curl.haxx.se/docs/copyright.html