Skip to content

Instantly share code, notes, and snippets.

View devluis's full-sized avatar

Alberto Hernández devluis

View GitHub Profile
@devluis
devluis / php-class-to-read-psd-files
Created December 29, 2013 20:14
PHP class to read PSD files
<?
/* This file is released under the GPL, any version you like
*
* PHP PSD reader class, v1.3
*
* By Tim de Koning
*
* Kingsquare Information Services, 22 jan 2007
*
* example use:
@devluis
devluis / validate-email-with-regular-expression-php
Created December 29, 2013 20:07
validate email with regular expression in PHP
<?php
$email = "someone@example.com";
if(eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) {
echo "Valid email address.";
}
else {
echo "Invalid email address.";
}
@devluis
devluis / list-images-inside-folder
Created December 29, 2013 20:05
List images inside folder
<?php
if ($handle = opendir('myFolder')) {
echo "Directory handle: $handle\n";
echo "Files:\n";
/* This is the correct way to loop over the directory. */
while (false !== ($file = readdir($handle))) {
echo $file."<br />";
}
@devluis
devluis / check-is-file-exist
Created December 29, 2013 19:59
Check if file exist with PHP
<?php
# Check if file exist
if(file_exists("path-to-my-image/my-image.png")){
print 'File exist';
} else {
print 'File does not exist';
}
?>
@devluis
devluis / sql-return-records-last-hour
Created December 28, 2013 21:27
Select SQL to return records in the last hour
SELECT *
FROM tbl_name
WHERE creation_time > DATE_SUB(NOW(),INTERVAL 1 HOUR)
@devluis
devluis / add-separator-in-time-with-jquery.html
Created December 14, 2013 04:34
Add separator in string time with jquery
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Add separator in time with Jquery</title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script>
$(document).ready(function() {
$("#currentTime").keyup(function(){
if ($(this).val().length == 2){
@devluis
devluis / get-profile-picture
Created December 13, 2013 18:49
Get facebook profile picture with graph API
To get the facebook profile picture
http://graph.facebook.com/[user id]/picture
For changing the size use this link
http://graph.facebook.com/[user id]/picture?type=large --------------> for larger image
http://graph.facebook.com/[user id]/picture?type=smaller --------------> for smaller image
http://graph.facebook.com/[user id]/picture?type=square --------------> for square
@devluis
devluis / live-word-counter-jquery
Created December 6, 2013 05:35
Live Word and Character Counter using jQuery
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<meta charset=utf-8 />
<title>Live Word and Character Counter using jQuery</title>
<style>
textarea{
@devluis
devluis / hover-dropdown-menu
Created December 5, 2013 23:10
JQuery Drop Down Menu
<!doctype html>
<html lang="en">
<head>
<style type="text/css">
ul {
margin:0;
padding:0;
list-style-type:none;
min-width:200px;
}
@devluis
devluis / tips-htaccess
Last active December 29, 2015 19:09
Htaccess tips.
# Error Pages
# Here error page is redirecting to error.html.
errorDocument 400 http://www.youwebsite.com/404.html
errorDocument 401 http://www.youwebsite.com/error.html
errorDocument 403 http://www.youwebsite.com/error.html
errorDocument 500 http://www.youwebsite.com/error.html
# Disable directory Listing
# If you want to disable folder files listing, include following code.