Skip to content

Instantly share code, notes, and snippets.

@scottsweb
scottsweb / gravity-forms-validation.php
Last active March 11, 2024 10:22
Using a Gravity Forms filter to create a custom validation and check for existing UID in already saved entries.
<?php
/***************************************************************
* Function media_custom_validation
* Check the media form for duplicate inputs on the same day
***************************************************************/
add_filter('gform_validation', 'media_custom_validation');
function media_custom_validation($validation_result) {
@scottsweb
scottsweb / eu.php
Last active November 21, 2022 00:44
An array of EU country codes.
<?php
$eu_countries = array(
"AT" => "Austria",
"BE" => "Belgium",
"BG" => "Bulgaria",
"HR" => "Croatia",
"CY" => "Cyprus",
"CZ" => "Czech Republic",
"DK" => "Denmark",
@scottsweb
scottsweb / dashicons.php
Last active July 6, 2017 08:53
An array of the WordPress dashicons http://melchoyce.github.io/dashicons/.
<?php
$icons = array(
'menu-icon-dashicons-menu' => __('Menu', 'iconic'),
'menu-icon-dashicons-dashboard' => __('Dashboard', 'iconic'),
'menu-icon-dashicons-admin-site' => __('Admin Site', 'iconic'),
'menu-icon-dashicons-admin-media' => __('Admin Media', 'iconic'),
'menu-icon-dashicons-admin-page' => __('Admin Page', 'iconic'),
'menu-icon-dashicons-admin-comments' => __('Admin Comments', 'iconic'),
'menu-icon-dashicons-admin-appearance' => __('Admin Appearance', 'iconic'),
@scottsweb
scottsweb / photobooth
Created February 21, 2016 09:44
init.d script for Photobooth
#!/bin/bash
### BEGIN INIT INFO
# Provides: photobooth
# Required-Start: $local_fs
# Required-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start or stop the photobooth server
### END INIT INFO
@scottsweb
scottsweb / unicorn
Last active August 31, 2015 20:07
init.d script for Unicorn Hat (Python script as root)
#!/bin/bash
### BEGIN INIT INFO
# Provides: unicorn
# Required-Start: $local_fs $remote_fs $network
# Required-Stop: $local_fs $remote_fs $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start or stop the unicorn hat server
### END INIT INFO
@scottsweb
scottsweb / node-red
Last active August 31, 2015 20:03
init.d script for Node-RED
#!/bin/bash
### BEGIN INIT INFO
# Provides: node-red
# Required-Start: $local_fs $remote_fs $network
# Required-Stop: $local_fs $remote_fs $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start or stop the node-red server
### END INIT INFO
@scottsweb
scottsweb / gmail.py
Last active August 29, 2015 14:04
Send Email via Gmail with Python
#!/usr/bin/python
import argparse
import os
import smtplib
from smtplib import SMTP_SSL
from email.mime.multipart import MIMEMultipart
from email.mime.base import MIMEBase
from email.mime.text import MIMEText
from email import encoders