Skip to content

Instantly share code, notes, and snippets.

View ocmca's full-sized avatar

Owen McAlack ocmca

View GitHub Profile
@ocmca
ocmca / systemd-mkinitcpio.conf
Last active January 5, 2022 06:50 — forked from bjcubsfan/systemd-mkinitcpio.conf
backup with defaults
# vim:set ft=sh
# MODULES
# The following modules are loaded before any boot hooks are
# run. Advanced users may wish to specify all system modules
# in this array. For instance:
# MODULES=(piix ide_disk reiserfs)
MODULES=()
# BINARIES
# This setting includes any additional binaries a given user may
@ocmca
ocmca / send-mail-html-php
Last active October 19, 2016 06:07
PHP function for sending HTML emails
function sendEmail($to,$from,$subject,$message){
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Create email headers
$headers .= 'From: '.$from."\r\n".
'Reply-To: '.$from."\r\n" .
'X-Mailer: PHP/' . phpversion();
@ocmca
ocmca / jquery-scroll-to-top.js
Last active August 29, 2015 14:20
Function takes in an element to find the top of it's position, also the speed (in milliseconds) at which the scroll should occur. Defaults to the top of the document at a "slow" tempo.
var scrollToTop = function(el, speed) {
/**
* Function takes in the element to scroll to, as well as
* the speed in which the document should scroll animate to the top.
*
* Default is window top, and slow (respectively). Time (in milliseconds is allowed)
*/
"use strict";
var position;
@ocmca
ocmca / paypal-buynow-form.html
Created April 14, 2015 11:29
Sample Code for a Buy Now Button with a Buy One, Get One Free Discount The following sample HTML code uses the discount percentage variables to offer a "Buy one, get one free" discount. To receive the discount, the buyer must purchase 2 of the item; the 2nd one is free (100% discount). If the buyer purchases only 1 unit of the item, it is the fu…
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<!-- Identify your business so that you can collect the payments. -->
<input type="hidden" name="business" value="[email protected]">
<!-- Specify a Buy Now button. -->
<input type="hidden" name="cmd" value="_xclick">
<!-- Specify details about the item that buyers will purchase. -->
<input type="hidden" name="item_name" value="Hot Sauce-12 oz. Bottle">
(function( $ ) {
$.fn.showLinkLocation = function() {
this.filter( "a" ).each(function() {
var link = $( this );
link.append( " (" + link.attr( "href" ) + ")" );
});
return this;
};
@ocmca
ocmca / creditcard_filter.php
Last active April 3, 2023 17:06
returns a hyphenated creditcard number
// returns a hyphenated creditcard number
function creditCardFilter($str){
$new = str_replace('/\D+/g','',$str);
return chunk_split($new,4,'-');
}
@ocmca
ocmca / print_r_pre.php
Last active August 29, 2015 14:17
Surround print_r with <pre></pre>
function pretty($printThis)
{
print("<pre>");
print_r($printThis);
print("</pre>");
}
@ocmca
ocmca / object_size.js
Last active August 29, 2015 14:17
add .size() method to object that return the size.
Object.size = function(obj) {
var size = 0, key;
for (key in obj) {
if (obj.hasOwnProperty(key)) size++;
}
return size;
};