Skip to content

Instantly share code, notes, and snippets.

View andrewjcurrie's full-sized avatar

Andrew Currie andrewjcurrie

View GitHub Profile
@andrewjcurrie
andrewjcurrie / pi.multiply.php
Last active August 29, 2015 14:04
Multiplication Plugin for ExpressionEngine 2
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
$plugin_info = array(
'pi_name' => 'Multiplication',
'pi_version' => '1.0',
'pi_author' => 'Andrew Currie',
'pi_author_url' => 'https://www.digitalpci.com',
'pi_description' => 'Multiply numbers delimited by |',
'pi_usage' => Multiply::usage()
);
@andrewjcurrie
andrewjcurrie / total.hours.js
Last active August 29, 2015 14:16
Total Hours from 2 EE Time Select Fields
<script type="text/javascript">
$(function() {
$('#arrival_hour, #arrival_minutes, #arrival_noon, #departure_hour, #departure_minutes, #departure_noon').on('change', function(event) {
var arrival_hour = $('#arrival_hour').val();
var arrival_minute = $('#arrival_minutes').val();
var departure_hour = $('#departure_hour').val();
var departure_minute = $('#departure_minutes').val();
if (arrival_hour && arrival_minute && departure_hour && departure_minute) {
@andrewjcurrie
andrewjcurrie / website.backup.sh
Last active July 11, 2022 05:00
Website Backup Shell Script
#!/bin/bash
#
# Website Backup Shell Script
# by Andrew Currie (andrew@digitalpci.com)
#
# Performs a full backup of the specified database and document root.
# Be sure to edit the configuration options at the beginning of the file to match your environment prior to executing.
# The end result will be one TAR archive with the name 'website-backup-(current-datestamp)'.
# The backup includes the entire document root directory and also a 'database.sql' file containing a MySQL dump of the database.
#
@andrewjcurrie
andrewjcurrie / launch_sublime_from_terminal.markdown
Created September 9, 2016 04:03 — forked from olivierlacan/launch_sublime_from_terminal.markdown
Launch Sublime Text 2 from the Mac OS X Terminal

Launch Sublime Text 2 from the Mac OS X Terminal

Sublime Text 2 ships with a CLI called subl (why not "sublime", go figure). This utility is hidden in the following folder (assuming you installed Sublime in /Applications like normal folk. If this following line opens Sublime Text for you, then bingo, you're ready.

open /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl

You can find more (official) details about subl here: http://www.sublimetext.com/docs/2/osx_command_line.html

Installation

var product_classes = ['auto','mortgage','home+equity','credit+card','boat','rv','money+market','savings','checking','cd','ira'];
var market_ids = ['16970'];
var market_names = ['Saint Louis Metro'];
var default_mkt_id = 16970;
var api_key = "d5c57ba3-1831-4533-9f01-ab671bac2579";
var fileUrl = "https://api.datatrac.net/api/Thresholds.json?MarketID=" + market_ids.toString() + "&ProductClass=" + product_classes.toString() + "&ApiKey=" + api_key;
/* ------- smooth scrolling ----- */
$(function() {
"use strict";
@andrewjcurrie
andrewjcurrie / datatrac-home.js
Created May 22, 2019 20:29
datatrac-home.js
var product_classes = ['checking'];
var market_ids = [16970];
var market_names = {};
var default_mkt_id = 16970;
var api_key = "d5c57ba3-1831-4533-9f01-ab671bac2579";
var fileUrl = "https://api.datatrac.net/api/Thresholds.json?MarketID=" + market_ids.toString() + "&ProductClass=" + product_classes.toString() + "&ApiKey=" + api_key;
$(window).load(function(){
"use strict";
@andrewjcurrie
andrewjcurrie / .htaccess
Last active May 10, 2023 00:22
Remove PHP Extension
# HTACCESS for Apache
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php [NC,L]
# NGINX Configuration
server {
index index.php;
location ~ \.php$ {
if ($request_uri ~ ^/([^?]*)\.php($|\?)) { return 302 /$1?$args; }
@andrewjcurrie
andrewjcurrie / index.html
Created May 10, 2023 00:21
IPv4 Address Validator
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JavaScript IPv4 Address Validator</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body onload='document.ipform.ipaddr.focus()'>
<div class="container">
<h2>Enter an IP address then click 'Validate'</h2>
@andrewjcurrie
andrewjcurrie / validator.js
Created May 10, 2023 00:24
IPv4 Address Validator
function ValidateIPaddress(inputText) {
var ipformat = /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;
if (inputText.value.match(ipformat)) {
alert("You entered a valid IPv4 address.");
document.ipform.ipaddr.focus();
return false;
} else {
alert("You entered an invalid IPv4 address.");
document.ipform.ipaddr.focus();
@andrewjcurrie
andrewjcurrie / style.css
Created May 10, 2023 00:25
IPv4 Address Validator
@import url('https://fonts.googleapis.com/css?family=Roboto&display=swap');
body, p, h1, h2, li, input {
font-family: 'Roboto', sans-serif;
}
h2 {
color: #FFF;
}