Skip to content

Instantly share code, notes, and snippets.

View slucero's full-sized avatar

Stephen Lucero slucero

  • Red Hat
  • Arkansas
View GitHub Profile
@slucero
slucero / phpdoc-types.md
Last active November 2, 2023 21:15
PHPDoc Type Specification Notes

Advanced PHPDoc Type Specification

Notes

  • Cannot currently specify strict limiting of array keys (issue)
    • Array shapes are assumed to be incomplete and allow additional key/value assignments by default.
  • The Drupal coding standards don't currently play nicely with multiline array shapes and type specifications.
  • @param specifications warn about not having a variable name on the same line
@slucero
slucero / farm_1.au3
Created August 8, 2018 14:51
Farmville auto-farm script
; Change this to set the current farm size. This can change as the farm levels up.
Const $farm_size = 20
Dim $farm_x[$farm_size][$farm_size] = [[0]]
Dim $farm_y[$farm_size][$farm_size] = [[0]]
; Calculate farm square dimensions for traversal.
$res_height = @DesktopHeight
$res_width = @DesktopWidth
$square_width = 50
@slucero
slucero / BlockContentPlacementSubscriber.php
Created May 22, 2017 19:24
YAML Content - Block Placement Event Subscriber
<?php
namespace Drupal\yaml_content\EventSubscriber;
use Drupal\block\Entity\Block;
use Drupal\block_content\Entity\BlockContent;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Entity\EntityStorageException;
use Drupal\yaml_content\Event\EntityPostSaveEvent;
use Drupal\yaml_content\Event\YamlContentEvents;
@slucero
slucero / README.md
Last active September 29, 2016 18:11
Create New Github PR

Add the git-pr file into as an executable in your local PATH. For example, if ~/bin is in your PATH, then the following should work:

# Add and save script content.
vi ~/bin/git-pr
# Make the script executable.
chmod u+x ~/bin/git-pr
@slucero
slucero / Vagrantfile
Last active January 25, 2018 22:55
Local Vagrant Configuration
# ~/.vagrant.d/Vagrantfile
# Local configuration to use across all Vagrant machines
Vagrant.configure("2") do |config|
config.vm.provider :virtualbox do |vb|
host = RbConfig::CONFIG['host_os']
# Force settings for allowed resources
if host =~ /darwin/
@slucero
slucero / git-merge-all
Created December 8, 2015 19:11
Git command script to merge a single branch into multiple others.
#!/bin/bash
##############################
# Merge the current branch into multiple other local branches.
#
# TODO: Add the option to pass additional arguments to merge commands
##############################
# Determine the current branch name
source=$(git symbolic-ref HEAD 2> /dev/null) || source=$(git rev-parse --short HEAD 2> /dev/null);
@slucero
slucero / git-track-all
Created December 8, 2015 19:06
Git command script to locally track all remote branches
#!/usr/bin/env ruby
##############################
# Create local tracking branches for all remote branches
# that don't have local branches with a matching name.
#
# TODO: Add remote name as an agument
# TODO: Add option for pass-through grep arguments to filter branches
##############################
@slucero
slucero / issue_numbers.rb
Created November 5, 2015 20:10
A Git hook for prepending commit messages with an issue number found in the current working branch. It's organized for use with the https://github.com/icefox/git-hooks project for managing git hooks.
#! /usr/bin/env ruby
# ~/.git_hooks/lib/issue_numbers.rb
$issue_pattern = /\d{5}(?=-)/
#require 'git'
#g = Git.open(working_dir, :log => Logger.new(STDOUT))
@slucero
slucero / gist:dbadd483ac09fe1bbe9d
Created September 9, 2014 20:57
Angular Compile Content Directive
/**
* Directive for compiling HTML loaded on-the-fly.
*
* Compiles the assigned scope attribute and inserts it inside the current element.
*
* Usage: Assign scope value name containing content to be compiled and inserted
* to compile-content attribute.
*
* Example: <div compile-content="htmlContent"></div>
* This assumes that $scope.htmlContent contains a sanitized HTML string.
@slucero
slucero / gist:cee51deacb4077a79f8e
Created August 29, 2014 15:50
Drupal EntityFieldQuery Example
<?php
$query = new EntityFieldQuery();
$entities = $query->entityCondition('entity_type', 'node')
->entityCondition('bundle', 'event')
->propertyCondition('status', 1)
->fieldCondition('field_date', 'value', array('2011-03-01', '2011-03-31'), 'BETWEEN')
->fieldOrderBy('field_date', 'value', 'ASC')
->execute();
$nodes = node_load_multiple(array_keys($entities['node']));