Skip to content

Instantly share code, notes, and snippets.

Nikos Glikis nikos-glikis

View GitHub Profile
@nikos-glikis
nikos-glikis / kill
Created Mar 26, 2019
Golang handle kill signal
View kill
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 5 second to finish processing")
time.Sleep(5 * time.Second)
os.Exit(0)
}()
View my.cnf
# Generated by Percona Configuration Wizard (http://tools.percona.com/) version REL5-20120208
# Configuration name server generated for a1565408@mvrht.net at 2018-06-10 10:08:14
[mysql]
# CLIENT #
port = 3306
socket = /var/lib/mysql/mysql.sock
[mysqld]
View my.ini
#######################################################################
# File name: my.ini
# Created By: The Uniform Server Development Team
# Edited Last By: Mike Gleaves (ric)
# V 1.0 24-7-2016
########################################################################
[mysql]
default-character-set=utf8
View gist:7135dd9acd1b0ad24b65a67c60ac958a
func addToLog(text string, logfile string) {
f, err := os.OpenFile(logfile, os.O_APPEND|os.O_WRONLY, 0600)
if err != nil {
panic(err)
}
defer f.Close()
if _, err = f.WriteString(text); err != nil {
View rsync_complete_system.sh
#- if use a different port, change the port.
rsync -av -exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found} -z --rsh='ssh -p22' --delete --progress --exclude root@remotehost.com /local/destination
@nikos-glikis
nikos-glikis / mod_all_domain_dirs.php
Created May 11, 2017
Directadmin - reset user files and folders permissions + restrict php files.
View mod_all_domain_dirs.php
<?php
//this: https://help.directadmin.com/item.php?id=589
$dirs = scandir('/home/');
shuffle($dirs);
$ignoreDirs = [
'.',
'..',
'tmp',
'ftp',
View Symfony delete all tables
/**
* Clean database. Truncates all tables except from everything that loads with fixtures.
* Used as a fast clean.
*/
public function cleanDB()
{
$excludeTables = array();
$em = $this->em;
$connection = $em->getConnection();
View usefull bash
#repeat x times
#run 5 ls - runs ls 5 times
function run() {
number=$1
shift
for n in $(seq $number); do
$@
sleep 1
done
}
You can’t perform that action at this time.