Skip to content

Instantly share code, notes, and snippets.

Avatar

Pablo Barrios sauron

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

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 Mar 14, 2022
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.
View RefreshCrops.php
<?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 Nov 4, 2021
Event Listener registration for clearing the cache on save. Files: app/Listeners/TwillEventSubscriber.php and in app/Providers/EventServiceProvider.php
View EventServiceProvider.php
/**
* The subscriber classes to register.
*
* @var array
*/
protected $subscribe = [
'App\Listeners\TwillEventSubscriber',
];
@sauron
sauron / twill_step_1.md
Last active Jun 15, 2021
Step by step - Creating a Twill app - Part 1
View twill_step_1.md

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
☢️ DANGEROUS command to delete already created twill crops. 🔞
View DeleteCrop
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
class DeleteCrops extends Command
{
/**
View UpdateCrops.php
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
class UpdateCrops extends Command
{
/**
View VS Code Key Shortcuts.json
// 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
VS Code Settings. Dark Mode. Big Fonts. No panels. Focus Mode.
View VS Code Settings.json
{
"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,
View Sublime USER Settings.json
{
"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 Oct 7, 2016
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"
View auto.sh
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