Skip to content

Instantly share code, notes, and snippets.

View devluis's full-sized avatar

Alberto Hernández devluis

View GitHub Profile
@devluis
devluis / gist:6106036
Created July 29, 2013 17:34
Centrar un div en forma vertical y horizontal utlizando solo CSS
position: absolute;
left: 50%;
top: 50%;
width: 300px;
height: 200px;
margin-top: -100px;
margin-left: -150px;

Deploy your site with git

This gist assumes:

  • you have a local git repo
  • with an online remote repository (github / bitbucket etc)
  • and a cloud server (Rackspace cloud / Amazon EC2 etc)
    • your (PHP) scripts are served from /var/www/html/
    • your webpages are executed by apache
  • apache's home directory is /var/www/
# Make .git files and directory web inaccessible
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*/)?\.git+ - [R=404,L]
</IfModule>
# Second line of defense (if no mod_rewrite)
RedirectMatch 404 ^(.*/)?\.git+
@devluis
devluis / gist:6194464
Created August 9, 2013 15:16
Internet Explorer User Agent Strings
Internet Explorer 10.6
Mozilla/5.0 (compatible; MSIE 10.6; Windows NT 6.1; Trident/5.0; InfoPath.2; SLCC1; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET CLR 2.0.50727) 3gpp-gba UNTRUSTED/1.0
Internet Explorer 10.0
Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)
Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0)
Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/5.0)
Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/4.0; InfoPath.2; SV1; .NET CLR 2.0.50727; WOW64)
@devluis
devluis / gist:6194846
Created August 9, 2013 16:05
Detectar navegador usando el User Agent con coldfusion
<!--- Verificamos el user agent del navegador del usuario --->
<cfif #HTTP_USER_AGENT# CONTAINS "OptimizedIE8">
<!--- Código a ejecutar --->
<cfelse>
<!--- Código a ejecutar --->
</cfif>
@devluis
devluis / gist:6233667
Created August 14, 2013 17:57
Hide part of image with css without cropping image
<style>
.container {
width: 418px;
height: 240px;
overflow: hidden;
}
.container img {
width: 100%;
}
</style>
@devluis
devluis / gist:6272558
Created August 19, 2013 18:41
Video player HTML 5 with support for iOS devices
<!DOCTYPE html>
<head>
<meta charset=”utf-8″>
<meta name=”apple-mobile-web-app-capable” content=”yes” />
<title>My Video</title>
<link rel=”apple-touch-icon” href=”icon.png” />
<style>
body {margin:0;}
@devluis
devluis / gist:6527564
Created September 11, 2013 18:15
Add active class to a navigation menu based on URL
<!DOCTYPE html>
<html>
<head>
<style>
#nav {
margin:200px auto;
width:430px;
}
#nav ul {
@devluis
devluis / gist:6551899
Created September 13, 2013 15:03
Link on webapp to switch desktop version witch coldfusion
<!--- Check if parameter nomobile exist in URL --->
<cfif structKeyExists(url, "nomobile")>
<!--- If exist SET session on TRUE and show desktop version--->
<cfset session.nomobile = true>
<!--- If not exist redirect to mobile version--->
<cfelse>
<cfif reFindNoCase("android|avantgo|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino",CGI.HTTP_USER_AGENT) GT 0 OR reFindNoCase("1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(
@devluis
devluis / gist:6709785
Created September 26, 2013 04:14
Show random image when refresh page
<?php
srand( microtime() * 10000 );
$num = rand( 1, 3 ); # Random range
switch( $num ){
case 1: $image_file = "mi-imagen-1.jpg";
break;
case 2: $image_file = "mi-imagen-2.jpg";