Skip to content

Instantly share code, notes, and snippets.

View eriktorsner's full-sized avatar

Erik Torsner eriktorsner

  • Stockholm, Sweden
View GitHub Profile

Use gh v0.11.0 or later for the "shell" aliases.

Run the following gh alias set commands for each operation. You can confirm the created aliases with gh alias list.

gh listMilestones

gh alias set listMilestones "api graphql -F owner=':owner' -F name=':repo' -f query='
    query ListMilestones(\$name: String\!, \$owner: String\!) {
        repository(owner: \$owner, name: \$name) {
            milestones(first: 100) {
@eriktorsner
eriktorsner / WordPressMultisiteValetDriver.php
Created August 18, 2023 11:04
Updated WordPress multisite driver for valet 4
<?php
namespace Valet\Drivers\Custom;
use Valet\Drivers\BasicValetDriver;
/*
Valet driver for Wordpress Multisite
Usage: Drop this file into your ~/.valet/Drivers/ directory
@eriktorsner
eriktorsner / test_dependencies.php
Last active August 6, 2021 13:03
test dependencies example
<?php
class Item_handler {
public static function upload_one() {
// Do something expensive with lots of deps
return true;
}
public function upload_two() {
// Do something expensive with lots of deps
<?php
$secret = 'top_secret';
$url = 'https://example.com/wa-hook/abc123abc123
$parameters = ['foo' => 'bar'];
$args = ['headers' => []];
$args['body'] = json_encode($parameters);
$hash = hash_hmac('sha1', $args['body'], $secret);
$args['headers']['Content-Type'] = 'application/json; charset=utf-8';
@eriktorsner
eriktorsner / cardMap.js
Last active February 1, 2018 09:09
Small script to display AMD GPU ordering in xmr-stak vs OverdriveNTool.
/********************************************************
*
* 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
<?php
// Solution 1. Let ElectricCar handle unplugging itself
class ElectricCar extends Car
{
...
public function start()
{
$this->unplug();
parent::start();
<?php
class Driver
{
private $car;
public function __construct($car)
{
$this->car = $car;
}
<?php
class Car
{
public function start()
{
/// wrooom
}
}
@eriktorsner
eriktorsner / RuntimeProviderTest.php
Last active April 25, 2017 10:12
Snippet from 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 April 25, 2017 10:13
Snippet from 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);