Snippets Code


Latest Php Snippets

Css Snippets

CODE SNIPPETS :: PHP MYSQL JQUERY JAVASCRIPT


10 Useful and Time Saving JavaScript Snippets

Sep 11, 2015   ByCedric Ruiz

JavaScript evolves at a really fast pace. With such a big wave of fresh JavaScript technology splashing the web everyday it's a daunting task to keep up to date with all of it. jQuery is the preferred library due to its undeniable popularity, although some scripts are written in pure JavaScript.

In this article we are going to cover 10 useful scripts that will save you some time when solving common problems. Most of these snippets are good to copy & paste but feel free to analyze, strip, mix, share, or adapt them to your own workflow.

Full Detail

10 JQUERY SNIPPETS

Sep 25, 2015   BySARA VIEIRA

jQuery is used on thousands upon thousands of web pages. It’s one of the most common libraries to insert into pages, and it makes DOM manipulation a snap.

Of course, part of jQuery’s popularity is its simplicity. It seems we can do almost anything we like with this powerful library.

For all the options open to us, there are some snippets we tend to come back to time and time again. Today I’d like to give you 10 snippets that everyone, newbies to gurus, will use time and time again.

Full Detail

10 Useful & Handy PHP Snippets for Developers

Sep 05, 2015   ByGAVIN

The PHP library contains innumerable useful php code snippets which every developer needs to have in their “toolbox”. These php snippets offer a variety of handy functions which can ultimately end up saving you time. Today, we’ve collected 10 useful and handy php snippets which you may find useful within your coding endeavors. Enjoy !

1. The Real Way to Check Uploaded File Type

<!--?php <br ?-->// Here we specify all the type of files we want to accept
$extension = array("application/pdf", "image/jpeg", "image/png", "image/gif");

if(isset($_POST['submit'])){
	exec("file -i ".$_FILES['inputName']['tmp_name'], $output);
	$type = explode(':', (string)$output[0]);
}

// Here we check our file with our needs
if (isset($_FILES['inputName']) &&
	    $_FILES['inputName']['error'] == UPLOAD_ERR_OK  &&
	    $_FILES['inputName']['size'] <= 10000000 &&
	    in_array(trim($type[1]), $extension)){
	    var_dump($_FILES['inputName']['tmp_name']);
}else{
    die("File Error");
}

Source 

Full Detail

USEFUL LINKS



ESSENTIAL SNIPPETS



Any good web developer knows that re-purposing old code is a big key to getting stuff done efficiently. With each project, I often find myself going back again and again to the same snippets of code. If you’re a beginner, some of these tricks might be new to you. For a seasoned front-end developer, you might already be copy + pasting these from your existing code, or from somewhere else. Either way, these tiny slices of code are great building blocks for most projects. Nothing here is mind-blowing stuff, but it’s always straight-up useful:


Perfect Full-Page Background Images

This one’s a killer for any responsive site. I probably google this one at least once a week:

.cover {
background: url(images/bg.jpg) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}

Full-screen images are trendy as all get out right now. This snippet works across any resolution device.
via http://css-tricks.com/perfect-full-page-background-image/

Javascript Function Suicide

This one’s a neat trick for when you want a javascript function to run once and only once, but is triggered by a common event: have it kill itself. Just pop this code into the end of the function, and it’ll over-write itself with function that doesn’t do anything:

var yourFunction = function () {
// do stuff
yourFunction = function() {return false;}
};

Read More
Top