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 / guide.js
Created January 27, 2012 20:52
codejobs - Definitive Guide for JavaScript - JavaScript
/**
* How to create a Javascript object and initialize its properties using dot notation (.)
*/
var codejobs = new Object();
codejobs.url = 'http://www.codejobs.biz';
codejobs.twitter = '@codejobs';
codejobs.getTwitter = function() { return codejobs.twitter; };
@MilkZoft
MilkZoft / hello.cob
Created January 23, 2012 02:54
codejobs - Hello World - Cobol
000100 IDENTIFICATION DIVISION.
000200 PROGRAM-ID. HELLOWORLD.
000300
000400*
000500 ENVIRONMENT DIVISION.
000600 CONFIGURATION SECTION.
000700 SOURCE-COMPUTER. RM-COBOL.
000800 OBJECT-COMPUTER. RM-COBOL.
000900
001000 DATA DIVISION.
@MilkZoft
MilkZoft / cut.php
Created January 20, 2012 03:51
codejobs - Cut words - PHP
<?php
function cut($text, $length = 12, $type = "text", $file = FALSE, $elipsis = FALSE) {
if($type === "text") {
$elipsis = "...";
$words = explode(" ", $text);
if(count($words) > $length) {
return str_replace("\n", "", implode(" ", array_slice($words, 0, $length)) . $elipsis);
}
@MilkZoft
MilkZoft / code.php
Created January 19, 2012 03:09
codejobs - Generates a random code (Hash) - PHP
<?php
function code($max = 10, $uppercase = TRUE) {
return ($uppercase) ? strtoupper(substr(md5(date("Y-m-d H:i:s", time())), 0, $max)) : substr(md5(date("Y-m-d H:i:s", time())), 0, $max);
}
?>
@MilkZoft
MilkZoft / spam.php
Created January 18, 2012 04:25
codejobs - Filter SPAM words - PHP
<?php
function isSPAM($string, $max = 2) {
$words = array(
"http", "www", ".com", ".mx", ".org", ".net", ".co.uk", ".jp", ".ch", ".info", ".me", ".mobi", ".us", ".biz", ".ca", ".ws", ".ag",
".com.co", ".net.co", ".com.ag", ".net.ag", ".it", ".fr", ".tv", ".am", ".asia", ".at", ".be", ".cc", ".de", ".es", ".com.es", ".eu",
".fm", ".in", ".tk", ".com.mx", ".nl", ".nu", ".tw", ".vg", "sex", "porn", "fuck", "buy", "free", "dating", "viagra", "money", "dollars",
"payment", "website", "games", "toys", "poker", "cheap"
);
$count = 0;
@MilkZoft
MilkZoft / browser.php
Created January 18, 2012 04:07
codejobs - How to know the user's browser? - PHP
<?php
function browser() {
$browsers = array(
"Opera" => "(Opera)",
"Mozilla Firefox" => "((Firebird)|(Firefox))",
"Galeon" => "(Galeon)",
"Mozilla" => "(Gecko)",
"MyIE" => "(MyIE)",
"Lynx" => "(Lynx)",
"Netscape" => "((Mozilla/4\.75)|(Netscape6)|(Mozilla/4\.08)|(Mozilla/4\.5)|(Mozilla/4\.6)|(Mozilla/4\.79))",
@MilkZoft
MilkZoft / remove.php
Created January 18, 2012 03:36
codejobs - Remove Spaces - PHP
<?php
function removeSpaces($text, $trim = FALSE) {
$text = preg_replace("/\s+/", " ", $text);
if($trim) {
return trim($text);
}
return $text;
}
@MilkZoft
MilkZoft / slug.php
Created January 18, 2012 03:34
codejobs - Slug - PHP
<?php
function slug($string) {
$characters = array("Á" => "A", "Ç" => "c", "É" => "e", "Í" => "i", "Ñ" => "n", "Ó" => "o", "Ú" => "u",
"á" => "a", "ç" => "c", "é" => "e", "í" => "i", "ñ" => "n", "ó" => "o", "ú" => "u",
"à" => "a", "è" => "e", "ì" => "i", "ò" => "o", "ù" => "u"
);
$string = strtr($string, $characters);
$string = strtolower(trim($string));
$string = preg_replace("/[^a-z0-9-]/", "-", $string);
@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 / 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;
}