Skip to content

Instantly share code, notes, and snippets.

Erik Torsner eriktorsner

  • Stockholm, Sweden
Block or report user

Report or block eriktorsner

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@eriktorsner
eriktorsner / cardMap.js
Last active Feb 1, 2018
Small script to display AMD GPU ordering in xmr-stak vs OverdriveNTool.
View cardMap.js
/********************************************************
*
* Small script to display AMD GPU ordering in xmr-stak vs OverdriveNTool.
*
* To run this script, you first need to create a correctly named
* textfile with clinfo output. Use this command to create the file:
*
* C:\some\folder> clinfo | findstr "Device Topology" > clinfo_topology.txt
*
* TIP: Add the above command to your windows startup script, that way you
View lsb-sample3.php
<?php
// Solution 1. Let ElectricCar handle unplugging itself
class ElectricCar extends Car
{
...
public function start()
{
$this->unplug();
parent::start();
View lsp-sample2.php
<?php
class Driver
{
private $car;
public function __construct($car)
{
$this->car = $car;
}
View startyourengines.php
<?php
class Car
{
public function start()
{
/// wrooom
}
}
@eriktorsner
eriktorsner / RuntimeProviderTest.php
Last active Apr 25, 2017
Snippet from RuntimeProviderTest.php
View RuntimeProviderTest.php
<?php
public function testRegister()
{
$container = new Pimple\Container();
$provider = new RuntimeProvider();
$provider->register($container);
$this->assertInstanceOf('helloTestable\Lyrics', $container['lyrics']);
$this->assertInstanceOf('helloTestable\helloTestable', $container['helloTestable']);
@eriktorsner
eriktorsner / helloTestableTest.php
Last active Apr 25, 2017
Snippet from helloTestableTest.php
View helloTestableTest.php
<?php
public function testEchoCss()
{
\WP_Mock::userFunction('is_rtl', array(
'return_in_order' => array(true, false),
));
$dummy = new \stdClass();
$hello = new helloTestable($dummy);
@eriktorsner
eriktorsner / helloTestableTest.php
Last active Apr 25, 2017
Snippet from helloTestableTest.php
View helloTestableTest.php
<?php
public function testEchoLyric()
{
$mockLyric = new \MockLyric('foobar');
$hello = new helloTestable($mockLyric);
$this->expectOutputRegex('/.*foobar*./');
$hello->echoLyric();
}
@eriktorsner
eriktorsner / MockObjects.php
Last active Apr 25, 2017
helloTestable MockObjects.php
View MockObjects.php
<?php
class MockLyric
{
public function __construct($lyric)
{
$this->lyric = $lyric;
}
public function getLyric()
@eriktorsner
eriktorsner / helloTestableTest.php
Last active Apr 25, 2017
Snippet from helloTestableTest.php
View helloTestableTest.php
<?php
public function testInit()
{
$dummy = new \stdClass();
$hello = new helloTestable($dummy);
\WP_Mock::expectActionAdded('admin_notices', array($hello, 'echoLyric'));
\WP_Mock::expectActionAdded('admin_head', array($hello, 'echoCss'));
@eriktorsner
eriktorsner / LyricsTest.php
Last active Apr 25, 2017
Snippet from LyricsTest.php
View LyricsTest.php
<?php
public function testGetLyric()
{
$file = dirname(__DIR__) . '/fixtures/lyrics.txt';
$lyrics = new Lyrics($file);
\WP_Mock::userFunction('wptexturize', array(
'return' => function($s) {
return $s . ' wptexturize';
You can’t perform that action at this time.