Skip to content

Instantly share code, notes, and snippets.

View sauron's full-sized avatar

Pablo Barrios sauron

  • San Miguel de Tucumán, Argentina
View GitHub Profile
@sauron
sauron / twill_settings_translation_file.md
Created June 10, 2022 15:41
Override translation static copy from the Twill CMS.

FORM Creation

File: resources/views/admin/settings/interface.blade.php

@extends('twill::layouts.form', [
    'contentFieldsetLabel' => 'Home',
])

@section('contentFields')
@formField('input', [
    'name' => 'home-a11yHeading',
@sauron
sauron / RefreshCrops.php
Last active March 14, 2022 15:01
Refresh crops command that generates the missing crops for a given Model. This patch make sure that if a Morphmap is set, it will use it to look for the mediables. Added the ability to process crops added in the `config/twill.php`. This will cover block images.
<?php
namespace A17\Twill\Commands;
use Carbon\Carbon;
use Illuminate\Database\DatabaseManager;
use Illuminate\Database\Query\Builder;
use Illuminate\Support\Collection;
use Illuminate\Support\Str;
use A17\Twill\Models\Media;
@sauron
sauron / EventServiceProvider.php
Created November 4, 2021 13:21
Event Listener registration for clearing the cache on save. Files: app/Listeners/TwillEventSubscriber.php and in app/Providers/EventServiceProvider.php
/**
* The subscriber classes to register.
*
* @var array
*/
protected $subscribe = [
'App\Listeners\TwillEventSubscriber',
];
@sauron
sauron / twill_step_1.md
Last active June 15, 2021 02:24
Step by step - Creating a Twill app - Part 1

Step by step - Creating a Twill app.

In this post, I'll create an app from the ground up. I'll assume you have PHP, Laravel and Composer. Of course a mysql DB for storing "everything." All the code it's here for reference.

Installation

Let's create a new app.

@sauron
sauron / DeleteCrop
Last active May 28, 2021 15:34
☢️ DANGEROUS command to delete already created twill crops. 🔞
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
class DeleteCrops extends Command
{
/**
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
class UpdateCrops extends Command
{
/**
// Place your key bindings in this file to overwrite the defaults
[
{
"key": "cmd+y",
"command": "default:redo"
},
/**
* Activity Bar
**/
{
@sauron
sauron / VS Code Settings.json
Last active May 5, 2021 21:15
VS Code Settings. Dark Mode. Big Fonts. No panels. Focus Mode.
{
"editor.multiCursorModifier": "ctrlCmd",
"editor.snippetSuggestions": "top",
"editor.formatOnPaste": false,
"editor.renderWhitespace": "all",
"editor.scrollBeyondLastLine": false,
"files.insertFinalNewline": true,
"editor.find.seedSearchStringFromSelection": true,
"editor.fontSize": 15,
"editor.tabSize": 4,
@sauron
sauron / Sublime USER Settings.json
Created August 28, 2020 13:25
Sublime Settings
{
"color_scheme": "Packages/Material Theme/schemes/Material-Theme-Palenight.tmTheme",
"default_line_ending": "unix",
"draw_white_space": "all",
"ensure_newline_at_eof_on_save": true,
"fallback_encoding": "UTF-8",
"file_exclude_patterns":
[
"*.pyc",
"*.pyo",
@sauron
sauron / auto.sh
Last active October 7, 2016 23:27
My updated version of https://github.com/postmodern/chruby so it always set the gem_home as the directory where there is a .ruby-version file. Line 14 contains the "super hack"
unset RUBY_AUTO_VERSION
function chruby_auto() {
local dir="$PWD/" version
until [[ -z "$dir" ]]; do
dir="${dir%/*}"
if { read -r version <"$dir/.ruby-version"; } 2>/dev/null || [[ -n "$version" ]]; then
if [[ "$version" == "$RUBY_AUTO_VERSION" ]]; then return