Skip to content

Instantly share code, notes, and snippets.

@tortuetorche
tortuetorche / CacheRepository.php
Last active September 11, 2015 18:03 — forked from tillkruss/Database.php
[Laravel 5.1] Use Redis PECL/HHVM extension
<?php
namespace App\Repositories;
use Illuminate\Cache\Repository;
class CacheRepository extends Repository
{
public function has($key)
{
<?php
namespace CHH;
trait MetaObject
{
protected static $__metaClass;
static function setMetaClass(MetaClass $metaClass)
{
@tortuetorche
tortuetorche / 01_OLD_GIST.md
Last active December 21, 2015 18:59
Finite Trait
@tortuetorche
tortuetorche / 01_README.md
Last active June 11, 2016 21:17
Legacy browsers compatibility (like IE 8 and 9, Android 2.3, Safari 5...) for Turbolinks.replace() ⚠️ Alpha version ⚠️

⚠️ This gist has moved to its own Github repository

You can grab the code HERE 😼

@tortuetorche
tortuetorche / quick-slugify.sh
Created November 9, 2016 10:24 — forked from oneohthree/quick-slugify.sh
Quick bash slugify
echo "$STRING" | iconv -t ascii//TRANSLIT | sed -r s/[^a-zA-Z0-9]+/-/g | sed -r s/^-+\|-+$//g | tr A-Z a-z
@tortuetorche
tortuetorche / 01.FiniteStateMachine.README.md
Last active October 12, 2017 23:06
FiniteStateMachine Trait with Example.Add a DSL to the PHP Finite package, borrowed from the Ruby StateMachine gem.

FiniteStateMachine Trait

Add a DSL to the PHP Finite package, borrowed from the Ruby StateMachine gem.

Usage

In your Stateful Class, add the stateMachineConfig() method and call initStateMachine() method at initialization (__contruct() method).

Example

@tortuetorche
tortuetorche / FiniteAuditTrailTrait.php
Created July 12, 2016 15:32
FiniteStateMachine and FiniteAuditTrail Traits for Laravel 5.1 (WIP)
<?php namespace App\Finite;
/**
* The FiniteAuditTrail Trait.
* This plugin, for the Finite package (see https://github.com/yohang/Finite), adds support for keeping an audit trail for any state machine.
* Having an audit trail gives you a complete history of the state changes in your stateful model.
* Prerequisites:
* 1. Install Finite package (https://github.com/yohang/Finite#readme)
* 2. Use FiniteStateMachine in your model (https://gist.github.com/tortuetorche/6365575)
* Usage: in your Stateful Class use this trait after FiniteStateMachine trait, like this "use FiniteAuditTrailTrait;".
@tortuetorche
tortuetorche / INSTALL4Windows.md
Last active April 12, 2020 23:06
Redis for Windows as a Memcache successor for PHP applications and as a queue driver for Laravel

Install Redis as a service on Windows

Installation instructions

  1. Download and extract the last Redis version (2.8.4)
  2. Copy all extracted binaries to c:\redis\bin
  3. Create another folder at c:\redis\inst1
  4. Download and extract the RedisWatcher binaries from the 2.4 branch
  5. Run InstallWatcher.msi with administrator rights. This should create a Windows service called Redis watcher.
@tortuetorche
tortuetorche / README.md
Last active March 12, 2021 12:07
Compile and install runkit PHP PECL extension

Install runkit PHP PECL extension

On Ubuntu

sudo apt-get install gcc php-pear php5-dev
cd ~/Downloads
git clone https://github.com/zenovich/runkit.git
@tortuetorche
tortuetorche / dom.js
Created March 15, 2021 12:36 — forked from rainerborene/dom.js
rails-ujs is a past thing. Here is how you can accomplish almost the same behaviour with Stimulus and Hotwire.
export function reduceToParams(elements) {
return elements.reduce((hash, node) => Object.assign(hash, { [node.name]: node.value }), {})
}
export function stopEverything(e) {
e.preventDefault()
e.stopPropagation()
e.stopImmediatePropagation()
}