Skip to content

Instantly share code, notes, and snippets.

View samuelsolis's full-sized avatar

Samuel samuelsolis

View GitHub Profile
@samuelsolis
samuelsolis / openapi.json
Created March 17, 2023 12:27
openapi.json versión 3
{
"openapi": "3.0.3",
"info": {
"title": "Swagger Petstore - OpenAPI 3.0",
"description": "This is a sample Pet Store Server based on the OpenAPI 3.0 specification. ",
"version": "1.0.11"
},
"servers": [
{
"url": "https://petstore3.swagger.io/api/v3"
swagger: "2.0"
info:
description: "This is a sample documentatio for de Color API."
version: "1.0.0"
title: "Swagger Color Management"
contact:
email: "example@example.com"
license:
name: "Apache 2.0"
url: "http://www.apache.org/licenses/LICENSE-2.0.html"
@samuelsolis
samuelsolis / example.php
Created February 7, 2018 08:15
Drupal 8 custom entity without bundle
<?php
/**
* @file
* Contains \Drupal\example\Entity\Example.
*/
namespace Drupal\example\Entity;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Field\BaseFieldDefinition;
@samuelsolis
samuelsolis / Form.php
Last active October 26, 2022 18:52
Change Field value in drupal 8 form with Ajax
<?php
/**
* Form controller for the bb_report entity edit forms.
*
* @ingroup report
*/
class FeeForm extends ContentEntityForm {
/**
* {@inheritdoc}
@samuelsolis
samuelsolis / remove_duplicate_menu_links.sql
Created March 28, 2016 14:03
Remove duplicate item menu links in Drupal.
@samuelsolis
samuelsolis / tinymc.pluggins.js
Created February 3, 2016 12:50
Custom tinyMCE buttons
(function() {
tinymce.PluginManager.add('stylebuttons', function(editor, url) {
/**
* Uppercase & bold button.
*/
editor.addButton('stylebuttons', {
text: 'Resalt',
tooltip: 'Uppercase and bold at time.',
icon: true,
image: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAABiklEQVQ4T52TvUoDQRDHZ/ZEtMgpvoBYaBvyAOKRSuGyJkV6QUgULARbg4g+gKDGECx8A3NLIFqo5wsoYuFHIT6B6KXJmWRH9rg7jnhJxG2WnZn/b3ZmZxF6Fuc8RaQVESktpZxWbsbgHQCvpWSVev38ISrB4JDP58ddt30IAKu90MiZiLDabE5s2vZZS9k9gC++BID5AeKIS946ztSigngAzrOnQzLHcKkihLWOqmYAdtcnc8m378URpMQUZjK5CiIVYwJKQtT2/RtuA8AvCCKUkfPsKwDM9gBCcWDnPBsDoWc0Te4yxkYjgF3H+fQy27bdUbthGCNq1/VJBdmJxLpxgNAvRC1oMvXpkaua+ALA5uIChgGIuk/I+fIJAK79BwAAR2iauSRjdB8MVRQ05AaESEmvxgFPOWiqj4WwNjyAYayM6frHBQBb+MsoE+FNp9NaajQabviZFCSR+DpApEJcOT6YAKjcbn9vKXH4maJZVU80jQpElAbAGeUj6r4haleIVLUs6zEa/wMGdqGMo9K2vQAAAABJRU5ErkJggg==',
@samuelsolis
samuelsolis / git alias
Last active August 4, 2017 11:50
Git alias
git config --global alias.st status
git config --global alias.logf 'log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --numstat'
git config --global alias.ld 'log --pretty=format:"%C(yellow)%h\\ %ad%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --date=relative'
git config --global alias.logv 'log --graph --full-history --all --color --pretty=format:"%x1b[31m%h%x09%x1b[32m%d%x1b[0m%x20%s"'
git config --global alias.logb 'log --graph --full-history --color --pretty=format:"%x1b[31m%h%x09%x1b[32m%d%x1b[0m%x20%s"'
@samuelsolis
samuelsolis / mail_customization.module
Last active August 29, 2015 14:13
Add param to drupal mail links for tracking with Google Analytics
<?php
function mail_customization_mail_alter(&$message){
$preg = '/((https?:\/\/)([\da-z\.-]+)\.?([a-z\.]{2,6})?([\/\w \.-]*)*\/?(\?([A-Za-z0-9=&])*)?)/';
foreach($message['body'] as $key=>$body){
preg_match($preg , $body, $matches);
if (!empty($matches[0])){
$url = $matches[0];
export GIT_PS1_SHOWDIRTYSTATE=true
export GIT_PS1_SHOWUNTRACKEDFILES=true
export GIT_PS1_SHOWSTASHSTATE=true
export PS1='\[\033[1;34m\]\u\[\033[0;30m\]@\[\033[0;32m\]\w\[\033[0;30m\]$(__git_ps1 " [\[\e[31;1m\]%s\[\e[0m\]]")\$ '
@samuelsolis
samuelsolis / mymodule.module
Created April 8, 2014 09:22
Preprocess field in Display Suite module, Drupal 7 example.
/*
* Before this, you have to create a "Preproces field" with name like "mycustomfield".
* In this example we render an user image (a image field, not the user picture).
*
*/
function MYMODULE_preprocess_comment(&$vars){
$author= user_load($vars['user']->uid);
$settings= array('settings' => array('image_style' => 'thumbnail'),'label' => 'hidden' );
$vars['mycustomfield'] = render(field_view_field('user', $author, 'field_user_main_image', $settings));
}