Skip to content

Instantly share code, notes, and snippets.

View lpirir's full-sized avatar
🏠
Working from home

Luis Pirir lpirir

🏠
Working from home
View GitHub Profile
@lpirir
lpirir / relative-date-php
Created February 22, 2012 17:23 — forked from ivanmendoza/relative-date-php
Get relative date (spanish)
// INPUT: $item_date
$item_date = date("D, d M o G:i:s T",strtotime($item_date));
$today = date(DATE_RFC822);
$diff_date=(strtotime($today) - strtotime($item_date));
$inMinutes=round($diff_date/60);
$inHours=round($diff_date/(60*60));
$inDays=round($diff_date/(24*60*60));
if($inMinutes==1){$txt_date="hace un minuto";}
@lpirir
lpirir / dateformat
Created March 16, 2012 18:30
Mostrar fechas en español
function getDateWithTimezone($formato = "F j, Y", $fecha = 0)
{
date_default_timezone_set('America/Guatemala');
if (preg_match("/([0-9]{4})[\/-]([0-9]{1,2})[\/-]([0-9]{1,2})/", $fecha,$partes)) {
if (checkdate($partes[2],$partes[3],$partes[1])) {
$fecha=strtotime($fecha);
} else {
return(-1);
}
@lpirir
lpirir / fullscreen
Created March 17, 2012 23:20
Javascript code to show full screen browser
var docElm = document.documentElement;
if (docElm.requestFullscreen) {
docElm.requestFullscreen();
}
else if (docElm.mozRequestFullScreen) {
docElm.mozRequestFullScreen();
}
else if (docElm.webkitRequestFullScreen) {
docElm.webkitRequestFullScreen();
}
@lpirir
lpirir / hack_replacement.css
Created March 26, 2012 14:45
Hack new image replacement
.hide-text {
text-indent: 100%;
white-space: nowrap;
overflow: hidden;
}
@lpirir
lpirir / gist:7649457
Last active December 29, 2015 09:19
pagination like digg style from Stranger Studios http://www.strangerstudios.com/sandbox/pagination/diggstyle_function.txt
//function to return the pagination string
function getPaginationString($page = 1, $totalitems, $limit = 15, $adjacents = 1, $targetpage = "/", $pagestring = "?page=")
{
//defaults
if(!$adjacents) $adjacents = 1;
if(!$limit) $limit = 15;
if(!$page) $page = 1;
if(!$targetpage) $targetpage = "/";
//other vars
@lpirir
lpirir / .vimrc
Created December 23, 2013 18:59 — forked from JeffreyWay/.vimrc
set nocompatible " Disable vi-compatibility
set t_Co=256
colorscheme xoria256
set guifont=menlo\ for\ powerline:h16
set guioptions-=T " Removes top toolbar
set guioptions-=r " Removes right hand scroll bar
set go-=L " Removes left hand scroll bar
set linespace=15
@lpirir
lpirir / gist:5fe1d8dd4f790f288997
Created October 17, 2014 14:51
Mostrar los directorios con mas espacio ordenados por tamaño
du -Sh | sort -rh | head -n 15
@lpirir
lpirir / Create UTF8 Database
Created December 29, 2014 01:34
Create a UTF8 database in MySQL
CREATE DATABASE `mydb` CHARACTER SET utf8 COLLATE utf8_general_ci;
GRANT ALL ON `mydb`.* TO `username`@localhost IDENTIFIED BY 'password';
FLUSH PRIVILEGES;
@lpirir
lpirir / gist:6970992e694c79c5f94f
Created December 29, 2014 02:12
Create a UTF8 table in MySQL
CREATE TABLE aTable (
id BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY,
aNumber bigint(20) DEFAULT NULL
) ENGINE=InnoDB CHARACTER SET=utf8;
@lpirir
lpirir / __init__.py
Last active August 29, 2015 14:15 — forked from jhargis/__init__.py
# -*- coding: utf-8 -*-
# http://docs.cherrypy.org/en/latest/advanced.html?highlight=jinja2#html-templating-support
import os.path
import cherrypy
class Root(object):
@cherrypy.expose
def index(self):