Skip to content

Instantly share code, notes, and snippets.

View digitalhydra's full-sized avatar
💭
please don't turn this into The MS social network

Jairo Mejia digitalhydra

💭
please don't turn this into The MS social network
View GitHub Profile
@digitalhydra
digitalhydra / htaccess-caching.txt
Created December 13, 2013 20:20
compresion y optimizacion de carga de pagina con .htaccess
FileETag none # Turn off eTags
<IfModule mod_expires.c> # Check that the expires module has been installed
ExpiresActive On
ExpiresDefault "access plus 10 years"
ExpiresByType image/gif "access plus 10 years"
ExpiresByType image/jpeg "access plus 10 years"
ExpiresByType image/png "access plus 10 years"
ExpiresByType text/css "access plus 10 years"
ExpiresByType text/html "access plus 1 seconds"
ExpiresByType text/javascript "access plus 10 years"
@digitalhydra
digitalhydra / add-post-column.php
Last active January 13, 2016 04:03
Add Custom Column to the Posts Screen
// GET FEATURED IMAGE
function ST4_get_featured_image($post_ID) {
$post_thumbnail_id = get_post_thumbnail_id($post_ID);
if ($post_thumbnail_id) {
$post_thumbnail_img = wp_get_attachment_image_src($post_thumbnail_id, 'featured_preview');
return $post_thumbnail_img[0];
}
}
// ADD NEW COLUMN
@digitalhydra
digitalhydra / medialibraryonwordpress.php
Created December 13, 2013 20:57
integrate the Media Library into a plugin for wordpress
function wp_gear_manager_admin_scripts() {
wp_enqueue_script('media-upload');
wp_enqueue_script('thickbox');
wp_enqueue_script('jquery');
}
function wp_gear_manager_admin_styles() {
wp_enqueue_style('thickbox');
}
@digitalhydra
digitalhydra / endofvideo.js
Created December 13, 2013 21:22
detect end of html5 video
<video src="video.ogv">
video not supported
</video>
then you can use:
<script>
var video = document.getElementsByTagName('video')[0];
video.onended = function(e) {
/*Do things here!*/
@digitalhydra
digitalhydra / carouselswipe.js
Created December 13, 2013 21:36
add swipe control to bootstrap carousel
/*! jQuery Mobile v1.3.2 | Copyright 2010, 2013 jQuery Foundation, Inc. | jquery.org/license */
(function(e,t,n){typeof define=="function"&&define.amd?define(["jquery"],function(r){return n(r,e,t),r.mobile}):n(e.jQuery,e,t)})(this,document,function(e,t,n,r){(function(e,t,n,r){function x(e){while(e&&typeof e.originalEvent!="undefined")e=e.originalEvent;return e}function T(t,n){var i=t.type,s,o,a,l,c,h,p,d,v;t=e.Event(t),t.type=n,s=t.originalEvent,o=e.event.props,i.search(/^(mouse|click)/)>-1&&(o=f);if(s)for(p=o.length,l;p;)l=o[--p],t[l]=s[l];i.search(/mouse(down|up)|click/)>-1&&!t.which&&(t.which=1);if(i.search(/^touch/)!==-1){a=x(s),i=a.touches,c=a.changedTouches,h=i&&i.length?i[0]:c&&c.length?c[0]:r;if(h)for(d=0,v=u.length;d<v;d++)l=u[d],t[l]=h[l]}return t}function N(t){var n={},r,s;while(t){r=e.data(t,i);for(s in r)r[s]&&(n[s]=n.hasVirtualBinding=!0);t=t.parentNode}return n}function C(t,n){var r;while(t){r=e.data(t,i);if(r&&(!n||r[n]))return t;t=t.parentNode}return null}function k(){g=!1}function L(){g=!0}f
@digitalhydra
digitalhydra / countrybyip.php
Created December 13, 2013 21:49
obtener pais basado en la ip
/Obtener IP:
$_SERVER["HTTP_CLIENT_IP"]!=""?$ip=$_SERVER["HTTP_CLIENT_IP"]:
$ip=$_SERVER["REMOTE_ADDR"];
//Función de obtención de IP (basado en la web de webhosting.info)
function getCountry($ip_address){
//By Marc Palau (http://www.nbsp.es)
$url = "http://ip-to-country.webhosting.info/node/view/36";
$inici = "src=/flag/?type=2&cc2=";
@digitalhydra
digitalhydra / superoclassphp.php
Created December 13, 2013 21:50
php super class
<?php
// Define the 'class' class
$class = Obj()
->fn('new', function ($class) {
$newClass = Obj($class->methods)
->fn('new', function($class) {
$obj = Obj($class->imethods);
$args = func_get_args();
array_shift($args);
@digitalhydra
digitalhydra / diasdelmes.php
Created December 13, 2013 21:51
numero de dias del mes php
<? $númeroDeDias = intval(date("t",$mes)); ?>
@digitalhydra
digitalhydra / alphaidgenerator.php
Created December 13, 2013 22:09
alpha id generator
<?php
/**
* Translates a number to a short alhanumeric version
*
* Translated any number up to 9007199254740992
* to a shorter version in letters e.g.:
* 9007199254740989 --> PpQXn7COf
*
* specifiying the second argument true, it will
* translate back e.g.:
@digitalhydra
digitalhydra / backbutton.php
Created December 14, 2013 14:13
crear link a pagina anterior en wordpress
<?php wp_get_referer() ?>