run those commands to setup permissions for both apache2 and cli commands,

so you can run cache:clear command or remove app/cache/dev or app/cache/prod directories without subsequent problems with permission denied errors

HTTPDUSER=`ps aux | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx' | grep -v root | head -1 | cut -d\  -f1`
sudo setfacl -R -m u:"$HTTPDUSER":rwX -m u:`whoami`:rwX app/cache app/logs
sudo setfacl -dR -m u:"$HTTPDUSER":rwX -m u:`whoami`:rwX app/cache app/logs

 

 

I don’t find that information using google so I think I should post it here.

If u want execute php script via php command in zenbox.pl cron u should add following command:

/usr/local/bin/php /home/lpodolski/domains/lpodolski.com/cron/refreshPage.php >/dev/null 2>&1

In zenbox controll panel this should look like this:

Of course for experienced users this is obvious, but zenbox.pl hosting platform main target are casual users who want to simply host their blog or email. So at first I have expected that standard command would work out of the box

php /home/lpodolski/domains/lpodolski.com/cron/refreshPage.php >/dev/null 2>&1

there is also no feedback that command was not successful, so it take me some time before i realize that this doesnt work

of course u can probably use standard wget url to open URL via CRON but in this case u allow cron executions for everyone:

wget -qO- http://lpodolski.com &> /dev/null

 

In order to have Polish language spell checking In PhpStorm you must generate .dic file with words.

You can do that using linux command:

aspell --lang pl dump master | aspell --lang pl expand | tr ' ' '\n' > polish.dic

You can also download this file generated by me, by clicking: Polish PhpStorm dictionary

Next you go to settings, for single project or you can also set it as default (default setting wouldn’t apply to old procjects). Type in search “Spelling” change tab to “Dictionaries”, click + button to add folder where generated dictionary is placed. Apply. If not working, try to reboot PhpStorm.

How to search key value pair in multidimensional array? In other words search for subset of multidimensional, multilevel array by key and value pair.

This is solution to this problem, notice that in $arr[1] there is multidimensional array, and is also returned in output of search.

<?php

$arr = array(
    0 => array(
        'id' => 0,
        'name' => "cat 1"
    ),
    1 => array(
            array(
                'id' => 1,
                'name' => "cat 1"
            )
    )
,
    2 => array(
        'id' => 2,
        'name' => "cat 2"
    )
);

$arrIterator = new RecursiveIteratorIterator(new RecursiveArrayIterator($arr));

foreach ($arrIterator as $arrIteratorItem) {

    $subArray = $arrIterator->getSubIterator();

    if (isset($subArray['name']) && $subArray['name'] === 'cat 1') {
        $outputArray[] = iterator_to_array($subArray);
    }
}

print_r($outputArray);

output of print_r :

Array
(
    [0] => Array
        (
            [id] => 0
            [name] => cat 1
        )

    [1] => Array
        (
            [id] => 1
            [name] => cat 1
        )

)

BTW as you can see in first code snippet, it do not include closing ?> tag. As you can know closing PHP tag is optional. And if do not necessary you can and should not include it. This is because after closing PHP tag there could be empty white space character that will make problems with sessions. Ie. “headers already send” type of errors.

Sources:

I want expand my last post (Immediately invoked function expression aka IIFE), by more examples of using IIFE.

IIFE can be also used like this:

var foo = function() {
// code
}();

However, it’s better practice to do this like this, because of code readability:

var foo = (function() {
// long code
})();

If you have on your page jQuery and maybe other JS library that uses $ sing to access it. You may use this little pattern to pass library to IIFE, the way it will not make conflicts. And also get advantage of $ access to that library:

(function($) {
// code using $
})(jQuery);

Also it helps with rendering animations:

(function animation_loop() {
    window.requestAnimationFrame(animation_loop)
    render():
})();

It’s protect against unwanted globals:

(function() {
     window.public = 'foo';
     var private = 'bar';
})();

// latter on

public; // foo
private; // undefined

Useful if you want compute and return value in one statement:

var browser = {
    vendor_prefix : (function() {
        var prefix;
        // compute stuff
        return prefix;
    })()
};

Create a class in one statement:

var MyClass = (function() {
    function MyClass(foo) {
        this.foo = foo;
    }

    MyClass.prototype = {
        bar : 'baz'
    };

    return MyClass;
})();

Creating private variables:

var number = (function() {

    var num =0,
    add = function(n) { num = num + n;},
    get = function() { return num; };

    return { add:add, get:get};
})();

create private functions:

var foo = (function() {
    var priv = function() { alert('Hi'); },
        publ = function() { priv(); }

    return publ;
})();

