Skip to content

Instantly share code, notes, and snippets.

View kikegarcia's full-sized avatar

Enrique J. García kikegarcia

View GitHub Profile
@kikegarcia
kikegarcia / controller.php
Created July 8, 2013 08:15
Twitter PHP Class With Oauth for API 1.1
<?php
/**
* Profile controller
* Delegates control to profile controllers to seperate the distinct profile features
*/
class Twittercontroller {
/**
* Constructor
@kikegarcia
kikegarcia / controller.php
Created July 8, 2013 08:24
Facebook Wall to PHP class with FB API
<?php
/**
* Profile controller
* Delegates control to profile controllers to seperate the distinct profile features
*/
class Facebookcontroller {
/**
* Constructor
@kikegarcia
kikegarcia / jqueryselectors.js
Last active December 19, 2015 11:29
Select and change A href (adds target blank too), Select Option & Img Src
// a href Selector and new attr
var linksToMondosonoro = $('a[href="/video/urltocatch"]');
$(linksToMondosonoro).attr("href", "http://www.newurl.com")
$(linksToMondosonoro).attr("target","_blank"); // añade un target blank
// Select Selector and new attr
var selectToMondosonoro = $('#selectmodifier option[value="/video/selecttocatch"]');
$(selectToMondosonoro).val('http://www.newurl.com');
// Img variable and the new property
@kikegarcia
kikegarcia / hide.js
Last active December 19, 2015 13:59
Hide things if a span is empty
<script>
$(document).ready(function(){
if(!$('.testimonios > span.efecto').html().trim()) {
$('h2.titular').hide();
$('div.testimonios').hide();
$('.testimonios > span.efecto').hide();
}
})
</script>
@kikegarcia
kikegarcia / ahref.js
Created July 12, 2013 12:09
Replace "a href" with the actual real URL
var url = $(location).attr('href');
var urlsplit = url.split("/");
var urlname = urlsplit[5];
$('a').each(function(){
this.href = this.href.replace('.pag.', urlname);
});
@kikegarcia
kikegarcia / hiddendiv.html
Created July 15, 2013 14:12
hidden div that shows in certain time with Jquery Delay and goes away with a click outside of it
<div id="suscribecall" style="right: -500px; width:314px;height:390px;position: absolute; background-color:#dd7051; z-index: 100;"></div>
<script>
$(document).ready(function() {
$('div#showbanners').show('slow');
$('#suscribecall').delay(10000).animate({
right: "0px"
@kikegarcia
kikegarcia / onchangeselect.html
Created July 18, 2013 07:06
onchange select
<div class="styled-select">
<select id="selectmodifier" onchange="this.options[this.selectedIndex].value && (window.location = this.options[this.selectedIndex].value);">
<option value="" selected="selected" enabled='false'>BUSCA TU ARTISTA</option>
<!-- START videoselect -->
<option value="/video/{urlname}">{name}</option>
<!-- END videoselect -->
</select>
</div>
@kikegarcia
kikegarcia / jquerydynamicselectors
Last active December 20, 2015 02:59
Jquery checks if there's a property that must replace another one and does it atm
<div id="galeria">
<h1 class="textbar">GALERÍA DE VÍDEOS</h1>
<div class="styled-select">
<select onchange="this.options[this.selectedIndex].value && (window.location = this.options[this.selectedIndex].value);">
<option value="" selected="selected" enabled='false'>SELECCIONA TU ARTISTA</option>
<!-- START videoselect -->
<option value="/video/{urlname}" name="{urlalt}">{name}</option>
<!-- END videoselect -->
</select>
</div>
@kikegarcia
kikegarcia / MLquerytags
Last active December 20, 2015 05:29
Query ML búsqueda tags
SELECT pl.name, pl.id_product, price
FROM ps_product p
LEFT JOIN ps_product_lang pl ON p.id_product = pl.id_product
WHERE pl.id_lang = 1 AND p.id_product IN (
SELECT pt.id_product
FROM ps_product_tag pt, ps_tag pp
WHERE pp.name REGEXP "[[:<:]]Cuerpo|hasta25[[:>:]]" AND pt.id_tag=pp.id_tag)
@kikegarcia
kikegarcia / bitly.php
Created July 25, 2013 13:57
Bitly class
$url = 'http://toysessions.savethechildren.es/video/'.$data['urlname'];
$login = '';
$appkey = '';
$format = 'xml';
$version = '2.0.1';
$bitly = 'http://api.bit.ly/shorten?version='.$version.'&longUrl='.urlencode($url).'&login='.$login.'&apiKey='.$appkey.'&format='.$format;
$response = file_get_contents($bitly);
if(strtolower($format) == 'json')