Skip to content

Instantly share code, notes, and snippets.

Musin Vitaly vmpartner

View GitHub Profile
@vmpartner
vmpartner / clean_sessions.sh
Created May 14, 2020
Clean docker php sessions
View clean_sessions.sh
for fn in $(docker ps -aqf "name=php"); do
docker exec $fn /usr/lib/php/sessionclean
done
@vmpartner
vmpartner / main.go
Created Oct 15, 2019
Example how make unkillable golang app
View main.go
package main
import (
"fmt"
"time"
)
var chExit chan struct{}
const TimeSleepRecover = 10
@vmpartner
vmpartner / read-access.sql
Created Aug 5, 2019 — forked from oinopion/read-access.sql
How to create read only user in PostgreSQL
View read-access.sql
-- Create a group
CREATE ROLE readaccess;
-- Grant access to existing tables
GRANT USAGE ON SCHEMA public TO readaccess;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO readaccess;
-- Grant access to future tables
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO readaccess;
@vmpartner
vmpartner / README.md
Created May 30, 2019
Golang check date is empty
View README.md
<p>{{ if not .PriceDate.IsZero }}{{ .PriceDate.Format "02.01.2006 15:04:05" }}{{ end }}</p>
@vmpartner
vmpartner / vpn.sh
Created Mar 15, 2019
Docker OpenVPN
View vpn.sh
OVPN_DATA="ovpn-data" && \
YOUR_IP="8.8.8.8" && \
CLIENTNAME="x1" && \
docker volume create --name $OVPN_DATA && \
docker run -v $OVPN_DATA:/etc/openvpn --log-driver=none --rm kylemanna/openvpn ovpn_genconfig -u udp://$YOUR_IP && \
docker run -v $OVPN_DATA:/etc/openvpn --log-driver=none --rm -it kylemanna/openvpn ovpn_initpki && \
docker run -v $OVPN_DATA:/etc/openvpn -d -p 1194:1194/udp --cap-add=NET_ADMIN kylemanna/openvpn
# Generate a client certificate without a passphrase
# docker run -v $OVPN_DATA:/etc/openvpn --log-driver=none --rm -it kylemanna/openvpn easyrsa build-client-full $CLIENTNAME nopass
View card_section_after_delete_2_tr.sql
CREATE OR REPLACE FUNCTION card_section_after_delete_func()
RETURNS trigger AS
$BODY$
DECLARE
_skew_tree INTEGER;
BEGIN
PERFORM lock_card_section(OLD.tree);
-- Проверяем, стоит ли выполнять триггер:
IF OLD.trigger_for_delete = TRUE THEN RETURN OLD; END IF;
-- Помечаем на удаление дочерние узлы:
@vmpartner
vmpartner / docker.sh
Created Feb 12, 2019
Easy install docker & compose on ubuntu
View docker.sh
echo "Start" && \
curl -fsSL https://get.docker.com -o get-docker.sh && \
sh get-docker.sh && \
curl -L "https://github.com/docker/compose/releases/download/1.23.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose && \
chmod +x /usr/local/bin/docker-compose && \
echo "Finish"
@vmpartner
vmpartner / sethost.sh
Last active Jan 28, 2019
Script for easy change ubuntu hostname
View sethost.sh
#!/bin/bash
#Assign existing hostname to $hostn
hostn=$(cat /etc/hostname)
#Display existing hostname
echo "Existing hostname is $hostn"
#Ask for new hostname $newhost
echo "Enter new hostname: "
read newhost
View gist:dcc271f70f452b79760c4b647c588091
v := reflect.ValueOf(client)
for i := 0; i < v.NumField(); i++ {
key := v.Type().Field(i).Name
value := ""
switch v.Field(i).Type().String() {
case "int64":
value = strconv.Itoa(int(v.Field(i).Int()))
View convert.sh
#!/bin/bash
# Recursive file convertion utf-8 --> windows-1251
# Place this file in the root of your site, add execute permission and run
# Converts *.php, *.html, *.css, *.js files.
# To add file type by extension, e.g. *.cgi, add '-o -name "*.cgi"' to the find command
find ./ -name "*.php" -o -name "*.html" -o -name "*.css" -o -name "*.js" -type f |
while read file
do
You can’t perform that action at this time.