Skip to content

Instantly share code, notes, and snippets.

View nikos-glikis's full-sized avatar

Nikos Glikis nikos-glikis

View GitHub Profile
@nikos-glikis
nikos-glikis / kill
Created March 26, 2019 16:44
Golang handle kill signal
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)
}()
# Generated by Percona Configuration Wizard (http://tools.percona.com/) version REL5-20120208
# Configuration name server generated for [email protected] at 2018-06-10 10:08:14
[mysql]
# CLIENT #
port = 3306
socket = /var/lib/mysql/mysql.sock
[mysqld]
@nikos-glikis
nikos-glikis / my.ini
Created June 3, 2018 15:57
uniform conf
#######################################################################
# 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
$binPhash = base_convert($phash, 16, 2);
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 {
int32(time.Now().Unix())
@nikos-glikis
nikos-glikis / rsync_complete_system.sh
Created May 16, 2017 15:55
rsync a live linux system
#- 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 [email protected] /local/destination
@nikos-glikis
nikos-glikis / mod_all_domain_dirs.php
Created May 11, 2017 18:17
Directadmin - reset user files and folders permissions + restrict php files.
<?php
//this: https://help.directadmin.com/item.php?id=589
$dirs = scandir('/home/');
shuffle($dirs);
$ignoreDirs = [
'.',
'..',
'tmp',
'ftp',
/**
* 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();
#repeat x times
#run 5 ls - runs ls 5 times
function run() {
number=$1
shift
for n in $(seq $number); do
$@
sleep 1
done
}