Skip to content

Instantly share code, notes, and snippets.

View marinsagovac's full-sized avatar

Marin Sagovac marinsagovac

View GitHub Profile
@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",
@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 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);
FF000000
FFFFFFFF
FFFF0000
FF00FF00
FF0000FF
FFFFFF00
FFFF00FF
FF00FFFF
FF800000
FF008000
# 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
#!/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"
=======================
ONLINE RESOURCES:
=======================
SECTION 1 - OVERVIEW - COURSE INTRODUCTION
========================================
- understand the Magento architecture and modules
- efficiently and effectively customize and extend Magento
- enable the best upgrade path to new versions
@marinsagovac
marinsagovac / PHP Xrange
Created December 15, 2017 09:54
PHP Xrange
<?php
function xrange($start, $limit, $step = 1) {
if ($start < $limit) {
if ($step <= 0) {
throw new LogicException('Step must be +ve');
}
for ($i = $start; $i <= $limit; $i += $step) {
yield $i;
@marinsagovac
marinsagovac / Ubuntu MongoDB install
Created December 15, 2017 10:49
Ubuntu MongoDB install
### Ubuntu Mongodb ###
### Installing Mongodb ###
sudo apt-get install mongodb-server
sudo service mongodb start
Check log in "/var/log/mongodb/mongodb.log"
@marinsagovac
marinsagovac / Logrotate unix
Created December 15, 2017 10:50
Logrotate unix
LOGROTATE CENTOS
================
INFO
====
Check is logrotate active:
cat /etc/cron.daily/logrotate