Skip to content

Instantly share code, notes, and snippets.

Avatar

Matthew Ephraums mephraums

  • Melbourne, Australia
View GitHub Profile
View gist:11160562
<html>
<head>
<title>Hello World</title>
</head>
<body>
<h1>Hello World</h1>
View Switch from http to https
<script>
/* Create an anonymous function */
(function() {
/* 1. Define default protocol */
protocolToUse = "http";
/* 2. Identify current page protocol */
currentProtocol = doc.loc.protocol;
View endpoints.php
<?php
/*
Plugin Name: WP_Rewrite endpoints demo
Description: A plugin giving example usage of the WP_Rewrite endpoint API
Plugin URI: http://make.wordpress.org/plugins/2012/06/07/rewrite-endpoints-api/
Author: Jon Cave
Author URI: http://joncave.co.uk/
*/
function makeplugins_endpoints_add_endpoint() {
@mephraums
mephraums / gist:6409156
Last active Dec 22, 2015
Javascript - Format Number to Currency
View gist:6409156
//http://stackoverflow.com/questions/149055/how-can-i-format-numbers-as-money-in-javascript
Number.prototype.formatMoney = function(c, d, t){
var n = this,
c = isNaN(c = Math.abs(c)) ? 2 : c,
d = d == undefined ? "." : d,
t = t == undefined ? "," : t,
s = n < 0 ? "-" : "",
i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "",
j = (j = i.length) > 3 ? j % 3 : 0;
return '$' + s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : "");
@mephraums
mephraums / gist:6445607
Last active Dec 22, 2015
Javascript - URL Params Anonymous function Object
View gist:6445607
var urlParams = {};
(function() {
var match,
pl = /\+/g, // Regex for replacing addition symbol with a space
search = /([^&=]+)=?([^&]*)/g,
decode = function (s) { return decodeURIComponent(s.replace(pl, " ")); },
query = window.location.search.substring(1).toLowerCase();
while (match = search.exec(query))
View OpenWithSublimeText2.bat
@echo off
SET st2Path=C:\Program Files\Sublime Text 2\sublime_text.exe
rem add it for all file types
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 2" /t REG_SZ /v "" /d "Open with Sublime Text 2" /f
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 2" /t REG_EXPAND_SZ /v "Icon" /d "%st2Path%,0" /f
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 2\command" /t REG_SZ /v "" /d "%st2Path% \"%%1\"" /f
rem add it for folders
@reg add "HKEY_CLASSES_ROOT\Folder\shell\Open with Sublime Text 2" /t REG_SZ /v "" /d "Open with Sublime Text 2" /f
@mephraums
mephraums / gist:6893666
Last active Dec 25, 2015
jQuery Change Element Type (jQuery Plugin)
View gist:6893666
//Change Element Type plugin
//Source: http://stackoverflow.com/questions/8584098/how-to-change-an-element-type-using-jquery
$.fn.changeElementType = function(newType) {
var newElements = [];
$(this).each(function() {
var attrs = {};
$.each(this.attributes, function(idx, attr) {
attrs[attr.nodeName] = attr.nodeValue;
View gist:7149480
function roundUp(number, digits)
{
var factor = Math.pow(10,digits);
return Math.ceil(number*factor) / factor
}
@mephraums
mephraums / gist:8396494
Created Jan 13, 2014
Code for logging events on an object
View gist:8396494
$obj = $('input');
function getEventsList($obj) {
var ev = new Array(),
events = $obj.data('events'),
i;
for(i in events) { ev.push(i); }
return ev.join(' ');
}
@mephraums
mephraums / certificate-expiry.sh
Last active Feb 10, 2020
Check list of domains and output text file with certificate expiry dates
View certificate-expiry.sh
#!/bin/bash
input="domains.txt" #text file with each domain on a new line
output="expiry.txt" #where the result should be written to
echo -n "" > $output
while read line; do
domain=$line
dates=$(echo | openssl s_client -servername $domain -connect $domain:443 2>/dev/null | openssl x509 -noout -dates)