Skip to content

Instantly share code, notes, and snippets.

@gizzmo
gizzmo / GoogleMailRepositoryTest.php
Created June 15, 2017 02:51
Wanted to try my hand a mocking the PHP Google API. Am I doing this right?
<?php
namespace Tests\Unit;
use Tests\TestCase;
class GoogleMailRepositoryTest extends TestCase
{
public function testFindsMessage()
{
@gizzmo
gizzmo / tests\Unit\ScheduleProcessorTest.php
Created June 6, 2017 03:42
First time doing PHPUnit testing. And I think I might not be doing this right.
<?php
namespace Tests\Unit;
use Mockery;
use Carbon\Carbon;
use Tests\TestCase;
use App\ScheduleProcessor;
use App\Contracts\MailMessage;
use Illuminate\Support\Collection;
@gizzmo
gizzmo / defer.lua
Created March 22, 2017 19:42
Defer a function's execution if in combat lock down, until combat is over.
-- Get the addon namespace
local ADDON_NAME, private = ...
local deferframe = CreateFrame('Frame')
deferframe.queue = {}
local function runDeferred(thing)
local thing_t = type(thing)
if thing_t == 'string' and private[thing] then
private[thing](private)
@gizzmo
gizzmo / .php_cs
Last active May 25, 2016 23:58
php-cs-fixer config file containing all fixers with descriptions. Comment out the ones you don't want to use, or un-comment the ones you do.
<?php
use Symfony\CS\Config\Config;
use Symfony\CS\FixerInterface;
use Symfony\CS\Finder\DefaultFinder;
$fixers = [
// 'psr0', // [PSR-0] Classes must be in a path that matches their namespace, be at least one namespace deep, and the class name should match the file name.
'encoding', // [PSR-1] PHP code MUST use only UTF-8 without BOM (remove BOM).
@gizzmo
gizzmo / gist:b98c4f690c06695291f9
Created May 24, 2015 14:44
pre-commit - phpunit testing
#!/usr/bin/php
<?php
echo PHP_EOL;
// output a little introduction
echo '>> Starting unit tests' . PHP_EOL;
// get the name for this project; probably the topmost folder name
$projectName = basename(getcwd());
@gizzmo
gizzmo / mymedia
Last active February 18, 2017 03:07
Script to maintain my media files
#!/usr/bin/env bash
# Take ownership
find /mnt/{Movie-Drive/Movies,Tv-Drive/Tv-Shows}/ \( ! -user mymedia -o ! -group mymedia \) -exec chown mymedia:mymedia {} \+
# Set correct permission
find /mnt/{Movie-Drive/Movies,Tv-Drive/Tv-Shows}/ -type d ! -perm 775 -exec chmod 775 {} \+
find /mnt/{Movie-Drive/Movies,Tv-Drive/Tv-Shows}/ -type f ! -perm 664 -exec chmod 664 {} \+
# Secure files
@gizzmo
gizzmo / gist:2866207
Created June 4, 2012 03:42
script to ease creating virtualhosts on ubuntu.
#!/bin/bash
#================================================================================
# virtualhost
#
# A fancy little script to setup a new virtualhost in Ubuntu based upon the
# excellent virtualhost (V1.04) script by Patrick Gibson <[email protected]> for OS X.
#
# This script has been tested on Ubuntu 7.10 (Gutsy Gibbon) with Apache2(!) and
# probably works on Debian as well, but this has not been tested (yet). If you use
# this script on other Linux distributions and can confirm it to work I would like to hear
@gizzmo
gizzmo / minecraft_backup.bat
Last active October 6, 2017 05:44
Minecraft saves backup script for windows.
@ECHO OFF
SETLOCAL
::Minecraft backup script
::You need to install 7-Zip first. It can be found here: http://www.7-zip.org/
::Please check the path section first before running!
::---------------------------------------------------------------------------------------------------------------------------------------------------------
::Path section
::Set this variable to your Minecraft path. It should be ok for every Windows 7 OS.
<?php
/**
* Blizzard to Wowhead converter
*
* Converts Blizzard's talent string and class id into Wowhead's (shorter) talent string
*
* @author Gizzmo <[email protected]>
*
* @param string|int $class Blizzard's class id or class name