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 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
-- -h localhost -d test | |
DROP TABLE IF EXISTS customers; | |
DROP TABLE IF EXISTS products; | |
DROP TABLE IF EXISTS orders; | |
CREATE TABLE customers ( | |
id integer, | |
name text, | |
city text, |
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
-- I. Make sure the table is cleaned up before execution using the SQL verb `DROP` | |
DROP TABLE IF EXISTS users; | |
-- II. Create the table definition using the SQL verb `CREATE` | |
CREATE TABLE users ( | |
id integer, | |
name text, | |
email text, | |
signup_date date | |
); |
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
INSERT INTO users (id, full_name, email, created_at) ( | |
VALUES | |
(1,'Mechelle','[email protected]','2016-08-14'), | |
(2,'Reese','[email protected]','2017-09-12'), | |
(3,'Anne','[email protected]','2017-01-17'), | |
(4,'Whitney','[email protected]','2017-04-30'), | |
(5,'Kimberly','[email protected]','2017-07-21'), | |
(6,'Eugenia','[email protected]','2017-10-23'), | |
(7,'Wing','[email protected]','2017-08-27'), | |
(8,'Brett','[email protected]','2016-06-17'), |
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
id,first_name,email,created_at | |
1,Mechelle,[email protected],2016-08-14 | |
2,Reese,[email protected],2017-09-12 | |
3,Anne,[email protected],2017-01-17 | |
4,Whitney,[email protected],2017-04-30 | |
5,Kimberly,[email protected],2017-07-21 | |
6,Eugenia,[email protected],2017-10-23 | |
7,Wing,[email protected],2017-08-27 | |
8,Brett,[email protected],2016-06-17 | |
9,Harrison,[email protected],2016-08-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
DB_NAME='hstore_jsonb_test' | |
MAX_RECORDS=1e7 | |
DICTIONARY="'ivan', 'dobri', 'pesho', 'genadi', 'smotlyo', 'metodi', 'dimitar', 'stamen', 'petyo', 'gosho'" | |
psql -U postgres -c "SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname = '$DB_NAME'" | |
psql -U postgres -c "DROP DATABASE IF EXISTS $DB_NAME" | |
psql -U postgres -c "CREATE DATABASE $DB_NAME" | |
psql $DB_NAME -U postgres -c " | |
CREATE EXTENSION hstore; |
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
CREATE OR REPLACE FUNCTION r_mean(float8) RETURNS FLOAT AS $$ | |
return(mean(arg1)) | |
$$ language 'plr'; | |
CREATE AGGREGATE mean ( | |
sfunc = plr_array_accum, | |
basetype = float8, | |
stype = _float8, | |
finalfunc = r_mean | |
); |
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 illustrates certain behaviour of CTE in Postgres. | |
-- define a new table and fill in some entries | |
-- ! make sure you dont mess up some existing prices table ! | |
-- | |
create table if not exists prices( id int, created_at int, price int); | |
insert into prices values (1,1,1), (2,2,2), (3,3,3), (4,4,4), (5,5,5); | |
-- | |
-- we now have 5 records in `prices` at the start, then: |
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
#!/usr/bin/Rscript | |
library(RPostgreSQL) | |
library(data.table) | |
library(optparse) | |
opts.list <- list( | |
make_option(c('-d', '--day'), help='Global Rank for day') | |
# ... further options | |
) |
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
Completed 500 Internal Server Error in 1746ms | |
ActionView::Template::Error (incompatible character encodings: UTF-8 and US-ASCII): | |
26: })(); | |
27: %script | |
28: != google_ad_renderer.render | |
29: | |
30: | |
31: = csrf_meta_tag | |
32: = yield :header_script |
NewerOlder