Sources:

#!/bin/bash

DETECTOR=`/bin/arcconf getconfig 1 |grep -i optimal |wc -l`

if [ "$DETECTOR" -ne "2" ] 
then

	echo  "`/bin/arcconf getconfig 1`" | mail -s "There is problem with RAID" [email protected]

fi

Of course, you must add it to cron, for example like this:

*/10 * * * * /usr/local/bin/raid_check.sh

This is what: arcconf getconfig 1  command returns:

Bellow command, show information about RAID configuration and status, and also about logical and physical devices.

server:~# arcconf getconfig 1
Controllers found: 1
----------------------------------------------------------------------
Controller information
----------------------------------------------------------------------
   Controller Status                        : Optimal
   Channel description                      : SAS/SATA
   Controller Model                         : Adaptec 5405
   Controller Serial Number                 : 9D31112A78D
   Physical Slot                            : 49
   Temperature                              : 75 C/ 167 F (Normal)
   Installed memory                         : 256 MB
   Copyback                                 : Disabled
   Background consistency check             : Disabled
   Automatic Failover                       : Enabled
   Global task priority                     : High
   Performance Mode                         : Default/Dynamic
   Stayawake period                         : Disabled
   Spinup limit internal drives             : 0
   Spinup limit external drives             : 0
   Defunct disk drive count                 : 0
   Logical devices/Failed/Degraded          : 1/0/0
   SSDs assigned to MaxIQ Cache pool        : 0
   Maximum SSDs allowed in MaxIQ Cache pool : 8
   NCQ status                               : Enabled
   --------------------------------------------------------
   Controller Version Information
   --------------------------------------------------------
   BIOS                                     : 5.2-0 (17899)
   Firmware                                 : 5.2-0 (17899)
   Driver                                   : 1.1-5 (2461)
   Boot Flash                               : 5.2-0 (17899)
   --------------------------------------------------------
   Controller Battery Information
   --------------------------------------------------------
   Status                                   : Not Installed

----------------------------------------------------------------------
Logical device information
----------------------------------------------------------------------
Logical device number 0
   Logical device name                      : Device 0
   RAID level                               : 5
   Status of logical device                 : Optimal
   Size                                     : 342890 MB
   Stripe-unit size                         : 256 KB
   Read-cache mode                          : Enabled
   MaxIQ preferred cache setting            : Enabled
   MaxIQ cache setting                      : Disabled
   Write-cache mode                         : Enabled (write-back)
   Write-cache setting                      : Enabled (write-back)
   Partitioned                              : Yes
   Protected by Hot-Spare                   : No
   Bootable                                 : Yes
   Failed stripes                           : No
   Power settings                           : Disabled
   --------------------------------------------------------
   Logical device segment information
   --------------------------------------------------------
   Segment 0                                : Present (0,0) 10486536320009980002
   Segment 1                                : Present (0,1) 11096504340004610020
   Segment 2                                : Present (0,2) 1110652233000461006C
   Segment 3                                : Present (0,3) 10486536320009980024

