Skip to content

Instantly share code, notes, and snippets.

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

Mariano Peyregne Marian0

🏠
Working from home
  • Santa Fe, Argentina
View GitHub Profile
@Marian0
Marian0 / gist:c28e33faf11b850edc2f
Created November 18, 2014 19:10
Date format in Yii translatable applications
// In languages key value for example app_es.php
'yyyy-mm-dd' => 'dd/mm/yyyy',
'Y-m-d' => 'd/m/Y',
//In controller:
$date = DateTime::createFromFormat(Yii::t('app', 'Y-m-d') , $this->date);
$this->date = $date->format('Y-m-d');
@Marian0
Marian0 / gist:9e43d3aebe4e928d0b9f
Created December 10, 2014 15:51
Bindear eventos sobre elementos traidos por AJAX
$(document).on('click', selector-to-your-element , function() {
//code here ....
});
@Marian0
Marian0 / gist:39a3f7467808f0b0a829
Created December 10, 2014 21:02
CakePHP - Load model, find data, send to view
$this->loadmodel('Area');
$data = $this->Area->find('list'); // OR ALL TO GET ALL ATTRIBUTES
$this->set('areas', $data );
@Marian0
Marian0 / gist:babab18854a651d4269a
Last active August 29, 2015 14:11
Model find example CAKE PHP
$alertasLlegando = $this->Alerta->find('all', array('conditions' => array(
'Alerta.lat >= ' => $area['lat1'],
'Alerta.lat <= ' => $area['lat2'],
'Alerta.lng <= ' => $area['lng1'],
'Alerta.lng <= ' => $area['lng2'],
'Alerta.estado' => 'llegando',
),
'limit' => 5,
'order' => array('Alerta.updated' => 'DESC')
));
@Marian0
Marian0 / gist:351b18f909bad9ff4074
Created December 17, 2014 16:41
CakePHP Query LOG on Controllers
$log = $this->Alerta->getDataSource()->getLog(false, false); debug($log);
@Marian0
Marian0 / gist:dac25364716861ac0b5e
Created December 19, 2014 15:22
Consulta para obtener productos con precio menor al de compra
select * from
product P,
(SELECT idProduct as prodStock, max(unitPrice) as maxPrice from buy B where stockAvailable>0 GROUP BY idProduct) L
WHERE
P.idProduct=prodStock
AND
P.unitSellingPrice<=maxPrice
;
@Marian0
Marian0 / gist:069dc670f4f35dbab501
Created March 4, 2015 14:42
Capturar submit y hacer un ajax como la gente
$(document).on('submit', '#contact' , function(event) {
url = $(this).attr("action");
console.log(url);
$.ajax({
type: "POST",
url: url,
datatype: "json",
data: {
"name": $("#contact #name").val(),
@Marian0
Marian0 / gist:f0603f4eff7bd099a356
Created March 5, 2015 16:12
Ubuntu Nautilus Files configuration Behavior
Para que el comportamiento de búsqueda sea el mismo de siempre:
gsettings set org.gnome.nautilus.preferences enable-interactive-search true
@Marian0
Marian0 / loading.md
Last active October 16, 2015 14:05
Overlay Loading CSS

#CSS

#ajaxLoadOverlay{
    background: rgba(0, 0, 0, 0.8) url('../images/ring-alt.svg') no-repeat scroll center center;
    display: none;
    height: 100%;
    position: fixed;
    top: 0;
    width: 100%;
 z-index: 1001;
@Marian0
Marian0 / gist:4d689c33164bc9daf0e1
Created October 22, 2015 12:07
Disable wordpress Frontend by htaccess
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !/wp-admin
RewriteCond %{REQUEST_URI} !/wp-includes
RewriteCond %{REQUEST_URI} !/wp-login\.php$
RewriteCond %{REQUEST_URI} !/wp-content
RewriteCond %{REQUEST_URI} !/feed