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
{
/**
@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,
// Place your key bindings in this file to overwrite the defaults
[
{
"key": "cmd+y",
"command": "default:redo"
},
/**
* Activity Bar
**/
{
@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 / .profile
Last active November 8, 2017 19:26
Prompt bash for GIT with branches - rvm - and git status.For Mac OSX it must be put on the ~/.profile fileFor Linux it must be put on the ~/.bash_rc file or similar.Just a note the "nothing to commit,..." message depends of your git version.
if [ -f $(brew --prefix)/etc/bash_completion ]; then
. $(brew --prefix)/etc/bash_completion
fi
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit, working tree clean" ]] && echo "*"
}
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/"
}