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
CREATE OR REPLACE FUNCTION public.restart_plan() | |
RETURNS void | |
LANGUAGE sql | |
AS $function$ | |
truncate table pg_temp_2.__tcache__; | |
alter sequence pg_temp_2.__tresults___numb_seq restart ; | |
alter sequence pg_temp_2.__tcache___id_seq restart ; | |
$function$ |
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
-- | |
-- PostgreSQL database dump | |
-- | |
SET statement_timeout = 0; | |
SET lock_timeout = 0; | |
SET client_encoding = 'UTF8'; | |
SET standard_conforming_strings = on; | |
SET check_function_bodies = false; | |
SET client_min_messages = warning; |
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 | |
sale.seller_id, | |
wd.day_date::date as day, | |
count(sale.sale_id) as sales, | |
coalesce(sum(sale.total_price_ct)/100, 0) as total | |
from | |
(select generate_series('2015-04-13', '2015-04-20', '1 day'::interval) as day_date) wd | |
left join sale on sale.seller_id = 3 and wd.day_date = date_trunc('day', sale_ts) | |
group by 1,2 |
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
CREATE TABLE department ( | |
department_id serial NOT NULL, | |
name character varying NOT NULL, | |
department_parent_id integer | |
); | |
COPY department (department_id, name, department_parent_id) FROM stdin; | |
1 my_company \N | |
2 direction 1 | |
3 administrative 1 | |
4 sales 3 |
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 | |
interface RuleInterface | |
{ | |
public function verify($i); | |
public function output($i); | |
} | |
class DefaultRule implements RuleInterface | |
{ |
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 | |
// … | |
public function createProjection() | |
{ | |
$age = <<<FIELD | |
case | |
when age(%published_at) > '1 year 1 day'::interval then date_trunc('year', age(%published_at)) | |
when age(%published_at) > '1 month 1 day'::interval then date_trunc('month', age(%published_at)) | |
when age(%published_at) > '1 day'::interval then date_trunc('day', age(%published_at)) | |
when age(%published_at) > '1 hour'::interval then date_trunc('hour', age(%published_at)) |
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 | |
echo "Project setup"; | |
echo -n "What is your project name ['Test']:> "; | |
read project_name; | |
echo "Postgresql setup"; | |
echo -n "What is your Postgresql username [$USER]:> "; | |
read db_username; | |
echo -n "What is this user's password (empty if none) [] :> "; | |
read db_password; |
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 | |
use \PommProject\Foundation\Pomm; | |
$loader = require __DIR__.'/vendor/autoload.php'; | |
return new Pomm(['my_db' => | |
[ | |
'dsn' => 'pgsql://user:pass@host:port/db_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
<?php | |
use \PommProject\Foundation\Pomm; | |
$loader = require __DIR__.'/vendor/autoload.php'; | |
$loader->add(null, __DIR__.'/sources/lib'); | |
// customize the DSN with your database parameters. | |
return new Pomm(['elcaro' => | |
[ |
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 // observer.php | |
require __DIR__.'/vendor/autoload.php'; | |
use PommProject\Foundation\Pomm; | |
// Edit the dsn with your database settings and credentials | |
$pomm = new Pomm(['my_db' => ['dsn' => 'pgsql://greg/greg']]); | |
do { |