Skip to content

Instantly share code, notes, and snippets.

View luckyshot's full-sized avatar
🌍
xaviesteve.com

Xavi Esteve luckyshot

🌍
xaviesteve.com
View GitHub Profile
@luckyshot
luckyshot / gist:5147735
Last active December 14, 2015 20:59
Google Spreadsheets (Excel) - Nested IFs formula
=($C5*if(CZ25>3, if(CZ25>5,if(CZ25>10,if(CZ25>25,if(CZ25>30,32,16),8),4),2),1)
+$C5*if(CZ26>3, if(CZ26>5,if(CZ26>10,if(CZ26>25,if(CZ26>30,32,16),8),4),2),1)
+$C5*if(CZ27>3, if(CZ27>5,if(CZ27>10,if(CZ27>25,if(CZ27>30,32,16),8),4),2),1)
+$C5*if(CZ28>3, if(CZ28>5,if(CZ28>10,if(CZ28>25,if(CZ28>30,32,16),8),4),2),1)
+$C5*if(CZ29>3, if(CZ29>5,if(CZ29>10,if(CZ29>25,if(CZ29>30,32,16),8),4),2),1)
+$C5*if(CZ30>3, if(CZ30>5,if(CZ30>10,if(CZ30>25,if(CZ30>30,32,16),8),4),2),1)
+$C5*if(CZ31>3, if(CZ31>5,if(CZ31>10,if(CZ31>25,if(CZ31>30,32,16),8),4),2),1)
+$C5*if(CZ32>3, if(CZ32>5,if(CZ32>10,if(CZ32>25,if(CZ32>30,32,16),8),4),2),1)
+$C5*if(CZ33>3, if(CZ33>5,if(CZ33>10,if(CZ33>25,if(CZ33>30,32,16),8),4),2),1)
+$C5*if(CZ34>3, if(CZ34>5,if(CZ34>10,if(CZ34>25,if(CZ34>30,32,16),8),4),2),1)
@luckyshot
luckyshot / gist:5148188
Created March 12, 2013 23:54
jQuery - Attach event to parent delegating to child targets
$('#parent').click(function(e){
var target = $(e.target); // the child that fired the original click
// do stuff here
});
@luckyshot
luckyshot / gist:5263561
Created March 28, 2013 14:29
Disable copy paste in an input field
<input autocomplete="off" onpaste="return false">
@luckyshot
luckyshot / match-against.sql
Last active May 8, 2017 08:56
MySQL - Select results and order by relevance
-- You should add a FULLTEXT index on each row you are searching
ALTER TABLE `user` ADD FULLTEXT INDEX (`first_name`);
--
SELECT *, (
(1.2 * (MATCH(title) AGAINST (:query IN BOOLEAN MODE))) +
(0.8 * (MATCH(description) AGAINST (:query IN BOOLEAN MODE))) +
(1.0 * (MATCH(tags) AGAINST (:query IN BOOLEAN MODE)))
@luckyshot
luckyshot / gist:5335507
Created April 8, 2013 09:26
CSS animation/transition
.box {
transition: all 0.2s ease;
animation: down-bump 0.4s ease;
}
.box:hover {
animation: up-bump 0.4s ease;
}
@keyframes up-bump {
@luckyshot
luckyshot / gist:5338413
Created April 8, 2013 16:55
File-less HTML page!
data:text/html,<title>Hello Data URL</title><p>File-less HTML page!</p>
@luckyshot
luckyshot / gist:5340059
Created April 8, 2013 20:11
JavaScript simplest timer (setInterval)
var t = setInterval(function(){
// Do stuff
},1000);
@luckyshot
luckyshot / gist:5346124
Created April 9, 2013 14:30
JavaScript - Remember page scrolled position
$(document)
.scrollTop( (localStorage.scrollPos) ? localStorage.scrollPos : 0 )
.on('scroll', function() {
localStorage.scrollPos = $(document).scrollTop();
});
@luckyshot
luckyshot / gist:5366726
Last active December 16, 2015 02:59
Browser and client details in JavaScript
/****************************************************
* Website
****************************************************/
// Page title
document.title.substring(0, 200);
// Domain (i.e. gist.github.com)
document.domain;
@luckyshot
luckyshot / gist:5395596
Last active December 16, 2015 06:59
Simple Console system
<?php
public function c($msg, $echo = 0) {
if (!isset($_SESSION['console'])) { $_SESSION['console'] = "";}
if ($echo) {
$buffer = "<pre>".$_SESSION['console']."</pre>";
$_SESSION['console']="";
return $buffer;
}else{
$_SESSION['console'] = $_SESSION['console']."