Skip to content

Instantly share code, notes, and snippets.

View cartoonclouds's full-sized avatar

Chris Tudhope cartoonclouds

View GitHub Profile
@cartoonclouds
cartoonclouds / MouseControl.h
Created April 12, 2022 16:39 — forked from chuckleplant/MouseControl.h
Mouse control for Windows in C++. Dependencies: User32 Windows library.
#ifndef _WIN32_WINNT
# define _WIN32_WINNT 0x500
#endif
#include "Winuser.h"
class ofxMouse
{
public:
static enum MouseEventFlags
{
@cartoonclouds
cartoonclouds / To_MP3_Windows.bat
Created April 12, 2022 16:39 — forked from chuckleplant/To_MP3_Windows.bat
Converts files to MP3 using FFMPEG, on Windows. Note that you can change m4a to almost any other audio format and ffmpeg will still convert.
@echo off
FOR /F "tokens=*" %%G IN ('dir /b *.m4a') DO ffmpeg -i "%%G" -acodec libmp3lame -ab 128k "%%G.mp3"
@cartoonclouds
cartoonclouds / waiting-for-DOM-elements
Created January 4, 2021 14:48
Util to wait for an element to be added to the DOM before further execution
/** Using MutationObserver **/
/*****************************/
/**
* Continually searches for an element (by selector) in the DOM and returns it if found.
*
* @param selector<string> A selector string use to search for the element
* @returns {Promise<any>}
*/
function existsInDOM(selector) {
@cartoonclouds
cartoonclouds / aliases
Created November 25, 2020 23:48
Custom helper Homestead aliases
alias cbf='./vendor/bin/phpcbf'
alias cdal='composer dumpautoload'
@cartoonclouds
cartoonclouds / Response.php
Created November 23, 2020 03:50 — forked from jeffochoa/Response.php
Laravel HTTP status code
<?php
// This can be found in the Symfony\Component\HttpFoundation\Response class
const HTTP_CONTINUE = 100;
const HTTP_SWITCHING_PROTOCOLS = 101;
const HTTP_PROCESSING = 102; // RFC2518
const HTTP_OK = 200;
const HTTP_CREATED = 201;
const HTTP_ACCEPTED = 202;
@cartoonclouds
cartoonclouds / MultipleEmails.php
Created November 23, 2020 02:10
Laravel Multiple Email Validation Rule
/**
* Usage: new \App\Rules\MultipleEmails
*/
<?php
namespace App\Rules;
use Illuminate\Contracts\Validation\Rule;
use Validator;
@cartoonclouds
cartoonclouds / collection-macro.php
Created April 17, 2020 02:02
A Laravel Collection macro providing the ability to zip collections however not by passing them as parameters but calling zipReverse on the collection of collections.
Collection::macro('zipReverse', function() {
$items = $this->map->values();
$maxElementCount = ($items->map->count())->max();
$zipped = collect();
for($i = 0; $i < $maxElementCount; $i++) {
/** @var Collection $columnItems */
$columnItems = $items->pluck($i);
<?php
declare(strict_types=1);
namespace OsiemSiedem\View;
use ArrayAccess;
use JsonSerializable;
use ReflectionMethod;
use ReflectionObject;
@cartoonclouds
cartoonclouds / Controller.php
Last active January 15, 2020 04:19
View Models/Presenters
public function viewItem(Item $item)
{
$data['product'] = \App\Presenters\VuePresenters\ItemPresenter::decorate($product);
return view('item', $data);
}
// https://laravel-news.com/laravel-view-models
// https://github.com/spatie/laravel-view-models
@cartoonclouds
cartoonclouds / LaravelValidators.php
Created December 4, 2019 00:10
A list of helper Laravel validators.
Validator::extend('alpha_spaces', function ($attribute, $value){
return preg_match('/^[\pL\s]+$/u', $value);
});