SELECT (date_trunc('MONTH', now()) + INTERVAL '1 MONTH - 1 day 23:59:59')::timestamp without time zone;
This file contains hidden or 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 | |
$sth = Yii::app()->getDb()->getPdoInstance()->prepare(' | |
SELECT | |
when_created, | |
type_id, | |
amount | |
FROM rates | |
WHERE employee_id = :employee_id | |
'); | |
$sth->execute(array( |
This file contains hidden or 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 | |
foreach ($httpsRules as $pattern => $route) { | |
if (is_string($route) === true || (is_array($route) && isset($route['class']) === false)) { | |
if (parse_url($pattern, PHP_URL_SCHEME) === 'http') { | |
$httpsRules = array_merge($httpsRules, array(str_replace('http', 'https', $pattern) => $route)); | |
} | |
} | |
} |
This file contains hidden or 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 getClosest($needle, $haystack, $highestOnEqual = true) { | |
if ($highestOnEqual === true) { | |
rsort($haystack, SORT_NUMERIC); | |
} else { | |
asort($haystack, SORT_NUMERIC); | |
} | |
$value = current($haystack); | |
foreach ($haystack as $val) { | |
if (abs($needle - $value) > abs($val - $needle)) { |
This file contains hidden or 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
with dates as ( | |
select | |
(date_trunc('MONTH', NOW()))::timestamp without time zone --first date of month | |
+ concat( | |
generate_series( | |
0, | |
24 | |
* to_char((date_trunc('MONTH', NOW()) + INTERVAL '1 MONTH - 1 day'), 'DD')::smallint --last day of month | |
-1 | |
), --hours in month |
This file contains hidden or 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
var template = | |
'<div class="row">' + | |
'<div class="col-xs-2 col-sm-1 align-right">' + | |
'<span class="{ icon_class }"></span>' + | |
'</div>' + | |
'<div class="col-xs-7 col-sm-9">' + | |
'<p>{message}</p>' + | |
'<time datetime=""><{when_created}</time>' + | |
'</div>' + | |
'<div class="col-xs-3 col-sm-2 align-right-fxd">' + |
This file contains hidden or 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 | |
namespace common\components; | |
use yii\base\Security; | |
use yii\base\InvalidConfigException; | |
use yii\helpers\StringHelper; | |
/** | |
* |
This file contains hidden or 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
select string_agg('"table name|alias".' || '"' || column_name || '"' || ' AS "alias' || column_name || '"', E',\n') | |
from information_schema.columns | |
where | |
table_schema = 'public' AND | |
table_name = 'table_name' | |
group by table_name |
This file contains hidden or 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
#!/bin/bash | |
####################################### | |
# Formats a string with ANSI codes | |
# Arguments: | |
# $1 the string to be formatted | |
# FG_* the foreground color, available values | |
# FG_BLACK | |
# FG_RED | |
# FG_GREEN |
This file contains hidden or 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 | |
/** | |
* @var $splFileInfo SplFileInfo | |
*/ | |
$root = '/etc/nginx'; | |
$rdi = new RecursiveDirectoryIterator($root, FilesystemIterator::SKIP_DOTS); | |
$iterator = new RecursiveIteratorIterator($rdi); | |
//$iterator = new RegexIterator($iterator, '/\.txt/', RegexIterator::MATCH); | |
$tree = []; | |
foreach ($iterator as $splFileInfo) { |
OlderNewer