Skip to content

Instantly share code, notes, and snippets.

View marinsagovac's full-sized avatar

Marin Sagovac marinsagovac

View GitHub Profile
#!/bin/bash
# Script will output dumps for all databases using seperate files
# Derived from this post: http://www.cyberciti.biz/faq/ubuntu-linux-mysql-nas-ftp-backup-script/
USER="root"
PASSWORD="SnM1073k"
HOST="localhost"
MYSQL="$(which mysql)"
MYSQLDUMP="$(which mysqldump)"
OUTPUT_DIR="/backups/files"
# Allow a command to continue execution after logout
nohup mycommand &
# Display one particular line from a file
gzip -dc mytarball.tar.gz | tar xvf -
# Display current runlevel
who -r
# Split lines of text into n-char lines
FF000000
FFFFFFFF
FFFF0000
FF00FF00
FF0000FF
FFFFFF00
FFFF00FF
FF00FFFF
FF800000
FF008000
@marinsagovac
marinsagovac / PHP EIO Event example
Last active December 21, 2020 10:15
PHP EIO Event example
<?php
// Add eio so file in php.ini
var_dump(extension_loaded('eio'));
// sudo pecl install eio-1.2.5
// add extension in php.ini extension=eio.so
/* Is called when eio_nop() finished */
function my_nop_cb($data, $result) {
sleep(1);
echo "my_nop ", $data, "\n";
sleep(2);
@marinsagovac
marinsagovac / PHP PCNTL fork process
Last active December 14, 2017 10:16
PCNTL fork process
<?php
$pid = pcntl_fork();
if ($pid == -1) {
die("could not fork");
} else if ($pid) {
exit(); // we are the parent
} else {
// we are the child
}
if (posix_setsid() == -1) {
@marinsagovac
marinsagovac / PHP CHARS ASCII
Last active December 14, 2017 10:16
Grim string to number
<?
$num_to_char = array(
'27' => "1",
'28' => "2",
'29' => "3",
'30' => "4",
'31' => "5",
'32' => "6",
'33' => "7",
'34' => "8",