Tuesday, July 7, 2015

Mocking PHP functions in PHPUnit test

It relies on using namespaces. Call to PHP function must be in the form time() and not \time().

Class to test(Example.php):
<?php
namespace Example;
class Example {
    public function doSomething()
    {
         return time();
    }
}


Test class(ExampleTest.php):
<?php
namespace Example {
    function time()
    {
        return 5;
    }
}
namespace ExampleTest {
    use Example\Example;

    class ExampleTest extends \PHPUnit_Framework_TestCase {
        protected $sut;

        public function setUp()
        {
             $this->sut = new Example();
        }

        public function testDoSomething()
        {
             $this->assertSame(5, $this->sut->doSomething());
        }
    }
}


Note: Auto loading of classes is omitted.

Tuesday, May 12, 2015

Getting youtube's subscriptions RSS


1. Login in Youtube
2. Click the links in order specified below:


3. Scroll to the bottom of the page (you may adjust subscriptions before that if you like):

4. Import downloaded file in your favorite RSS reader.

Thursday, December 25, 2014

How to enable CUDA for Freemake Video Converter for drivers after 337.88

For NVidia drivers after 337.88 CUDA option is unavailable:



1. Download 337.88 WHQL driver from NVidia website
2. Extract it to some folder with 7z
3. In Display.Driver folder extract nvcuvenc32.dl_ with 7z to nvcuvenc32.dll and rename it to nvcuvenc.dll
4. Copy nvcuvenc.dll to the  Freemake installation folder

The end result:


Note: NVidia drivers 347.09@GTX970, Freemake VC 4.1.5

Saturday, December 20, 2014

ADATA SP920SS 256GB vs KINGSTON SV300S37A 240G vs ADATA NH13 USB 1TB

SP920 256GB:



SV300S37A 240GB:


24% free space

87% free space

ADATA NH13 1TB



Kingston results are not very impressive, but it has somewhat nice price and it is quieter than standard HDD. ADATA NH13 contains  TOSHIBA MQ01ABD100/SATA2/5400/8MB drive. Here is benchmark on H97/i5/16GB RAM System with 2TB Seagate (Seagate2000DM001) disk:


Note: I just run the benchmarks no additional setup was made so I do not pretend they to be 'valid'. I hope someone finds them useful.

Saturday, November 29, 2014

Creating Windows Recovery Partition with AOMEI OneKey

Preconditions
 Installed Windows
 System Reserved partition is available

Steps
1. Install AOMEI OneKey backup
2. Run it and create recovery partition
3. Add a letter to the system reserved partition (one created during windows installation) - for example X:
4. Run command prompt as administrator and type the following commands:


bcdboot c:\windows /s x:
bcdedit /set {3940e26a-75e7-11e4-bfda-88dcdc879809} device partition=X:

where {3940e26a-75e7-11e4-bfda-88dcdc879809} is identifier of AOMEI entry (you can check it with bcdedit without parameters)

5. Move okldr.mbr, okcf.lst and okldr from C:'s root to X:'s
6. Remove letter from system reserved partition
7. (Optional) Test recovery

Note: When you run OneKey to recover, it will restore boot manager to the state when it was run i.e. AOMEI boot entry will point to C: - just repeat steps 3-6.

This covers the case when OS partition is formatted or essential files are deleted which in standard way won't work because AOMEI boot files are on OS partition..

Wednesday, July 16, 2014

Veeam Backup Free Edition Rant

I wanted to try this 'free' tool the ads for which were poking my eyes for a long time, but :


They want not only my phone but they do not accept 'public' email address. Also if you think that in the following screen:

you can sign in using Google+ account for example - think again (and read the underlined text). You will need to create account anyway. I don't want to link my Google+ account I want to log in with it and download the damn tool. In fact if the tool is free - I don't want to log in at all.

My conclusion: I am not the target audience. Whatever.

EDIT: Found it on Softpedia (no registration required).
EDIT 2: Softpedia version is 7.0.0.690 which does not support vSphere 5.5 . You need to download at least R2 patch which leads to the registration problem.

PS. Tried some alternatives:
1. NAKIVO Free Edition - does not support Free ESXi
2. Trilead VM Explorer - does not support latest version of ESXi 5.5 (2014-07-01) , but looks promising and probably when updated will support it.

EDIT 3: Latest 5.0.031.0 works and looks it will do :)

For the moment decided to use WinSCP + SSH on the host. Speed was around 100Mbit which works for me.

PS. After switching to 1000Mbit  had to enable rc4 and blowfish ssh ciphers on the server to get more than 20MB/s. By default only aes ciphers are enabled.



Saturday, July 12, 2014