Skip to content

Instantly share code, notes, and snippets.

View tameemsafi's full-sized avatar

Tameem Safi tameemsafi

View GitHub Profile
@tameemsafi
tameemsafi / emails.php
Last active April 15, 2024 12:42
Send an email programmatically in wordpress with wp_mail using the woocommerce transaction emails template.
<?php
// Define a constant to use with html emails
define("HTML_EMAIL_HEADERS", array('Content-Type: text/html; charset=UTF-8'));
// @email - Email address of the reciever
// @subject - Subject of the email
// @heading - Heading to place inside of the woocommerce template
// @message - Body content (can be HTML)
function send_email_woocommerce_style($email, $subject, $heading, $message) {
@tameemsafi
tameemsafi / php_upgrade_to_71.sh
Created September 28, 2017 15:09 — forked from pixeline/php_upgrade_to_71.sh
Update Mac Os X's php version to php 7.1 using homebrew. Includes curl and mcrypt
# 1. Install brew --> http://brew.sh/
# 2. run the following commands in your Terminal
brew tap homebrew/dupes
brew tap homebrew/versions
brew tap homebrew/homebrew-php
brew install --with-openssl curl
brew install --with-homebrew-curl --with-apache php71
brew install php71-mcrypt php71-imagick
# 3. Follow these instructions to make Apache and php-cli use the newer php executable and make the change persist after reboot.
brew info php71
@tameemsafi
tameemsafi / feedback-url-new-params.js
Last active November 29, 2017 16:33
Replace old feedback URL params with new params
(function(document) {
// Object to store new query params,
// the current ones will be replaced,
// new ones will be added to the url
var newParams = {
'recall-ui': '',
'lambda-return-code': '',
'recall-outcome': '',
'recall-outcome-detail': '',
@tameemsafi
tameemsafi / generate-output-html-expressjs.js
Created December 4, 2017 12:49
Generate html output before rendering response with expressjs
function(err, html) {
let outputFolder = path.resolve('output');
// Check if folder does not exist
if ( !fs.existsSync(outputFolder) ) {
// Create folder
fs.mkdirSync(outputFolder);
}
// Write html output to file
@tameemsafi
tameemsafi / add-global-variables-to-nunjucks.js
Last active October 1, 2020 05:04
Adding global variables functions to nunjucks
// Create express server
const app = express();
// Create nunjucks fileloader instance for the views folder
const nunjucksFileLoader = new nunjucks.FileSystemLoader(path.resolve('/path/to/views/folder'), {
noCache: true,
});
// Create a nunjucks instance to be used for the view engine
// This instance can be used to add filters and globals
@tameemsafi
tameemsafi / nunjucks-import-all-macros-into-a-global-variable.njk
Created January 30, 2018 11:27
Nunjucks - Import all macros into a global variable
{# Import macros for global use in all views #}
{% set components = {} %}
{% for component in macroFilePaths %}
{% import component as temp %}{% set macro = _.assign(components, temp) %}
{% endfor %}
{# end #}
@tameemsafi
tameemsafi / nunjucks-example-macro.njk
Created January 30, 2018 11:31
Nunjucks - Example macro
{% macro button(text='', url=false, start=false, disabled=false) %}
{% set disabledCode = 'disabled="disabled" aria-disabled="true"' %}
{% if url %}
<a class="button {{ 'button-start' if start }}" href="{{ url }}" role="button">{{ text }}</a>
{% else %}
<input class="button" type="submit" value="{{ text }}" {{ disabledCode if disabled }}>
{% endif %}
{% endmacro %}
@tameemsafi
tameemsafi / nunjucks-example-usage-of-button-macro.njk
Created January 30, 2018 11:33
Nunjucks - Example usage of button macro
{{ components.button(text='Save and continue') }}
@tameemsafi
tameemsafi / gds-ie-specific-mixin.scss
Created January 30, 2018 11:48
GDS - IE Specific mixin
@mixin ie-lte($version) {
@if & {
.lte-ie#{$version} & {
@content;
}
} @else {
.lte-ie#{$version} {
@content;
}
}
@tameemsafi
tameemsafi / html-ie-conditional-markup.html
Created January 30, 2018 11:50
HTML - IE conditional markup
<!DOCTYPE html>
<!--[if lte IE 8 ]><html class="lte-ie8" lang="en"><![endif]-->
<!--[if IE 9 ]><html class="ie9" lang="en"><![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--><html class="" lang="en"><!--<![endif]-->