Skip to content

Instantly share code, notes, and snippets.

View janogarcia's full-sized avatar

Jano Garcia janogarcia

View GitHub Profile
LICENCIA PÚBLICA de NO SEAS UN CAPULLO
Version 1, Diciembre 2009
Copyright (C) 2009 Philip Sturgeon <email@philsturgeon.co.uk>
Se autoriza la reproducción y distribución de las copias del presente documento de licencia, y se permite así mismo su modificación siempre y cuando se cambie el nombre de la licencia.
LICENCIA PÚBLICA de NO SEAS UN CAPULLO
TÉRMINOS Y CONDICIONES PARA LA COPIA, DISTRIBUCIÓN Y MODIFICACIÓN
//
// While TinyMCE can strip out <script> tags,
// it does not remove inline JS event handlers.
//
// Example: onmouseover, onclick, etc.
//
// This should be included at the bottom of a page,
// contained inside an <iframe> to sandbox user-created
// content. The reason it is contained in an <iframe>
// is to prevent user-created CSS from affecting
@janogarcia
janogarcia / php_string_slice.php
Created December 16, 2010 09:03
PHP port of JavaScript String slice() method
<?php
/**
* PHP port of JavaScript String slice() method
*
* @param string $str
* @param int $start
* @param int $end (optional)
*/
function str_slice($str, $start, $end = FALSE)
{
@janogarcia
janogarcia / bootstrap_translucent_ie.less
Created September 30, 2011 09:54
Translucent background colors in IE for Twitter Bootstrap
// Extension to Twitter Bootstrap's mixin.less that adds support for translucent background colors in IE6-IE9 (deprecated as of IE9)
#translucent {
.background(@color: @white, @alpha: 1) {
// http://css3please.com/
// http://msdn.microsoft.com/en-us/library/ms532997(v=vs.85).aspx
background-color: transparent;
background-color: hsla(hue(@color), saturation(@color), lightness(@color), @alpha);
// http://stackoverflow.com/questions/2877322/convert-opacity-to-hex-in-javascript
// http://robertnyman.com/2010/01/11/css-background-transparency-without-affecting-child-elements-through-rgba-and-filters/
@janogarcia
janogarcia / MY_url_helper.php
Created January 9, 2012 12:54
url_title_i18n(): multilanguage version of CodeIgniter url_title() fucntion. #i18n #internationalization #language
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* Create URL Title with support for accented characters
*
* Takes a "title" string as input and creates a
* human-friendly URL string with either a dash
* or an underscore as the word separator.
*
* All accented characters get transliterated
@janogarcia
janogarcia / riloadr_minimal.html
Created April 17, 2012 13:19
Riloadr - Minimal example
<!doctype html>
<html class="no-js" lang="en">
<head>
<meta charset="utf-8">
<meta name="HandheldFriendly" content="True">
<meta name="MobileOptimized" content="0">
<meta name="viewport" content="width=device-width">
<script type="text/javascript" src="riloadr.min.js"></script>
@janogarcia
janogarcia / haml_partials.haml
Created May 3, 2012 11:28
HAML Partials wihout Rails (useful for LiveReload)
/ A simplistic way of loading and rendering HAML partials (header.haml, footer.haml, nav.haml... you name it) without Rails
/ Useful when using tools like LiveReload http://livereload.com/
/ but don't want to configure a web server just to use PHP include/require constructs (discussion http://help.livereload.com/discussions/questions/22-haml-partials)
/ It could be improved/simplified using a helper http://stackoverflow.com/questions/5436769/partial-haml-templating-in-ruby-without-rails/5436973#5436973
/ Check out the Jade version https://gist.github.com/2593727
%html
%body
%header
= Haml::Engine.new(File.read('/path/to/your/partial.haml')).render
@janogarcia
janogarcia / jade_include.jade
Created May 4, 2012 10:00
Jade Include (useful for LiveReload)
// Jade (http://jade-lang.com) version of this HAML snippet https://gist.github.com/2585095
html
body
header
include partial
footer
@janogarcia
janogarcia / MY_Lang.php
Created June 13, 2012 08:32
CodeIgniter 2.1.0 Mutilingual
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
// Adds support for language code in the first segment of the URI.
// It negotiates the language if no language is found in the URI.
// Negotiation priority: URI language code segment > Cookie ($_COOKIE) > User agent ($_SERVER['HTTP_ACCEPT_LANGUAGE']) > Fallback (Configuration)
class MY_Lang extends CI_Lang {
/**
* Config class
@janogarcia
janogarcia / triggers.sql
Created October 18, 2012 15:04
MySQL Log/History Triggers for Audit Trail
DELIMITER //
# Campaign modified timestamps: modified_description, modified_where, modified_conditions, modified_includes
CREATE TRIGGER before_campaigns_update BEFORE UPDATE ON campaigns
FOR EACH ROW
BEGIN
IF (NEW.description <> OLD.description) OR (NEW.description IS NOT NULL AND OLD.description IS NULL) OR (NEW.description IS NULL AND OLD.description IS NOT NULL)
OR (NEW.infolink_text <> OLD.infolink_text) OR (NEW.infolink_text IS NOT NULL AND OLD.infolink_text IS NULL) OR (NEW.infolink_text IS NULL AND OLD.infolink_text IS NOT NULL)
OR (NEW.infolink_url <> OLD.infolink_url) OR (NEW.infolink_url IS NOT NULL AND OLD.infolink_url IS NULL) OR (NEW.infolink_url IS NULL AND OLD.infolink_url IS NOT NULL)