Skip to content

Instantly share code, notes, and snippets.

View mephraums's full-sized avatar

Matthew Ephraums mephraums

  • Melbourne, Australia
View GitHub Profile
@mephraums
mephraums / certificate-expiry.sh
Last active February 10, 2020 21:38
Check list of domains and output text file with certificate expiry dates
#!/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)
@mephraums
mephraums / gist:8396494
Created January 13, 2014 08:20
Code for logging events on an object
$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 / gist:7149480
Created October 25, 2013 04:34
Roundup Function
function roundUp(number, digits)
{
var factor = Math.pow(10,digits);
return Math.ceil(number*factor) / factor
}
@mephraums
mephraums / gist:6893666
Last active December 25, 2015 01:19
jQuery Change Element Type (jQuery Plugin)
//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;
@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:6445607
Last active December 22, 2015 08:29
Javascript - URL Params Anonymous function Object
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))
@mephraums
mephraums / gist:6409156
Last active December 22, 2015 03:18
Javascript - Format Number to Currency
//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) : "");
<?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() {
<script>
/* Create an anonymous function */
(function() {
/* 1. Define default protocol */
protocolToUse = "http";
/* 2. Identify current page protocol */
currentProtocol = doc.loc.protocol;
@mephraums
mephraums / gist:11160562
Created April 21, 2014 23:52
Sprite Checker
<html>
<head>
<title>Hello World</title>
</head>
<body>
<h1>Hello World</h1>