Skip to content

Instantly share code, notes, and snippets.

<?php
// doctrine-cli.php
//
// Place into Laravel Root directory
// Run: php doctrine-cli.php config:show
// And save output to {laravel_root}/config/doctrine.php
//
// https://gist.github.com/Negasus
@negasus
negasus / golog.go
Last active June 8, 2018 15:28
Setup log for golfing application
var opts struct {
Addr string `long:"addr" env:"ADDR" default:":3000" description:"listen address"`
Dbg bool `long:"debug" env:"DEBUG" description:"debug mode"`
}
func main() {
p := flags.NewParser(&opts, flags.Default)
if _, e := p.ParseArgs(os.Args[1:]); e != nil {
os.Exit(1)
@negasus
negasus / q1.go
Last active November 15, 2018 13:01
// Просьба добавить доводы по поводу использования первого либо второго варианта
// #1
for {
if a1 !== b1 {
// .. some code 1
continue
}
if a2 !== b2 {
// .. some code 2
@negasus
negasus / main.go
Created December 6, 2018 15:30
GO graceful shutdown
var gracefulStop = make(chan os.Signal)
signal.Notify(gracefulStop, syscall.SIGTERM)
signal.Notify(gracefulStop, syscall.SIGINT)
go func() {
sig := <-gracefulStop
fmt.Printf("caught sig: %+v", sig)
fmt.Println("Wait for 2 second to finish processing")
time.Sleep(2 * time.Second)
@negasus
negasus / app.lua
Created December 14, 2018 06:50
Script for tarantool 1.10.2-60 and above for get error XlogError: tx checksum mismatch
require('strict').on()
local fio = require('fio')
local instanceName = fio.basename(arg[0], '.lua')
local log = require('log')
local instancesData = {
['test_1'] = {port = 3301, read_only = false},
['test_2'] = {port = 3302, read_only = true},
['test_3'] = {port = 3303, read_only = true},
@negasus
negasus / token_validate.lua
Last active March 31, 2019 16:27
token_validate.lua for traefik v2 middleware 'lua script'. See https://youtu.be/C2umw-3SplM
-- get token from query argument 'token'
-- or from HTTP header 'Authorization' and check length
-- API for interaction with HTTP Request and Response
local http = require("http")
-- API for send log messages
local log = require("log")
local tokenQueryArgument = 'token'
local tokenHTTPHeader = 'Authorization'
@negasus
negasus / config.toml
Created March 31, 2019 16:36
Traefik v2 config file for middleware 'lua script'. See https://youtu.be/C2umw-3SplM
[providers]
[providers.file]
[http.routers]
[http.routers.router1]
Service = "service1"
Middlewares = ["token-validate-lua"]
Rule = "Host(`localhost`)"
[http.middlewares]
@negasus
negasus / storage_instance.lua
Created May 28, 2019 15:51
Tarantool vshard storage isntance file with Reload functions
require('strict').on()
local log = require('log')
vshard = require('vshard')
local cfg = {
listen = '{{ ip }}:{{ item.port }}',
net_msg_max = 10000,
readahead = 1 * 1024 * 1024,
@negasus
negasus / files.lua
Created June 4, 2019 11:40
Tarantool Vshard
-------------------
s_1.lua
-------------------
require('strict').on()
vshard = require('vshard')
local storage_uuid = 'b271d109-7f1f-4db5-9f0f-625abf9050ca'
local cfg = {
FROM tarantool/tarantool:2.x-centos7
ENV TARANTOOL_INSTANCE_NAME=default
RUN yum -y update
RUN yum install -y sudo
RUN sudo curl -L https://tarantool.io/installer.sh | sudo -E bash -s -- --repo-only
RUN yum install -y cartridge-cli
RUN yum install -y cmake make gcc unzip git