Skip to content

Instantly share code, notes, and snippets.

@niro1987
niro1987 / zha_ikea_tradfri_5button_remote_color.yaml
Last active January 30, 2022 01:04
Home Assistant - Blueprint - ZHA - IKEA TRADFRI - 5 Button Remote - Color Lights
---
# This automation simulates the use of the IKEA TRADFRI Remote control
# connected through ZHA.
# | Button | Action |
# | -------- | ------------------- |
# | Power | Toggle the light |
# | Dim-Up | Increase brightness |
# | Dim-Down | Decrease brightness |
# | Right | Change color |
@MatthieuScarset
MatthieuScarset / .lando.yml
Last active January 4, 2024 15:03
Correct settings for XDebug + VSCode + Lando (+3.0)
# Lando version is at least +3.0
name: drupal-nine
recipe: drupal9
services:
appserver:
webroot: web
xdebug: debug
config:
php: .vscode/php.ini
@daggerhart
daggerhart / wp-get-taxonomy-hierarchy.php
Last active December 18, 2022 03:22
WordPress function to get a complete taxonomy hierarchy of terms in PHP
<?php
/**
* Recursively get taxonomy and its children
*
* @param string $taxonomy
* @param int $parent - parent term id
* @return array
*/
function get_taxonomy_hierarchy( $taxonomy, $parent = 0 ) {
@saltnpixels
saltnpixels / save_upload_field_to_custom_field.php
Last active January 18, 2024 20:32
gravity form upload file to media library and use attachment ID in custom field
add_action( 'gform_after_create_post', 'gf_add_to_media_library', 10, 3 );
/**
* Save file upload fields under custom post field to the library
*
* @param $post_id The post identifier
* @param $entry The entry
* @param $form The form
*/
<?php
/*
Plugin Name: Programmatically add Gravity Forms
Plugin URI: https://daan.kortenba.ch/programmatically-add-gravity-forms/
Description: Programmatically add persistent Gravity Forms forms.
Author: Daan Kortenbach
Version: 0.1
Author URI: https://daan.kortenba.ch/
License: GPLv2 or later
*/
@cmbaughman
cmbaughman / sf_to_wp_sso.md
Created May 1, 2015 19:00
Set up Salesforce as an Identity Provider for Single Sign On with Wordpress

##Wordpress Side:

  1. On WP install the plugin SAML 2.0 Single Sign-On

  2. Once installed, copy and paste into an email the section “Your SAML Info”

  3. Make sure to check only the box labeled ‘Allow SSO Bypass’.

  4. Click Service Provider tab and put a check in the “Generate new certificate and private key for me.” then click update at the bottom of the page.

@wh1tney
wh1tney / deploy-static-site-heroku.md
Last active June 24, 2024 20:17
How to deploy a static website to Heroku

Gist

This is a quick tutorial explaining how to get a static website hosted on Heroku.

Why do this?

Heroku hosts apps on the internet, not static websites. To get it to run your static portfolio, personal blog, etc., you need to trick Heroku into thinking your website is a PHP app. This 6-step tutorial will teach you how.

Basic Assumptions

@wpsmith
wpsmith / sanitize_phone.php
Created June 5, 2014 17:00
PHP: Sanitize & Format US Phone Numbers
<?php
function sanitize_phone( $phone, $international = false ) {
$format = "/(?:(?:\+?1\s*(?:[.-]\s*)?)?(?:\(\s*([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9])\s*\)|([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9]))\s*(?:[.-]\s*)?)?([2-9]1[02-9]|[2-9][02-9]1|[2-9][02-9]{2})\s*(?:[.-]\s*)?([0-9]{4})(?:\s*(?:#|x\.?|ext\.?|extension)\s*(\d+))?$/";
$alt_format = '/^(\+\s*)?((0{0,2}1{1,3}[^\d]+)?\(?\s*([2-9][0-9]{2})\s*[^\d]?\s*([2-9][0-9]{2})\s*[^\d]?\s*([\d]{4})){1}(\s*([[:alpha:]#][^\d]*\d.*))?$/';
// Trim & Clean extension
$phone = trim( $phone );
$phone = preg_replace( '/\s+(#|x|ext(ension)?)\.?:?\s*(\d+)/', ' ext \3', $phone );
// Check if IE8 or lower
isOldIE: document.documentElement.className.search('old-ie') >= 0,
// Force IE8 to redraw :before/:after pseudo elements
// http://stackoverflow.com/questions/9809351/
redrawPseudoEls: function() {
var self = this;
if ( self.isOldIE ) {
console.log('redraw pseudo elements');
var head = document.getElementsByTagName('head')[0],
@freshyill
freshyill / Keyframe Animation Mixin
Created September 28, 2012 14:34
A simple mixin to create keyframe animation. Bourbon doesn't currently have a mixin for this. Requires SASS 3.2
// Mixin
@mixin keyframes($name) {
@-moz-keyframes #{$name} { @content; }
@-webkit-keyframes #{$name} { @content; }
@-o-keyframes #{$name} { @content; }
@-ms-keyframes #{$name} { @content; }
@-khtml-keyframes #{$name} { @content; }
@keyframes #{$name} { @content; }
}