Skip to content

Instantly share code, notes, and snippets.

View shelane's full-sized avatar

Shelane French shelane

View GitHub Profile
@MrPunyapal
MrPunyapal / 1 Types.md
Last active March 6, 2025 19:14
Types In PHP

Atomic Types (Built-in and Scalar)

// Built-in types
$variable = null;             // null type

// Scalar types
$boolVar = true;              // bool type
$intVar = 42;                 // int type
$floatVar = 3.14;             // float type
@jamesfinley
jamesfinley / .stylelintrc.json
Created February 22, 2023 12:08
A Stylelint for ordering your properties and keeping things clean.
/* You'll need the following packages: stylelint, stylelint-config-standard, stylelint-order */
{
"extends": "stylelint-config-standard",
"plugins": [
"stylelint-order"
],
"rules": {
"length-zero-no-unit": [true, {"ignore": ["custom-properties"]}],
"property-no-vendor-prefix": null,
@lpeabody
lpeabody / migrate-paragraphs.php
Created June 9, 2020 15:12
Move paragraphs from multiple limited-1 fields to a single components field with unlimited cardinality.
<?php
/** @var \Drupal\node\Entity\Node[] $landing_pages */
$landing_pages = \Drupal::entityTypeManager()
->getStorage('node')
->loadByProperties([
'type' => 'landing_page'
]);
$old_paragraph_fields = [
'field_tile_section',
@bdlangton
bdlangton / Blocks.md
Last active October 12, 2023 08:40
Drupal 8 programmatic solutions

Render custom blocks

$bid = 'myblock';
$block = \Drupal\block_content\Entity\BlockContent::load($bid);
$render = \Drupal::entityTypeManager()->getViewBuilder('block_content')->view($block);

Render plugin blocks

$block_manager = \Drupal::service('plugin.manager.block');
@krisrobinson
krisrobinson / ImageUrl.php
Created December 14, 2017 23:45
Thumbnail Image URL Field Formatter for Video Embed Field in Drupal 8
<?php
namespace Drupal\video_embed_field\Plugin\Field\FieldFormatter;
use Drupal\Core\Cache\CacheableMetadata;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Field\FormatterBase;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Form\FormStateInterface;
@koop
koop / ensure-cert-macos.sh
Created November 28, 2017 20:27
Ensures a certificate is in the macOS system keychain.
#!/bin/bash
# Usage
# $ ./install-cert-macos.sh "/path/to/cert"
CERT_PATH="$1"
# First, grab the SHA-1 from the provided SSL cert.
CERT_SHA1=$(openssl x509 -in "$CERT_PATH" -sha1 -noout -fingerprint | cut -d "=" -f2 | sed "s/://g")
# Next, grab the SHA-1s of any standard.dev certs in the keychain.
# Don't return an error code if nothing is found.
; generates interdiff into ~/patches from current diff
alias.interdiff=!git diff > ~/patches/interdiff.txt
; generates interdiff into ~/patches from current staged diff
alias.interdiff-stg=!git diff --staged > ~/patches/interdiff.txt
; generates patch into ~/patches based on branch name.
; usage git genpatch {comment number}
alias.genpatch=!sh -c "br=`git symbolic-ref HEAD|sed s#refs/heads/##`; git diff origin/8.0.x > ~/patches/\${br}.$1.patch"
; rebase branch of 8.0.x
alias.rebase8x=!git fetch origin && git rebase origin/8.0.x
; merge 8.0.x
@jolle-c
jolle-c / valid_date.lasso
Last active August 29, 2015 14:07
Replacement of valid_date that adds an optional param -strict
[
/**!
valid_date
Replacement of valid_date that adds an optional param -strict. When set to true it will fail on dates that doesn't exist in the real world. Like 2010-02-31.
When used with strict assumes that date inputs are either as ISO or US date format.
2014-10-13 JC Added to Gist
@jolle-c
jolle-c / wrp.lasso
Last active May 2, 2017 06:15
Quick way to grap a web_request param. For Lasso 9
[
/**!
wrp
Quick way to grap a web_request param
2017-05-02 JC Added examples
2014-10-08 JC Added to Gist
2014-10-08 JC Added separate methods for queryparams and postparams
2014-08-24 JC Rewrite of the wrp method once again. This time with code suggested by Brad Lindsay in a lassotalk thread. Introduces the param -all
@seanbuscay
seanbuscay / git_create_orphan.sh
Created June 27, 2013 15:26
Create an orphan branch in a repo.
cd repository
git checkout --orphan orphan_name
git rm -rf .
rm '.gitignore'
echo "#Title of Readme" > README.md
git add README.md
git commit -a -m "Initial Commit"
git push origin orphan_name