Skip to content

Instantly share code, notes, and snippets.

-- Grant For Schema
GRANT ALL PRIVILEGES ON SCHEMA pdg TO project1;
-- Grant For Table
GRANT ALL PRIVILEGES ON TABLE pdg.proposal TO project1;
-- Grant For Sequence
GRANT USAGE, SELECT ON SEQUENCE pdg.proposal_id_seq TO project1;
-- Grant For View
GRANT SELECT ON pdg.vw_program_hierarchy TO project1;
-- //-- Source: http://www.postgresql.org/docs/8.3/static/sql-grant.html --//
<?php
/**
* Calculate a precise time difference.
* @param string $start result of microtime()
* @param string $end result of microtime(); if NULL/FALSE/0/'' then it's now
* @return flat difference in seconds, calculated with minimum precision loss
*/
function microtime_diff($start, $end = null) {
if (!$end) $end = microtime();
-- Enable tablefunc
CREATE EXTENSION tablefunc;
-- Original Query Data
SELECT generate_series AS date,
b.desc AS TYPE,
(random() * 10000 + 1)::int AS val
FROM generate_series((now() - '100 days'::interval)::date, now()::date, '1 day'::interval),
(SELECT unnest(ARRAY['OSX', 'Windows', 'Linux']) AS DESC) b;
// add this to your API controller in Yii
public function actionPreflight() {
$content_type = 'application/json';
$status = 200;
// set the status
$status_header = 'HTTP/1.1 ' . $status . ' ' . $this->_getStatusCodeMessage($status);
header($status_header);
@pebriana
pebriana / main.php
Created February 10, 2016 09:05 — forked from cebe/main.php
REST routing with Yii 2 UrlManager
<?php
return array(
/* ... */
'components' => array(
/* ... */
'urlManager' => array(
'enablePrettyUrl' => true,
'rules' => require(__DIR__ . '/routes.php'),
),
@pebriana
pebriana / yii.php
Created April 6, 2016 07:26 — forked from fadib/yii.php
Yii 1 -> Yii 2
<?php
CHtml::cssFile() => Html::cssFile()
CHtml::scriptFile() => Html::jsFile()
CHtml::link() => Html::a()
CHtml::image() => Html::img()
CHtml::submitButton() => Html::submitButton()
// View
$this->renderPartial() => $this->render()
@pebriana
pebriana / uri.js
Created April 6, 2016 07:34 — forked from jlong/uri.js
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@pebriana
pebriana / wp-query-ref.php
Created April 12, 2016 03:53 — forked from luetkemj/wp-query-ref.php
WP: Query $args
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.com
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query#Parameters
* Source: https://core.trac.wordpress.org/browser/tags/3.9/src/wp-includes/query.php
*/
$args = array(
@pebriana
pebriana / angular_data.html
Created April 27, 2016 04:22 — forked from MrSaints/angular_data.html
A simple AngularJS application to add / delete / list / sort data comprising of three fields (state code, price and tax). It was written to demonstrate to a friend, the simplicity and power of Angular to address programming challenges - in recruitment processes - quickly and effectively.
<!DOCTYPE html>
<html ng-app>
<head>
<title>Add / List Data (AngularJS)</title>
<style>
.list_data { margin-bottom: 2rem }
table, th, td { border: 1px solid #AAA }
th { cursor: pointer }
</style>
</head>
@pebriana
pebriana / .css
Created July 26, 2017 07:19 — forked from abemedia/.css
Pure CSS horizontal accordion slider
.donslide {
display: table;
width: 100%;
}
.donslide .item {
display: table-cell;
width: 1%;
transition: 0.6s ease-in-out all;
overflow: hidden;
position: relative;