----------------------------------------------------------------------
Physical Device information
----------------------------------------------------------------------
      Device #0
         Device is a Hard drive
         State                              : Online
         Supported                          : Yes
         Transfer Speed                     : SATA 3.0 Gb/s
         Reported Channel,Device(T:L)       : 0,0(0:0)
         Reported Location                  : Connector 0, Device 0
         Vendor                             :
         Model                              : Corsair CSSD-F12
         Firmware                           : 2.0
         Serial number                      : 10486536320009980002
         Size                               : 114473 MB
         Write Cache                        : Enabled (write-back)
         FRU                                : None
         S.M.A.R.T.                         : No
         S.M.A.R.T. warnings                : 0
         Power State                        : Full rpm
         Supported Power States             : Full rpm,Powered off
         SSD                                : Yes
         MaxIQ Cache Capable                : No
         MaxIQ Cache Assigned               : No
         NCQ status                         : Enabled
      Device #1
         Device is a Hard drive
         State                              : Online
         Supported                          : Yes
         Transfer Speed                     : SATA 3.0 Gb/s
         Reported Channel,Device(T:L)       : 0,1(1:0)
         Reported Location                  : Connector 0, Device 1
         Vendor                             :
         Model                              : Corsair CSSD-F12
         Firmware                           : 2.0
         Serial number                      : 11096504340004610020
         Size                               : 114473 MB
         Write Cache                        : Enabled (write-back)
         FRU                                : None
         S.M.A.R.T.                         : No
         S.M.A.R.T. warnings                : 0
         Power State                        : Full rpm
         Supported Power States             : Full rpm,Powered off
         SSD                                : Yes
         MaxIQ Cache Capable                : No
         MaxIQ Cache Assigned               : No
         NCQ status                         : Enabled
      Device #2
         Device is a Hard drive
         State                              : Online
         Supported                          : Yes
         Transfer Speed                     : SATA 3.0 Gb/s
         Reported Channel,Device(T:L)       : 0,2(2:0)
         Reported Location                  : Connector 0, Device 2
         Vendor                             :
         Model                              : Corsair CSSD-F12
         Firmware                           : 2.0
         Serial number                      : 1110652233000461006C
         Size                               : 114473 MB
         Write Cache                        : Enabled (write-back)
         FRU                                : None
         S.M.A.R.T.                         : No
         S.M.A.R.T. warnings                : 0
         Power State                        : Full rpm
         Supported Power States             : Full rpm,Powered off
         SSD                                : Yes
         MaxIQ Cache Capable                : No
         MaxIQ Cache Assigned               : No
         NCQ status                         : Enabled
      Device #3
         Device is a Hard drive
         State                              : Online
         Supported                          : Yes
         Transfer Speed                     : SATA 3.0 Gb/s
         Reported Channel,Device(T:L)       : 0,3(3:0)
         Reported Location                  : Connector 0, Device 3
         Vendor                             :
         Model                              : Corsair CSSD-F12
         Firmware                           : 2.0
         Serial number                      : 10486536320009980024
         Size                               : 114473 MB
         Write Cache                        : Enabled (write-back)
         FRU                                : None
         S.M.A.R.T.                         : No
         S.M.A.R.T. warnings                : 0
         Power State                        : Full rpm
         Supported Power States             : Full rpm,Powered off
         SSD                                : Yes
         MaxIQ Cache Capable                : No
         MaxIQ Cache Assigned               : No
         NCQ status                         : Enabled

Command completed successfully.

Shorter version of this command, exactly: arcconf getconfig 1 ld  , showing only logical device information. This means it only show information about RAID:

server:~# arcconf getconfig 1 ld
Controllers found: 1
----------------------------------------------------------------------
Logical device information
----------------------------------------------------------------------
Logical device number 0
   Logical device name                      : Device 0
   RAID level                               : 5
   Status of logical device                 : Optimal
   Size                                     : 342890 MB
   Stripe-unit size                         : 256 KB
   Read-cache mode                          : Enabled
   MaxIQ preferred cache setting            : Enabled
   MaxIQ cache setting                      : Disabled
   Write-cache mode                         : Enabled (write-back)
   Write-cache setting                      : Enabled (write-back)
   Partitioned                              : Yes
   Protected by Hot-Spare                   : No
   Bootable                                 : Yes
   Failed stripes                           : No
   Power settings                           : Disabled
   --------------------------------------------------------
   Logical device segment information
   --------------------------------------------------------
   Segment 0                                : Present (0,0) 10486536320009980002
   Segment 1                                : Present (0,1) 11096504340004610020
   Segment 2                                : Present (0,2) 1110652233000461006C
   Segment 3                                : Present (0,3) 10486536320009980024

Command completed successfully.

Last command: arcconf getconfig 1 AL , show information about all kinds of devices, this means, controller itself, RAID status and configuration, and also logical and physical devices:

server:~# arcconf getconfig 1 AL
Controllers found: 1
----------------------------------------------------------------------
Controller information
----------------------------------------------------------------------
   Controller Status                        : Optimal
   Channel description                      : SAS/SATA
   Controller Model                         : Adaptec 5405
   Controller Serial Number                 : 9D31112A78D
   Physical Slot                            : 49
   Temperature                              : 75 C/ 167 F (Normal)
   Installed memory                         : 256 MB
   Copyback                                 : Disabled
   Background consistency check             : Disabled
   Automatic Failover                       : Enabled
   Global task priority                     : High
   Performance Mode                         : Default/Dynamic
   Stayawake period                         : Disabled
   Spinup limit internal drives             : 0
   Spinup limit external drives             : 0
   Defunct disk drive count                 : 0
   Logical devices/Failed/Degraded          : 1/0/0
   SSDs assigned to MaxIQ Cache pool        : 0
   Maximum SSDs allowed in MaxIQ Cache pool : 8
   NCQ status                               : Enabled
   --------------------------------------------------------
   Controller Version Information
   --------------------------------------------------------
   BIOS                                     : 5.2-0 (17899)
   Firmware                                 : 5.2-0 (17899)
   Driver                                   : 1.1-5 (2461)
   Boot Flash                               : 5.2-0 (17899)
   --------------------------------------------------------
   Controller Battery Information
   --------------------------------------------------------
   Status                                   : Not Installed

