This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- show running queries (pre 9.2) | |
SELECT procpid, age(query_start, clock_timestamp()), usename, current_query | |
FROM pg_stat_activity | |
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%' | |
ORDER BY query_start desc; | |
-- show running queries (9.2) | |
SELECT pid, age(query_start, clock_timestamp()), usename, query | |
FROM pg_stat_activity | |
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
this.pathname = window.location.pathname.split('/'); | |
//Normally in the dev environment the project will be inside a path into htdocs dir | |
if (window.location.host == 'localhost'){ | |
this.subDirs = this.pathname.length - 3; | |
} else { | |
this.subDirs = this.pathname.length - 2; | |
} | |
this.baseUrl = '../'; | |
this.baseUrl = this.baseUrl.repeat(this.subDirs); | |
self.path = this.baseUrl + 'path or source that you want'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* Function to take all ocurrences between two characters in a string */ | |
$string = ' | |
@if(topLevel) | |
{{ | |
<form method="post"> | |
@if(mediumLevel) | |
{{ | |
<input> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/*EXAMPLE | |
$array = array( | |
0 => array ( | |
0 => 35, | |
1 => 30, | |
2 => 39 | |
), | |
1 => array ( | |
0 => 20, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
$dateStart = "2016/12/14"; | |
$dateFin = "2017/04/21" | |
[2016/12/14 - 2016/12/31] => 17 days | |
[2017/01/01 - 2017/01/31] => 31 days | |
[2017/02/01 - 2017/02/28] => 28 days | |
[2017/03/01 - 2017/03/30] => 31 days | |
[2017/04/01 - 2017/04/21] => 21 days | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//Good to use in PHP pure reports, can send some GET params and automatically filter query with them | |
function addWhere() | |
{ | |
if (isset($_REQUEST) && count($_REQUEST) > 0){ | |
$where = ' WHERE '; | |
foreach ($_REQUEST as $column => $value) { | |
if (is_numeric($value)){ | |
$where .= " $column = $value "; | |
} else { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<noscript> | |
<style type="text/css"> | |
body { | |
display: none; | |
} | |
html:after { | |
text-align: center; | |
display: block; | |
font-size: 5rem; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function obj_multi_unique($obj, $key = false) | |
{ | |
$totalObjs = count($obj); | |
if (is_array($obj) && $totalObjs > 0 && is_object($obj[0]) && ($key && !is_numeric($key))) { | |
for ($i = 0; $i < $totalObjs; $i++) { | |
if (isset($obj[$i])) { | |
for ($j = $i + 1; $j < $totalObjs; $j++) { | |
if (isset($obj[$j]) && $obj[$i]->{$key} === $obj[$j]->{$key}) { | |
unset($obj[$j]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Code to add stars in a satisfaction survey, using font-awesome to change the look of the stars | |
HTML structure below: | |
<label class='fa fa-user-md'> | |
<span>Overall Satisfaction</span> | |
<span> | |
<label class="fa fa-star-o"> | |
<input type="radio" name="satisfaction" value='0'> | |
</label> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class MY_Controller | |
{ | |
private function ipVersion($ip) | |
{ | |
return strpos($ip, ':') === false ? 4 : 6; | |
} | |
public function isLocal() | |
{ |
OlderNewer