Skip to content

Instantly share code, notes, and snippets.

View MilkZoft's full-sized avatar

Carlos Santana Roldán MilkZoft

View GitHub Profile
@MilkZoft
MilkZoft / random.php
Created January 18, 2012 03:32
codejobs - Random String - PHP
<?php
function randomString($length = 6) {
$consonant = array("b", "c", "d", "f", "g", "h", "j", "k", "l", "m", "n", "p", "r", "s", "t", "v", "w", "x", "y", "z");
$vocal = array("a", "e", "i", "o", "u");
$string = NULL;
srand((double) microtime() * 1000000);
$max = $length / 2;
@MilkZoft
MilkZoft / remove.php
Created January 16, 2012 23:10
codejobs - Remove repeated words (case insensitive) - PHP, Regexp
<?php
$text = preg_replace("/s(w+s)1/i", "$1", $text);
?>
@MilkZoft
MilkZoft / domain.php
Created January 16, 2012 22:56
code.jobs - Validate domain name - PHP, Regexp
<?php
$URL = "http://codejobs.biz/";
if(preg_match('/^(http|https|ftp)://([A-Z0-9][A-Z0-9_-]*(?:.[A-Z0-9][A-Z0-9_-]*)+):?(d+)?/?/i', $URL)) {
print "Valid URL";
} else {
print "Invalid URL";
}
?>
@MilkZoft
MilkZoft / border.css
Created January 16, 2012 22:49
code.jobs - Border Radius (Rounded Corners) - CSS3
.round-all {
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
-khtml-border-radius:5px; /* make sure its proper */
border-radius: 5px;
}
.round-top {
-webkit-border-top-right-radius:5px;
-webkit-border-top-left-radius: 5px;
@MilkZoft
MilkZoft / opacity.css
Created January 16, 2012 22:42
code.jobs - Opacity Hack - CSS
selector {
filter: alpha(opacity=60); /* MSIE/PC */
-moz-opacity: 0.6; /* Mozilla 1.6 and older */
opacity: 0.6;
}
@MilkZoft
MilkZoft / disable.js
Created January 16, 2012 04:41
code.jobs - Disable the “Enter” key in forms - jQuery
$("#form").keypress(function(e) {
if(e.which == 13) {
return false;
}
});
@MilkZoft
MilkZoft / url.js
Created January 16, 2012 04:37
code.jobs - Get URL parameters - jQuery
$.urlParam = function(name) {
var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(window.location.href);
if(!results) {
return 0;
}
return results[1] || 0;
}
@MilkZoft
MilkZoft / browser.js
Created January 16, 2012 04:33
code.jobs - Test if the browser supports a specific CSS3 property - jQuery
var supports = (function() {
var div = document.createElement('div'),
vendors = 'Khtml Ms O Moz Webkit'.split(' '),
len = vendors.length;
return function(prop) {
if(prop in div.style) {
return true;
}
@MilkZoft
MilkZoft / enable.js
Created January 16, 2012 04:22
code.jobs - Enable HTML5 markup on older browsers - jQuery
(function() {
if(!/*@cc_on!@*/0) {
return;
}
var e = "abbr,article,aside,audio,bb,canvas,datagrid,datalist,details,dialog,eventsource,figure,footer,header,hgroup,mark,menu,meter,nav,output,progress,section,time,video".split(','), i = e.length;
while(i--) {
document.createElement(e[i]);
}
@MilkZoft
MilkZoft / column.js
Created January 16, 2012 04:18
code.jobs - Equal column height - jQuery
var maxHeight = 0;
$("div.col").each(function() {
if($(this).height() > maxHeight) {
maxHeight = $(this).height();
}
});
$("div.col").height(maxHeight);