Skip to content

Instantly share code, notes, and snippets.

@flacodirt
flacodirt / datetimeConvert
Last active December 14, 2015 22:58
Datetime conversion methods. Convert server datetime to UTC and convert UTC to server datetime.
/**
* Datetime conversion methods. Convert server datetime to UTC and convert UTC to server datetime.
* @author https://gist.github.com/dirte/
* @version 1.0.1
* @category DateTime
*/
/**
* datetimeConvertServerToUTC
*
@flacodirt
flacodirt / gist:5237180
Created March 25, 2013 13:41
Credit card validation regular expressions
/**
* Credit card validation regular expressions
*/
# American Express
/^3[47]/
# Visa
/^4/
@flacodirt
flacodirt / gist:5237195
Created March 25, 2013 13:43
Credit card verification luhn checksum method
/**
* Credit card verification luhn checksum method
*/
function validateLuhnChecksum(cardNumber) {
if (cardNumber == 0) { return false; }
var sum = 0;
var mul = 1;
for (var x = cardNumber.length; x > 0 ; x--) {
var tproduct = parseInt(cardNumber.charAt(x - 1), 10) * mul;
if (tproduct >= 10) {
@flacodirt
flacodirt / .vimrc
Last active December 15, 2015 10:19
Custom vimrc options file
syntax on
set background=dark " easy on the eyes
set ruler " show the line number on the bar
set more " use more prompt
set autoread " watch for file changes
set number " line numbers
set hidden
set noautowrite " don't automagically write on :next
set lazyredraw " don't redraw when don't have to
set showmode
@flacodirt
flacodirt / mysql_comment.markdown
Last active December 15, 2015 11:08 — forked from MadaraUchiha/mysql_comment.markdown
A little lighter, friendlier and more to the point.
@flacodirt
flacodirt / getPassphraseHash
Last active December 15, 2015 17:09
Gets hash of provided plaintext passphrase using crypt
/**
* getPassphraseHash
*
* Gets hash of provided plaintext passphrase using crypt
*
* @author https://gist.github.com/dirte
* @var string $rounds If supported, the number of rounds to loop the hash which increases security
* @var string $algo Crypt algorithm
* @var string $salt Uniqid with more entropy
* @var string $cryptSalt Salt to use in crypt
@flacodirt
flacodirt / authenticatePassphrase
Created April 2, 2013 18:10
Authenticate user provided passphrase against previously stored passphrase hash
/**
* authenticatePassphrase
*
* Authenticate user provided passphrase against previously stored passphrase hash
*
* @author https://gist.github.com/dirte
* @access public
* @param string $frmPassphrase
* @param string $dbPassphrase
* @return boolean
@flacodirt
flacodirt / codingStandardsPEAR.md
Last active December 15, 2015 18:09
Coding Standards from PEAR in quick-reference format

Coding Standards from PEAR in quick-reference format

Indenting and Line Length

  • Use an indent of 4 spaces, with no tabs
  • Line length of 75-85 characters

Control Structures

  • Control statements should have one space between the control keyword and opening parenthesis.
  • Example: if (condition) {
@flacodirt
flacodirt / .gitignore
Last active December 15, 2015 20:09
My gitignore file. Geared towards LAMP environment but also includes common Windows and Dreamweaver ignores.
# Logs
*.log
*_log
# Backups
*.bak
*.7z
*.bz2
*.gz
*.tar
@flacodirt
flacodirt / provision_centos_server.sh
Last active January 17, 2022 07:00
CentOS 6.x LAMP Server Provisioning Script
#!/bin/bash
clear
clear
echo '#'
echo '# CentOS 6.x LAMP Server Provisioning Script'
echo '#'
echo '# This script will guide you through the initial server provisioning for a standard CentOS 6.x LAMP server.'
echo '# The basic provisioning tasks to be ran immediately after provisioning are fully automated with user prompts.'
echo '# The rest of the script is for copy/paste reference to pick/choose as desired.'
echo '#'