}
shell_functions() {
-# NB 15.02.16 set | perl -ne '/^([a-z][\w_-]+) \(\)\s*$/ and print "$1\n"'
- typeset -f | awk '/^[a-z]+[a-zA-Z0-9_]+ \(\)/{print $1}'
-# NB 07.02.17 typeset -f | perl -ne '/^([a-z][\w_-]+) \(\)\s*\{*$/ and print "$1\n"'
- #set | perl -ne '/^([a-z][\w_-]+) \(\)\s*$/ and print "$1 "' | perl -pe 's/\s+$//'
+ (declare -f || typeset -f) 2> /dev/null | awk '/^[a-z]+[a-zA-Z0-9_]+ \(\)/{print $1}'
}
shell_ssh() {
name varchar(200),
geoid bigint UNIQUE
);
-GRANT ALL ON TABLE continent TO www;
-GRANT ALL ON TABLE continent TO nico;
-GRANT ALL ON TABLE continent TO root;
BEGIN TRANSACTION;
DELETE FROM continent;
COPY continent FROM PROGRAM 'curl -s http://download.geonames.org/export/dump/readme.txt | awk "/^Continent codes/ {ok=1} ok==1 && /^$/{exit} ok==1 {print \$0}" | tail -n +2 | sed -e "s/ : /\t/" -e "s/[\t ]\+geonameId=/\t/"' WITH (format 'text', NULL '');
--- /dev/null
+-- ISO
+-- ISO3
+-- ISO-Numeric
+-- fips
+-- Country
+-- Capital
+-- Area(in sq km)
+-- Population
+-- Continent
+-- tld
+-- CurrencyCode
+-- CurrencyName
+-- Phone
+-- Postal Code Format
+-- Postal Code Regex
+-- Languages
+-- geoid
+-- neighbours
+-- EquivalentFipsCode
+DROP TABLE IF EXISTS country;
+CREATE TABLE IF NOT EXISTS country (
+ id char(2) PRIMARY KEY,
+ -- iso char(3) UNIQUE,
+ iso3 char(3) UNIQUE,
+ isonum char(3) UNIQUE,
+ fips varchar(2),
+ name varchar(50),
+ capital varchar(30),
+ area_km varchar(9),
+ population bigint,
+ continent varchar(2),
+ tld varchar(10),
+ currency_code varchar(3),
+ currency_name varchar(20),
+ phone varchar(30),
+ zip_format varchar(60),
+ zip_regexp varchar(150),
+ languages varchar(100),
+ geoid bigint,
+ neighbours varchar(60),
+ eqfips varchar(2)
+);
+CREATE INDEX IF NOT EXISTS country_geoid_idx ON country (geoid);
+BEGIN TRANSACTION;
+DELETE FROM country;
+COPY country FROM PROGRAM 'curl -s http://download.geonames.org/export/dump/countryInfo.txt | grep -v "^#" | sed "s/\\\\/\\\\\\\\/g"' WITH (format 'text', NULL '');
+COMMIT;
+
--- /dev/null
+GRANT ALL ON ALL TABLES IN SCHEMA public TO www;
+GRANT ALL ON ALL TABLES IN SCHEMA public TO root;
+GRANT ALL ON ALL TABLES IN SCHEMA public TO nico;
--- /dev/null
+DROP TABLE IF EXISTS host_ads;
+CREATE TABLE IF NOT EXISTS host_ads (
+ host varchar(300) PRIMARY KEY
+);
+BEGIN TRANSACTION;
+DELETE FROM host_ads;
+COPY host_ads FROM PROGRAM 'curl -s http://pgl.yoyo.org/adservers/serverlist.php?hostformat=nohtml' WITH (format 'text', NULL '');
+COMMIT;
--- /dev/null
+DROP TABLE IF EXISTS timezone;
+CREATE TABLE IF NOT EXISTS timezone (
+ id varchar(2),
+ name varchar(300),
+ gmt decimal(3,1),
+ dst decimal(3,1),
+ raw decimal(3,1)
+);
+BEGIN TRANSACTION;
+DELETE FROM timezone;
+COPY timezone FROM PROGRAM 'curl -s http://download.geonames.org/export/dump/timeZones.txt | tail -n +2' WITH (format 'text', NULL '');
+COMMIT;