Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
DIRS="./app/modules/custom/ ./app/themes/custom/"
for i in $(seq 0 4); do
echo "Looking for @expire $(date -d "-$i month" "+%b %Y")."
grep -rni "@expire $(date -d "-$i month" "+%b %Y")" $DIRS && exit 1
done
exit 0
<?php
namespace Drupal\local_testing;
trait LocalTestingTrait {
/**
* Screenshot.
*/
public function takeScreenshot() {
@Sam152
Sam152 / gist:3d51d51d78cdf07d4033
Last active August 29, 2015 14:27
Replicate Snippet for fleshing out brochure website menus
<?php
$main_menu_links = menu_load_links('main-menu');
foreach ($main_menu_links as $menu_item) {
if ($menu_item['link_path'] == 'node/1' && $menu_item['link_title'] !== 'Home') {
$new_node = node_load(replicate_entity_by_id('node', 1));
$new_node->title = $menu_item['link_title'];
$menu_item['link_path'] = 'node/' . $new_node->nid;
menu_link_save($menu_item);
node_save($new_node);
}
<style type='text/css'>
a {
position: absolute;
display: block;
top:0;
bottom:0;
left:0;
right:0;
}
</style>
@Sam152
Sam152 / gist:14524c1c3c7375ec343b
Created September 24, 2014 08:08
Simple grids
@mixin grid($columns, $item-selector: '.views-row', $padding: 15px) {
margin: 0 (-1 * ($padding/2));
@include clearfix;
#{$item_selector} {
padding: {
left: $padding / 2;
right: $padding / 2;
}
float: left;
@include box-sizing(border-box);
@Sam152
Sam152 / Drupal Form Post Array Test Assistant
Created March 15, 2014 08:33
This allows you to turn an HTML form into a PHP POST array to make submitting forms in the context of Drupal tests easier.
javascript:var $=jQuery;var str="";var nl="\n";$.each($("form"),function(e,t){str+="$"+$(t).attr("id").split("-").join("_")+" = array("+nl;$.each($(t).find("input, select, textarea"),function(e,t){var n=$(t).attr("name");var r=$(t).val().split("'").join("\\'");if(n=="op"||n==""||n=="form_build_id"||n=="form_token"||n=="form_id"){return}str+=" '"+n+"' => '"+r+"',"+nl});str+=");"+nl+nl});console.log(str);
<Directory "/Users/sam/Sites/">
Options Indexes MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
<VirtualHost *:80>
@Sam152
Sam152 / gist:8413868
Last active January 3, 2016 05:09
Find what has changed since D7 and D8.
<?php
// ctags --langmap=php:.engine.inc.module.theme.install.php --php-kinds=cdfi --languages=php --recurse
function only_first_part($array) {
$delim = "\t";
foreach ($array as $i => &$line) {
$parts = explode($delim, $line);
$line = $parts[0];
}
@Sam152
Sam152 / gist:8413834
Created January 14, 2014 06:09
Functions that are no longer in D8.
actions_actions_map is no longer in D8.
actions_delete is no longer in D8.
actions_do is no longer in D8.
actions_function_lookup is no longer in D8.
actions_get_all_actions is no longer in D8.
actions_list is no longer in D8.
actions_load is no longer in D8.
actions_save is no longer in D8.
actions_synchronize is no longer in D8.
aggregator_admin_form is no longer in D8.
@mixin clearfix{
&:after{
visibility: hidden;
display: block;
font-size: 0;
content: " ";
clear: both;
height: 0;
}
}