Skip to content

Instantly share code, notes, and snippets.

View wpsmith's full-sized avatar

Travis Smith wpsmith

View GitHub Profile
@wpsmith
wpsmith / articulate-email.js
Created March 22, 2013 13:34
Creates New Email with To, Subject, and basic body text.
var player = GetPlayer();
var email = player.GetVar("ManagerEmail");
var name = player.GetVar("Name");
var texto = player.GetVar("Commitment") + "\n";
var subject = "My Corporate Responsibility Commitment";
var body_start = "Dear Manager,\n" + name + " has sent you his/her Corporate Responsibility Commitment:\n";
var body_end = "Please discuss this commitment with " + name + "\n";
var mailto_link = 'mailto:' + email + '?subject=' + subject + '&body=' + encodeURIComponent(body_start + texto + body_end);
win = window.open(mailto_link, 'emailWin');
@wpsmith
wpsmith / browser-language-codes.js
Last active November 8, 2024 14:47
JS: Object of Browser Language Codes
// <![CDATA[
var langCodes = {
"af": "Afrikaans",
"sq": "Albanian",
"an": "Aragonese",
"ar": "Arabic (Standard)",
"ar-dz": "Arabic (Algeria)",
"ar-bh": "Arabic (Bahrain)",
"ar-eg": "Arabic (Egypt)",
"ar-iq": "Arabic (Iraq)",
@wpsmith
wpsmith / gs-change-registered-cpt-init.php
Last active September 5, 2024 01:41
PHP: Register Custom Post Type
<?php
add_action( 'init', 'gs_books_label_rename', 999 );
/**
* Modify registered post type menu label
*
*/
function gs_books_label_rename() {
global $wp_post_types;
$wp_post_types['gs_books']->labels->menu_name = __( 'Books', 'gs_books' );
@wpsmith
wpsmith / Export-SpSearchManagedProperties.ps1
Created April 2, 2015 16:29
PowerShell - This script will export Managed and Crawled Properties from SharePoint 2010 Enterprise Search. I have used this during our migration to FAST Enterprise Search.
#------------------------------------------------------------------------------------------------------
# Name: Export-SpSearchManagedProperties.ps1
# Description: This script will export create Crawled and Managed Properties from Enterprise Search
#
# Usage: Run the function with a required parameters
# By: Ivan Josipovic, Softlanding.ca
#------------------------------------------------------------------------------------------------------
Function Export-SpSearchManagedProperties([string]$SearchServiceApp,[string]$filename){
#Use This to ignore the out of the box managed properties
$IgnoreMappings = @("AboutMe","Account","AccountName","AssignedTo","Author","BaseOfficeLocation","BestBetKeywords","CategoryNavigationUrl","CollapsingStatus","Colleagues","contentclass","ContentsHidden","ContentSource","ContentType","CreatedBy","Department","Description","DisplayDate","DocComments","DocId","DocKeywords","DocSignature","DocSubject","DuplicateHash","EMail",
@wpsmith
wpsmith / get-cookie.js
Created July 5, 2015 21:50
JavaScript: Get Cookie By Name
@wpsmith
wpsmith / font-mimetypes
Last active April 25, 2024 00:44 — forked from localpcguy/font-mimetypes
Mime Types for .htaccess or web.config
.eot - application/vnd.ms-fontobject
.woff - application/font-woff
.ttf - application/x-font-truetype
.svg - image/svg+xml
.otf - application/x-font-opentype
IIS (Web.Config)
<remove fileExtension=".eot" />
<mimeMap fileExtension=".eot" mimeType="application/vnd.ms-fontobject" />
<remove fileExtension=".ttf" />
@wpsmith
wpsmith / Microsoft.PowerShell_profile.ps1
Created July 15, 2015 13:17
PowerShell: Profile to always launch PS as Administrator, set Aliases (ex. Notepad++), Import SharePoint Online, Azure AD, and Azure Services.
# Check if Running as Admin
$IsAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")
if (-not $IsAdmin)
{
if ($MyInvocation.ScriptName -ne "")
{
try
{
Write-Host "Relanuching Script as Admin"
@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 );
@wpsmith
wpsmith / Get-AvailableExceptionsList.ps1
Created April 16, 2015 14:09
PowerShell: Retrieves all available Exceptions to construct ErrorRecord objects.
<#
.Synopsis
Retrieves all available Exceptions to construct ErrorRecord objects.
.Description
Retrieves all available Exceptions in the current session to construct ErrorRecord objects.
.Example
$availableExceptions = Get-AvailableExceptionsList
@wpsmith
wpsmith / New-ErrorRecord.ps1
Created April 16, 2015 14:16
PowerShell: Creates an custom ErrorRecord that can be used to report a terminating or non-terminating error.
<#
.Synopsis
Creates an custom ErrorRecord that can be used to report a terminating or non-terminating error.
.Description
Creates an custom ErrorRecord that can be used to report a terminating or non-terminating error.
.Parameter Exception
The Exception that will be associated with the ErrorRecord.