Skip to content

Instantly share code, notes, and snippets.

View DavidEngland's full-sized avatar

Dave England DavidEngland

View GitHub Profile
@DavidEngland
DavidEngland / misc.php
Created June 6, 2024 19:13
Various PHP string utils
<?php
/**
* Wraps a given string with a specified HTML tag and optional attributes.
*
* @param string $tag The HTML tag to wrap the string with.
* @param string $str The string to be wrapped.
* @param array $attributes Optional attributes to be added to the tag.
* @return string The wrapped string.
* @throws Exception If either the tag or the string is not a string.
*/
@DavidEngland
DavidEngland / captializeString.js
Created June 6, 2024 18:38
Capitalizes the first letter of each word in a string, with exceptions for certain words and prefixes. This function is particularly useful for formatting names and addresses.
/**
* Capitalizes the first letter of each word in a string, with exceptions for certain words and prefixes.
* This function is particularly useful for formatting names and addresses.
*
* @param {string} input The input string to be capitalized.
* @param {boolean} isName Optional. Specifies whether the input string is a name. Default is true.
* @returns {string} The capitalized string.
*/
function capitalizeString(input, isName = true) {
const str = input.trim();
@DavidEngland
DavidEngland / resume.json
Last active January 9, 2024 22:22
registry jasonresume.org resume in json data format
{
"basics": {
"name": "David England",
"summary": "Very versatile worker with extensive experience in many diverse areas. Able to adapt to almost any work environment. Especially enjoy working with data, programming and statistics.",
"website": "http://about.me/DavidEngland",
"email": "DavidEEngland@Outlook.com",
"picture": "data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20xmlns%3Axlink%3D%22http%3A%2F%2Fwww.w3.org%2F1999%2Fxlink%22%20width%3D%22508.834%22%20height%3D%22508.834%22%20viewBox%3D%220%200%20134.62898%20134.62898%22%3E%3Ctitle%3EDavid%20England%3C%2Ftitle%3E%3Cg%20transform%3D%22translate%28-149.644%20-194.156%29%22%3E%3Cimage%20y%3D%22194.156%22%20x%3D%22149.644%22%20xlink%3Ahref%3D%22data%3Aimage%2Fpng%3Bbase64%2CiVBORw0KGgoAAAANSUhEUgAAAJYAAACWCAYAAAA8AXHiAAAABHNCSVQICAgIfAhkiAAAIABJREFU%20eJzMvVmTJMmR5%2FdTM%2FMrIvKqzDq7G2gAMwPO7K6s8BCuUIQUfkO%2B8jPwnY8UfoTlkntygMFgBphG%20o6%2BqyiPCDzNTPpiZu0dkVh%2BDnuVaS3VGePht6qp%2F%2FevhAq3yJw05%2BW4%2B8
@DavidEngland
DavidEngland / functions.php
Created March 15, 2018 22:37 — forked from JoeHana/functions.php
WPCasa: Add custom details
<?php
/**
* Add custom detail
*
* @see wp-content/plugins/wpcasa/includes/class-wpsight-general.php
*/
add_filter( 'wpsight_details', 'custom_details', 50 );
@DavidEngland
DavidEngland / string-to-slug.js
Created February 28, 2018 02:37 — forked from spyesx/string-to-slug.js
String to slug in JS (wordpress sanitize_title)
var string_to_slug = function (str)
{
str = str.replace(/^\s+|\s+$/g, ''); // trim
str = str.toLowerCase();
// remove accents, swap ñ for n, etc
var from = "àáäâèéëêìíïîòóöôùúüûñç·/_,:;";
var to = "aaaaeeeeiiiioooouuuunc------";
for (var i=0, l=from.length ; i<l ; i++)
@DavidEngland
DavidEngland / example.php
Created June 14, 2017 15:46
General function for sharing webpage on social medias. Pass name of the social media you want to share webpage on, or if you want to share a specific page from webpage then pass the url as 2nd argument. See examples for clarification.
<?php
echo "<h3>Share current page</h3>";
echo '<a href="" class="" ' . socialLink( 'facebook' ) . '>Share on Facebook</a><br/>';
echo '<a href="" class="" ' . socialLink( 'twitter' ) . '>Share on Twitter</a><br/>';
echo '<a href="" class="" ' . socialLink( 'google' ) . '>Share on Google</a><br/>';
echo "<h3>Share specific url</h3>";
echo '<a href="" class="" ' . socialLink( 'facebook', 'www.worthers.com' ) . '>Share on Facebook</a><br/>';
echo '<a href="" class="" ' . socialLink( 'twitter' , 'www.worthers.com' ) . '>Share on Twitter</a><br/>';
@DavidEngland
DavidEngland / gist:e8a911c25992cb8723d64fc5c5171845
Created June 14, 2017 15:44 — forked from ebinnion/gist:5095189
Facebook centered pop up share
<script type="text/javascript">
function fbs_click(width, height) {
var leftPosition, topPosition;
//Allow for borders.
leftPosition = (window.screen.width / 2) - ((width / 2) + 10);
//Allow for title and status bars.
topPosition = (window.screen.height / 2) - ((height / 2) + 50);
var windowFeatures = "status=no,height=" + height + ",width=" + width + ",resizable=yes,left=" + leftPosition + ",top=" + topPosition + ",screenX=" + leftPosition + ",screenY=" + topPosition + ",toolbar=no,menubar=no,scrollbars=no,location=no,directories=no";
u=location.href;
t=document.title;
$(document).ready(function() {
$('.story-small img').each(function() {
var maxWidth = 100; // Max width for the image
var maxHeight = 100; // Max height for the image
var ratio = 0; // Used for aspect ratio
var width = $(this).width(); // Current image width
var height = $(this).height(); // Current image height
// Check if the current width is larger than the max
if(width > maxWidth){
ul.bar
list-style: none
margin: 0
padding: 0
li
display: inline
&:after
content: " |"
&:last-child:after
content: ""
@DavidEngland
DavidEngland / social_colors
Created May 17, 2017 19:12
social colors
/*
Source largely from: http://www.flatui.net/social-colors/
Enjoy this little pack. Find a derp or addition? Report it:
https://github.com/connor4312/social-colors
MIT license.
*/
$social-behance: #053eff;
$social-delicious: #205cc0;