Skip to content

Instantly share code, notes, and snippets.

@alex-gist
alex-gist / text.php
Created May 8, 2012 17:13
PHP-open|close-tags
<?php ?>
@alex-gist
alex-gist / usa50StateDropDown
Created March 26, 2012 18:11
HTML: USA 50 State Drop Down
<select name="state">
<option value="AL">AL</option>
<option value="AK">AK</option>
<option value="AZ">AZ</option>
<option value="AR">AR</option>
<option value="CA">CA</option>
<option value="CO">CO</option>
<option value="CT">CT</option>
<option value="DE">DE</option>
<option value="DC">DC</option>
@alex-gist
alex-gist / gist:2165082
Created March 22, 2012 22:22
REGEX: Select string between to end points
will select all strings between tart_tag & end_tag
(?<=start_tag)(.*)(?=end_tag)
@alex-gist
alex-gist / htaccess_php_security
Created March 22, 2012 16:30
HTACCESS: PHP Security
#HTACCESS Secure PHP Setting#
#############################
# Disable register globals
php_flag register_globals 0
# Disable magic quotes
php_flag magic_quotes_gpc 0
php_flag magic_quotes_runtime 0
@alex-gist
alex-gist / gist:2127401
Created March 19, 2012 21:51
REGEX: only select single \n
\n(?!\n)
@alex-gist
alex-gist / capitalize_while_inputting.js
Created March 12, 2012 23:03
jQuery: Capitalize first letter while typing inside input field
<script type="text/javascript" charset="utf-8">
//Capitalize first letter while typing in side of input field
jQuery(document).ready(function($) {
$('#selector').keyup(function(event) {
var textBox = event.target;
var start = textBox.selectionStart;
var end = textBox.selectionEnd;
textBox.value = textBox.value.charAt(0).toUpperCase() + textBox.value.slice(1);
textBox.setSelectionRange(start, end);
});
@alex-gist
alex-gist / gist:2023275
Created March 12, 2012 16:47 — forked from shreyas-satish/gist:1381897
JavaScript: Date validator
function isValidDate(date) {
var matches = /^(\d{2})[-\/](\d{2})[-\/](\d{4})$/.exec(date);
if (matches == null) return false;
var d = matches[1];
var m = matches[2] - 1;
var y = matches[3];
var composedDate = new Date(y, m, d);
return composedDate.getDate() == d && composedDate.getMonth() == m && composedDate.getFullYear() == y;
}
@alex-gist
alex-gist / dateExtend.js
Created March 12, 2012 16:47 — forked from rwbaker/dateExtend.js
JavaScript: Extend JavaScript Date
//Extend Date to have a few extra fatures
Date.dayNames = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
Date.monthNames = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
Date.prototype.dayNames = Date.dayNames;
Date.prototype.monthNames = Date.monthNames;
Date.prototype.getDayName = function() {
return this.dayNames[this.getDay()];
};
Date.prototype.getDayNameAbbr = function() {
@alex-gist
alex-gist / Date.js
Created March 12, 2012 16:46 — forked from jsmecham/Date.js
JavaScript: Date Formatter
/**
* Date#strftime(format) -> String
*
* - format (String): the format string
*
* Formats the *date* according to the directives given in the *format*
* string. Requires a String#interpolate() extension.
*
* ## Format Components
*
@alex-gist
alex-gist / boilerplate.html
Created March 12, 2012 16:40
HTML: Starter Boilerplate (HTML 5)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>HTML5 boilerplate—all you really need…</title>
<link rel="stylesheet" type="text/css" href="css/style.css" />
<!--[if IE]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>