----------------------------------------------------------------------
Logical device information
----------------------------------------------------------------------
Logical device number 0
   Logical device name                      : Device 0
   RAID level                               : 5
   Status of logical device                 : Optimal
   Size                                     : 342890 MB
   Stripe-unit size                         : 256 KB
   Read-cache mode                          : Enabled
   MaxIQ preferred cache setting            : Enabled
   MaxIQ cache setting                      : Disabled
   Write-cache mode                         : Enabled (write-back)
   Write-cache setting                      : Enabled (write-back)
   Partitioned                              : Yes
   Protected by Hot-Spare                   : No
   Bootable                                 : Yes
   Failed stripes                           : No
   Power settings                           : Disabled
   --------------------------------------------------------
   Logical device segment information
   --------------------------------------------------------
   Segment 0                                : Present (0,0) 10486536320009980002
   Segment 1                                : Present (0,1) 11096504340004610020
   Segment 2                                : Present (0,2) 1110652233000461006C
   Segment 3                                : Present (0,3) 10486536320009980024

----------------------------------------------------------------------
Physical Device information
----------------------------------------------------------------------
      Device #0
         Device is a Hard drive
         State                              : Online
         Supported                          : Yes
         Transfer Speed                     : SATA 3.0 Gb/s
         Reported Channel,Device(T:L)       : 0,0(0:0)
         Reported Location                  : Connector 0, Device 0
         Vendor                             :
         Model                              : Corsair CSSD-F12
         Firmware                           : 2.0
         Serial number                      : 10486536320009980002
         Size                               : 114473 MB
         Write Cache                        : Enabled (write-back)
         FRU                                : None
         S.M.A.R.T.                         : No
         S.M.A.R.T. warnings                : 0
         Power State                        : Full rpm
         Supported Power States             : Full rpm,Powered off
         SSD                                : Yes
         MaxIQ Cache Capable                : No
         MaxIQ Cache Assigned               : No
         NCQ status                         : Enabled
      Device #1
         Device is a Hard drive
         State                              : Online
         Supported                          : Yes
         Transfer Speed                     : SATA 3.0 Gb/s
         Reported Channel,Device(T:L)       : 0,1(1:0)
         Reported Location                  : Connector 0, Device 1
         Vendor                             :
         Model                              : Corsair CSSD-F12
         Firmware                           : 2.0
         Serial number                      : 11096504340004610020
         Size                               : 114473 MB
         Write Cache                        : Enabled (write-back)
         FRU                                : None
         S.M.A.R.T.                         : No
         S.M.A.R.T. warnings                : 0
         Power State                        : Full rpm
         Supported Power States             : Full rpm,Powered off
         SSD                                : Yes
         MaxIQ Cache Capable                : No
         MaxIQ Cache Assigned               : No
         NCQ status                         : Enabled
      Device #2
         Device is a Hard drive
         State                              : Online
         Supported                          : Yes
         Transfer Speed                     : SATA 3.0 Gb/s
         Reported Channel,Device(T:L)       : 0,2(2:0)
         Reported Location                  : Connector 0, Device 2
         Vendor                             :
         Model                              : Corsair CSSD-F12
         Firmware                           : 2.0
         Serial number                      : 1110652233000461006C
         Size                               : 114473 MB
         Write Cache                        : Enabled (write-back)
         FRU                                : None
         S.M.A.R.T.                         : No
         S.M.A.R.T. warnings                : 0
         Power State                        : Full rpm
         Supported Power States             : Full rpm,Powered off
         SSD                                : Yes
         MaxIQ Cache Capable                : No
         MaxIQ Cache Assigned               : No
         NCQ status                         : Enabled
      Device #3
         Device is a Hard drive
         State                              : Online
         Supported                          : Yes
         Transfer Speed                     : SATA 3.0 Gb/s
         Reported Channel,Device(T:L)       : 0,3(3:0)
         Reported Location                  : Connector 0, Device 3
         Vendor                             :
         Model                              : Corsair CSSD-F12
         Firmware                           : 2.0
         Serial number                      : 10486536320009980024
         Size                               : 114473 MB
         Write Cache                        : Enabled (write-back)
         FRU                                : None
         S.M.A.R.T.                         : No
         S.M.A.R.T. warnings                : 0
         Power State                        : Full rpm
         Supported Power States             : Full rpm,Powered off
         SSD                                : Yes
         MaxIQ Cache Capable                : No
         MaxIQ Cache Assigned               : No
         NCQ status                         : Enabled

Command completed successfully.