Skip to content

Instantly share code, notes, and snippets.

View ixzy24's full-sized avatar
🏠
Working from home

Fahudh Haneef ixzy24

🏠
Working from home
View GitHub Profile
@ixzy24
ixzy24 / .htaccess
Created June 3, 2012 13:24
Force www on .htaccess
# force www in url
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.example\.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
# END force www in url
@ixzy24
ixzy24 / gist:2863484
Created June 3, 2012 13:27
CSS test page
<!-- Sample Content to Plugin to Template -->
<h1>CSS Basic Elements</h1>
<p>The purpose of this HTML is to help determine what default settings are with CSS and to make sure that all possible HTML Elements are included in this HTML so as to not miss any possible Elements when designing a site.</p>
<hr />
<h1 id="headings">Headings</h1>
<h1>Heading 1</h1>
@ixzy24
ixzy24 / detection.js
Created June 3, 2012 13:30
JavaScript browser detection
// Browser detection
// Internet Explorer
var ie = document.all != null; //ie4 and above
var ie5 = document.getElementById && document.all;
var ie6 = document.getElementById && document.all&&(navigator.appVersion.indexOf("MSIE 6.")>=0);
// Netscape
var ns4 = document.layers != null;
var ns6 = document.getElementById && !document.all;
@ixzy24
ixzy24 / gist:2863518
Created June 3, 2012 13:32
email validation in PHP
<?php
function is_valid_email($email)
{
if(preg_match("/[a-zA-Z0-9_-.+]+@[a-zA-Z0-9-]+.[a-zA-Z]+/", $email) > 0)
return true;
else
return false;
}
@ixzy24
ixzy24 / gist:2866441
Created June 4, 2012 04:55
Targeted Css, Mozzila
@-moz-document url-prefix() {
.date {
padding: 16px 0 0 0;
}
.date p span {
padding: 9px 0 3px 0;
}
}
@ixzy24
ixzy24 / index.html
Created June 4, 2012 06:07
Basic HTML5 Skeleton
<!doctype html>
<!-- paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/ -->
<!--[if lt IE 7]> <html class="no-js ie6 oldie" lang="en"> <![endif]-->
<!--[if IE 7]> <html class="no-js ie7 oldie" lang="en"> <![endif]-->
<!--[if IE 8]> <html class="no-js ie8 oldie" lang="en"> <![endif]-->
<!-- Consider adding an manifest.appcache: h5bp.com/d/Offline -->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
<head>
<meta charset="UTF-8">
<title>Title</title>
@ixzy24
ixzy24 / gist:2877608
Created June 5, 2012 20:30
html5 placeholder fallback
// jQuery code
var i = document.createElement("input");
// Only bind if placeholder isn't natively supported by the browser
if (!("placeholder" in i)) {
$("input[placeholder]").each(function () {
var self = $(this);
self.val(self.attr("placeholder")).bind({
focus: function () {
if (self.val() === self.attr("placeholder")) {
@font-face {
font-family: 'MyWebFont';
src: url('webfont.eot'); /* IE9 Compat Modes */
src: url('webfont.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
url('webfont.woff') format('woff'), /* Modern Browsers */
url('webfont.ttf') format('truetype'), /* Safari, Android, iOS */
url('webfont.svg#svgFontName') format('svg'); /* Legacy iOS */
}
body {
@ixzy24
ixzy24 / gist:2878038
Created June 5, 2012 21:18
Extending jQuery selector
jQuery.expr[':'].regex = function(elem, index, match) {
var matchParams = match[3].split(','),
validLabels = /^(data|css):/,
attr = {
method: matchParams[0].match(validLabels) ?
matchParams[0].split(':')[0] : 'attr',
property: matchParams.shift().replace(validLabels,'')
},
regexFlags = 'ig',
regex = new RegExp(matchParams.join('').replace(/^s+|s+$/g,''), regexFlags);
var animals = [
{ name: "Waffles", type: "dog", age: 12 },
{ name: "Fluffy", type: "cat", age: 14 },
{ name: "Spelunky", type: "dog", age: 4 },
{ name: "Hank", type: "dog", age: 11 }
];
// filter dogs
animals = animals.filter(function(animal) {
return animal.type === "dog";