Skip to content

Instantly share code, notes, and snippets.

View night-codes's full-sized avatar
🇺🇦

Oleksiy Chechel night-codes

🇺🇦
View GitHub Profile
#! /bin/sh
#chkconfig: 345 20 80
#description: node.js server service
PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin:/srv/msrv.su/node/ # modify if you need
DESC="node.js server service"
NAME="node_service"
DAEMON="node"
@night-codes
night-codes / mgoExample.go
Last active September 8, 2015 05:52 — forked from border/mgoExample.go
mgo example
package main
import (
"fmt"
"labix.org/v2/mgo"
"labix.org/v2/mgo/bson"
"time"
)
type Person struct {
@night-codes
night-codes / benchmark+go+nginx.md
Created October 29, 2015 17:35 — forked from hgfischer/benchmark+go+nginx.md
Benchmarking Nginx with Go

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
@night-codes
night-codes / sliceinterface.md
Last active October 30, 2015 06:58
InterfaceSlice

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
@night-codes
night-codes / golangDeploy.md
Last active March 3, 2024 03:55
Golang deploy

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

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

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

ssh-keygen -t rsa -C "<имя_пользователя>@<домен_сервиса>"
@night-codes
night-codes / makeInsert.go
Created November 3, 2015 06:06
Golang slice insert func generator
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 {
@night-codes
night-codes / multiple_ssh_setting.md
Created February 17, 2016 16:07 — forked from jexchan/multiple_ssh_setting.md
Multiple SSH keys for different github accounts

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 / sendMail.go
Created April 16, 2017 05:17 — forked from andelf/sendMail.go
golang send mail net/smtp SMTP
package main
import (
"log"
"net/mail"
"encoding/base64"
"net/smtp"
"fmt"
"strings"
@night-codes
night-codes / MacPro system info
Last active August 30, 2017 15:42 — forked from anonymous/-
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
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.