Skip to content

Instantly share code, notes, and snippets.

@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()
}
@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 / 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)
{