Skip to content

Instantly share code, notes, and snippets.

Avatar
🐢
I may be slow to respond.

Oleksiy Chechel night-codes

🐢
I may be slow to respond.
View GitHub Profile
@night-codes
night-codes / client.go
Created Jun 29, 2018 — forked from kenshinx/client.go
golang socket server & client ping-pong demo
View client.go
package main
import (
"log"
"net"
"strconv"
"strings"
)
const (
@night-codes
night-codes / check.go
Created Jun 2, 2018 — forked from mattes/check.go
Check if file or directory exists in Golang
View check.go
if _, err := os.Stat("/path/to/whatever"); os.IsNotExist(err) {
// path/to/whatever does not exist
}
if _, err := os.Stat("/path/to/whatever"); err == nil {
// path/to/whatever exists
}
View tokey.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View MacPro system info
System: Host: mint Kernel: 4.8.0-53-generic x86_64 (64 bit gcc: 5.4.0)
Desktop: Cinnamon 3.4.3 (Gtk 3.18.9-1ubuntu3.3) dm: lightdm Distro: Linux Mint 18.2 Sonya
Machine: System: Apple product: MacPro6 1 v: 1.0 Chassis: type: 2 v: Mac-F60DEB81FF30ACF6
Mobo: Apple model: Mac-F60DEB81FF30ACF6 v: MacPro6 1
Bios: Apple v: MP61.88Z.0116.B46.1706200309 date: 06/20/2017
CPU: Multi core Intel Xeon E5-2695 v2 (-HT-MCP-) cache: 30720 KB
flags: (lm nx sse sse2 sse3 sse4_1 sse4_2 ssse3 vmx) bmips: 57594
clock speeds: min/max: 1200/3200 MHz 1: 1626 MHz 2: 1440 MHz 3: 1650 MHz 4: 1304 MHz
5: 1335 MHz 6: 1559 MHz 7: 1264 MHz 8: 1402 MHz 9: 1498 MHz 10: 1319 MHz 11: 1547 MHz
12: 1495 MHz 13: 1269 MHz 14: 2102 MHz 15: 1409 MHz 16: 1669 MHz 17: 1732 MHz 18: 1672 MHz
@night-codes
night-codes / sendMail.go
Created Apr 16, 2017 — forked from andelf/sendMail.go
golang send mail net/smtp SMTP
View sendMail.go
package main
import (
"log"
"net/mail"
"encoding/base64"
"net/smtp"
"fmt"
"strings"
@night-codes
night-codes / multiple_ssh_setting.md
Created Feb 17, 2016 — forked from jexchan/multiple_ssh_setting.md
Multiple SSH keys for different github accounts
View multiple_ssh_setting.md

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "your_email@youremail.com"
@night-codes
night-codes / makeInsert.go
Created Nov 3, 2015
Golang slice insert func generator
View makeInsert.go
package main
import (
"fmt"
"reflect"
)
func makeInsert(fptr interface{}) {
fn := reflect.ValueOf(fptr).Elem()
fn.Set(reflect.MakeFunc(fn.Type(), func(in []reflect.Value) []reflect.Value {
View golangDeploy.md

1) Создаем юзера под которым будет работать приложение, задаем пароль и переключаемся на него:

useradd -s /bin/bash <имя_пользователя>
passwd <имя_пользователя>
su <имя_пользователя>

2) Генерируем новый ключ для деплоя

ssh-keygen -t rsa -C "<имя_пользователя>@<домен_сервиса>"
View sliceinterface.md

Introduction

Given that you can assign a variable of any type to an interface{}, often people will try code like the following.

var dataSlice []int = foo()
var interfaceSlice []interface{} = dataSlice

This gets the error

cannot use dataSlice (type []int) as type []interface { } in assignment
View benchmark+go+nginx.md

Benchmarking Nginx with Go

There are a lot of ways to serve a Go HTTP application. The best choices depend on each use case. Currently nginx looks to be the standard web server for every new project even though there are other great web servers as well. However, how much is the overhead of serving a Go application behind an nginx server? Do we need some nginx features (vhosts, load balancing, cache, etc) or can you serve directly from Go? If you need nginx, what is the fastest connection mechanism? This are the kind of questions I'm intended to answer here. The purpose of this benchmark is not to tell that Go is faster or slower than nginx. That would be stupid.

So, these are the different settings we are going to compare:

  • Go HTTP standalone (as the control group)
  • Nginx proxy to Go HTTP
  • Nginx fastcgi to Go TCP FastCGI
  • Nginx fastcgi to Go Unix Socket FastCGI
You can’t perform that action at this time.