Skip to content

Instantly share code, notes, and snippets.

View gabemartinez's full-sized avatar

Gabriel Martinez gabemartinez

View GitHub Profile
@megclaypool
megclaypool / howto.md
Last active May 31, 2024 09:12
[How to include Drupal 8 & 9 webform values in confirmation etc emails]

In the email subject use:

  • [webform_submission:values:YOUR_FIELD_KEY].
    If you don't want a label to appear, you need to add :no_label
  • [webform_submission:values:YOUR_FIELD_KEY:no_label]
  • If the value is a field in a fieldset, use [webform_submission:values:YOUR_FIELDSET_FORM_KEY:YOUR_FIELD_KEY].
    (For more details, look at the webform tokens)

In the Email handler's custom Twig template:

  • {{ data.YOUR_FIELD_KEY }}
@lmfresneda
lmfresneda / remove_duplicates.js
Last active January 17, 2021 15:36
Remove duplicates from an array of objects in javascript
// FUN METHOD
/**
* Remove duplicates from an array of objects in javascript
* @param arr - Array of objects
* @param prop - Property of each object to compare
* @returns {Array}
*/
function removeDuplicates( arr, prop ) {
let obj = {};
return Object.keys(arr.reduce((prev, next) => {
@telekosmos
telekosmos / uniq.js
Last active November 15, 2022 17:13
Remove duplicates from js array (ES5/ES6)
var uniqueArray = function(arrArg) {
return arrArg.filter(function(elem, pos,arr) {
return arr.indexOf(elem) == pos;
});
};
var uniqEs6 = (arrArg) => {
return arrArg.filter((elem, pos, arr) => {
return arr.indexOf(elem) == pos;
});
@cvrebert
cvrebert / css_regression_testing.md
Last active May 28, 2024 17:42
Survey of screenshot-based CSS testing tools

Currently considering https://github.com/webdriverio/webdrivercss


Core Goals:

  • Can test in up-to-date versions of all major browsers
  • Can test on up-to-date versions of all major OSes
  • Can test in IE9 (because Bootstrap v4 will support IE9+)
  • Don't want to have to setup/maintain our own cluster of VMs running all the necessary OSes (and all the versions of Windows)
  • Workflow for management of reference/baseline/norm screenshots
@eugene-ilyin
eugene-ilyin / render_menu.php
Last active October 26, 2017 23:47
Render menu programmatically in Drupal 7
// One level menu.
$menu = menu_tree('main-menu');
$menu_items = render($menu);
// Menu with many levels.
menu_tree_all_data('main-menu');
$menu = menu_build_tree('main-menu');
$menu_items = render(menu_tree_output($menu));
@jamesmacwhite
jamesmacwhite / hiding-content-outlook-webmail.html
Last active October 12, 2023 11:05
Hiding content with mso-hide:all; to be more friendly with Outlook.com
<!--
Example 1: Using IF ELSE logic
Works with Outlook (Desktop)?: Yes
Works with Outlook.com?: No
When using IF ELSE logic, Outlook.com will remove content in both conditionals, which is problematic.
-->
<!--[if mso]>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
@harunhasdal
harunhasdal / getFavicon.js
Created July 28, 2014 12:19
Download favicon.ico from a website using NodeJS
var request = require("request");
var fs = require("fs");
request("https://github.com/favicon.ico").pipe(fs.createWriteStream('favicon.ico'));
@majodev
majodev / capture.js
Created July 22, 2014 17:21
Capture screenshots (png) from multiple sites with phantomjs
// How to: save as capture.js and run with "phantomjs capture.js"
// Setup by modifying URLS, PAGE_WIDTH AND PAGE_HEIGHT constants!
// Hint: set PAGE_WIDTH or PAGE_HEIGHT to 0 to capture full page!
// modified version of script at http://www.cameronjtinker.com/post/2011/09/26/Take-Screenshot-of-all-HTML-documents-in-a-folder-using-PhantomJS.aspx
var PAGE_WIDTH = 960;
var PAGE_HEIGHT = 640;
var URLS = [
"http://github.com",
@MrSaints
MrSaints / demo.html
Last active December 3, 2017 21:22
Native ports of Morphext in React and Polymer (JavaScript frameworks). They're a work in progress. Use them at your own risk. Original: https://github.com/MrSaints/Morphext
<!doctype html>
<html class="no-js" lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Morphext Web Components (v2.0.0)</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
@insin
insin / app.jsx
Last active July 13, 2021 07:39
React Form Handling - handleFormInputChange (Live version: http://bl.ocks.org/insin/raw/082c0d88f6290a0ea4c7/)
var INPUT_TYPES = 'color|date|datetime|datetime-local|file|month|number|password|range|search|tel|text|time|url|week'.split('|')
var App = React.createClass({
getInitialState: function() {
return {}
},
onChange: handleFormInputChange,
render: function() {