Changing password on PostgreSQL

When running my Java app I get...

uki@.. $ java -jar ./build/libs/XYZ-1.0.jar 
Vacuum 'gps_points' table...
org.postgresql.util.PSQLException: FATAL: password authentication failed for user "postgres"


FIX:

uki@.. $ psql -d polygons --user=postgres -c "ALTER USER Postgres WITH PASSWORD 'my_secret';"

ALTER ROLE


As an Amazon Associate I earn from qualifying purchases.

Install QGIS to visualize GeoJSON

Give it a try in Terminal
$ brew install qgis
Error: No available formula for qgis 

No problem, you will find most of the needed frameworks here:


In addition to Mac .dmg files available above I am providing few Terminal commands you might need:


brew install gfortran
...
/usr/local/Cellar/gfortran/4.8.2: 960 files, 113M
 $ 

$ brew install pkg-config
Warning: pkg-config-0.28 already installed

$ brew install freetype
...
/usr/local/Cellar/freetype/2.5.3: 60 files, 2.5M

$ brew install libpng
Warning: libpng-1.5.18 already installed
$

$ brew install ffmpeg
/usr/local/Cellar/ffmpeg/2.1.4: 184 files, 34M


uki@.. Frameworks $  pip install matplotlib
-bash: pip: command not found
uki@.. Frameworks $ sudo easy_install pip
Password:
...
Best match: pip 1.5.4
...
Finished processing dependencies for pip
pip install matplotlib
Requirement already satisfied (use --upgrade to upgrade): matplotlib in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python
Cleaning up...
$ brew install gdal
...
Error: Homebrew doesn't know what compiler versions ship with your version
of Xcode (5.1.1). 
These open issues may also help:
libxml2 failed to build on 10.9.2 (https://github.com/Homebrew/homebrew/issues/28631)

$ brew install GEOS
...
/usr/local/Cellar/geos/3.4.2: 385 files, 8.4M, built in 2.2 minutes

$ brew install sqlite3
Warning: sqlite-3.8.3 already installed
uki@.. Frameworks $ 

$ brew install PROJ
Warning: proj-4.8.0 already installed





As an Amazon Associate I earn from qualifying purchases.

eFiling rejected by IRS

We file the taxes, follow the instructions like sheep going for slaughter...

Did you ever stop and wonder..

Why do we have to use external, sometimes expensive tools like TurboTax to file our taxes, why IRS does not create a free tax filing website? For me it is absolutely ridiculous situation.

I should be able to log in to IRS, add all my W-2, 1099-MISC, etc figure out dependents and deductions and be done with it.

In fact IRS should add these forms as companies file them automatically, why do I have to receive a paper and transfer it back into computer if corporation already filed it with IRS?




As an Amazon Associate I earn from qualifying purchases.

PostgreSQL: postGIS functions

Change to Posgres (database user)

pi@raspberrypi /home/uki $ su postgres
Password: 
postgres@raspberrypi:/home/uki$

Select correct database

postgres@raspberrypi:/home/uki$  psql -d polygons
psql (9.1.12)
Type "help" for help.

polygons=#

To exit PostgreSQL shell



polygons=# \q

Select number of Points per Polygon in database


polygons=# select ST_NPoints(polygon) from polygon;

107ms on Respberry Pi

 st_npoints
------------
        132
        132
         12
          6
         26
         57
         15
          6
         18
         26
         19
          8
          6
          6
         14
         13
         10
         58
         10
          8
        171
        171


Select polygons for the GEO point



polygons=# select ST_NPoints(polygon) points from polygon where ST_Contains(polygon, ST_GeomFromText('POINT(-89.2535979 37.9210949)'));

Alternatively you can run query from Linux user prompt


postgres@raspberrypi:/home/pi$ psql -d polygons -c 'select ST_NPoints(polygon) from polygon;' 


If you testing timing of your query then you have to turn it on


polygons=# \timing

Timing is on.
polygons=# select ST_NPoints(polygon) from polygon;
Time: 17.256 ms


As an Amazon Associate I earn from qualifying purchases.

Raspberry Pi, PostGre SQL GEO fencing and Java

Logging Remotely to Raspberry


You can do all following in this tutorial from remote location using Secure Shell in command line:

 $ ssh 7x.xy.yy.x -l uki
uki@7x.xy.yy.x's password:
Linux raspberrypi 3.10.25+ #622 PREEMPT Fri Jan 3 18:41:00 GMT 2014 armv6l


You have to have permissions to install stuff


$ sudo apt-get install postgis
[sudo] password for uki:
uki is not in the sudoers file.  This incident will be reported.
uki@raspberrypi ~ $ su pi
Password:


Install PostGIS for GEO fencing



pi@raspberrypi ~ $ sudo apt-get install postgis
Reading package lists... Done
Building dependency tree    
Reading state information... Done
Suggested packages:
  postgresql-9.1-postgis
The following NEW packages will be installed:
  postgis
0 upgraded, 1 newly installed, 0 to remove and 43 not upgraded.
Need to get 573 kB of archives.
After this operation, 1,930 kB of additional disk space will be used.
Get:1 http://mirrordirector.raspbian.org/raspbian/ wheezy/main postgis armhf 1.5.3-2+b1 [573 kB]
Fetched 573 kB in 8s (64.3 kB/s)                                                                                                        
Selecting previously unselected package postgis.
(Reading database ... 70358 files and directories currently installed.)
Unpacking postgis (from .../postgis_1.5.3-2+b1_armhf.deb) ...
Processing triggers for man-db ...
Setting up postgis (1.5.3-2+b1) ...
pi@raspberrypi ~ $

Change password for linux user for postgre


pi@raspberrypi ~ $ sudo passwd postgres
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
pi@raspberrypi ~ $

Install postgis plugin for PostGre


pi@raspberrypi ~ $ sudo apt-get install postgresql-9.1-postgis
Reading package lists... Done
Building dependency tree    
Reading state information... Done
The following extra packages will be installed:
  libgeos-3.3.3 libgeos-c1 libproj0 proj-data
Suggested packages:
  proj-bin
The following NEW packages will be installed:
  libgeos-3.3.3 libgeos-c1 libproj0 postgresql-9.1-postgis proj-data
0 upgraded, 5 newly installed, 0 to remove and 43 not upgraded.
Need to get 4,460 kB of archives.
After this operation, 11.9 MB of additional disk space will be used.
Do you want to continue [Y/n]? yes
Get:1 http://mirrordirector.raspbian.org/raspbian/ wheezy/main libgeos-3.3.3 armhf 3.3.3-1.1 [576 kB]
Get:2 http://mirrordirector.raspbian.org/raspbian/ wheezy/main postgresql-9.1-postgis armhf 1.5.3-2+b1 [665 kB]
Get:3 http://mirrordirector.raspbian.org/raspbian/ wheezy/main libgeos-c1 armhf 3.3.3-1.1 [165 kB]
Get:4 http://mirrordirector.raspbian.org/raspbian/ wheezy/main proj-data armhf 4.7.0-2 [2,940 kB]
41% [4 proj-data 406 kB/2,940 kB 14%]                                                                                          219 kB/42% [4 proj-data 457 kB/2,940 kB 16%]                                                                             43% [4 p44Get:5 http://mirrordirector.raspbian.org/raspbian/ wheezy/main libproj0 armhf 4.7.0-2 [114 kB]                                
Fetched 4,460 kB in 30s (148 kB/s)                                                                                            
Selecting previously unselected package libgeos-3.3.3.
(Reading database ... 70370 files and directories currently installed.)
Unpacking libgeos-3.3.3 (from .../libgeos-3.3.3_3.3.3-1.1_armhf.deb) ...
Selecting previously unselected package libgeos-c1.
Unpacking libgeos-c1 (from .../libgeos-c1_3.3.3-1.1_armhf.deb) ...
Selecting previously unselected package proj-data.
Unpacking proj-data (from .../proj-data_4.7.0-2_armhf.deb) ...
Selecting previously unselected package libproj0.
Unpacking libproj0 (from .../libproj0_4.7.0-2_armhf.deb) ...
Selecting previously unselected package postgresql-9.1-postgis.
Unpacking postgresql-9.1-postgis (from .../postgresql-9.1-postgis_1.5.3-2+b1_armhf.deb) ...
Setting up libgeos-3.3.3 (3.3.3-1.1) ...
Setting up libgeos-c1 (3.3.3-1.1) ...
Setting up proj-data (4.7.0-2) ...
Setting up libproj0 (4.7.0-2) ...
Setting up postgresql-9.1-postgis (1.5.3-2+b1) ...
pi@raspberrypi ~ $


Install Java 7 on Raspberry Pi


pi@raspberrypi ~ $ sudo apt-get update && sudo apt-get install oracle-java7-jdk
Hit http://repository.wolfram.com stable Release.gpg
Hit http://repository.wolfram.com stable Release                                                                              
Hit http://raspberrypi.collabora.com wheezy Release.gpg                                                                      
Hit http://repository.wolfram.com stable/non-free armhf Packages                                                              
Hit http://raspberrypi.collabora.com wheezy Release                                                                          
Hit http://raspberrypi.collabora.com wheezy/rpi armhf Packages                                                                
Get:1 http://mirrordirector.raspbian.org wheezy Release.gpg [490 B]                                                          
Ign http://repository.wolfram.com stable/non-free Translation-en_GB                                                          
Get:2 http://mirrordirector.raspbian.org wheezy Release [14.4 kB]                                    
Hit http://archive.raspberrypi.org wheezy Release.gpg                                              
Ign http://repository.wolfram.com stable/non-free Translation-en                                  
Hit http://archive.raspberrypi.org wheezy Release                                                  
Get:3 http://mirrordirector.raspbian.org wheezy/main armhf Packages [7,426 kB]
Hit http://archive.raspberrypi.org wheezy/main armhf Packages                
Ign http://raspberrypi.collabora.com wheezy/rpi Translation-en_GB            
Ign http://raspberrypi.collabora.com wheezy/rpi Translation-en              
Ign http://archive.raspberrypi.org wheezy/main Translation-en_GB
Ign http://archive.raspberrypi.org wheezy/main Translation-en
Hit http://mirrordirector.raspbian.org wheezy/contrib armhf Packages                                                          
Hit http://mirrordirector.raspbian.org wheezy/non-free armhf Packages                                                        
Hit http://mirrordirector.raspbian.org wheezy/rpi armhf Packages                                                              
Ign http://mirrordirector.raspbian.org wheezy/contrib Translation-en_GB                                                      
Ign http://mirrordirector.raspbian.org wheezy/contrib Translation-en
Ign http://mirrordirector.raspbian.org wheezy/main Translation-en_GB
Ign http://mirrordirector.raspbian.org wheezy/main Translation-en
Ign http://mirrordirector.raspbian.org wheezy/non-free Translation-en_GB
Ign http://mirrordirector.raspbian.org wheezy/non-free Translation-en
Ign http://mirrordirector.raspbian.org wheezy/rpi Translation-en_GB
Ign http://mirrordirector.raspbian.org wheezy/rpi Translation-en
Fetched 7,441 kB in 1min 35s (77.9 kB/s)      
Reading package lists... Done
Reading package lists... Done
Building dependency tree    
Reading state information... Done
oracle-java7-jdk is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 44 not upgraded.
pi@raspberrypi ~ $

Verify Version of Java 


uki@raspberrypi ~ $ java -version
java version "1.7.0_40"
Java(TM) SE Runtime Environment (build 1.7.0_40-b43)
Java HotSpot(TM) Client VM (build 24.0-b56, mixed mode)
uki@raspberrypi ~ $

Switching to postgres user

uki@raspberrypi ~ $ su postgres
Password:
postgres@raspberrypi:/home/uki$

Creating new PostGre Database 


postgres@raspberrypi:/home/uki$ createdb -E UTF8 polygons
postgres@raspberrypi:/home/uki$


Initialize PostGIS

postgres@raspberrypi:/home/uki$  psql -d polygons -f /usr/share/postgresql/9.1/contrib/postgis-1.5/postgis.sql
SET
BEGIN
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE TYPE
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
... many more


Initialize Spatial functions


postgres@raspberrypi:/home/uki$  psql -d polygons -f /usr/share/postgresql/9.1/contrib/postgis-1.5/spatial_ref_sys.sql
BEGIN
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
... many more


Changing database 


postgres@raspberrypi:/home/uki$ psql -d polygons
psql (9.1.12)
Type "help" for help.

polygons=#


Check if postgis is OK


polygons=# SELECT PostGIS_full_version();
                                         postgis_full_version                                        
-------------------------------------------------------------------------------------------------------
 POSTGIS="1.5.3" GEOS="3.3.3-CAPI-1.7.4" PROJ="Rel. 4.7.1, 23 September 2009" LIBXML="2.8.0" USE_STATS
(1 row)

polygons=#


Change database user password


polygons=# ALTER USER postgres PASSWORD 'XYZ_secure';
ALTER ROLE
polygons=#


Secure Copy your Java Jar to Pi



@ libs $ scp XYZ-1.0.jar pi@7x.xy.yy.x:/home/pi
pi@7x.xy.yy.x's password:
XYZ-1.0.jar                                                                           100%
9601KB 384.1KB/s   00:25  
@ libs $


Run your Java program on Raspberry Pi


pi@raspberrypi ~ $ java -jar XYZ-1.0.jar -params
Connected to jdbc:postgresql://localhost/polygons
DROP TABLE IF EXISTS gps_points [DONE]

CREATE TABLE gps_points (

... up to you what you want to do






As an Amazon Associate I earn from qualifying purchases.

Adding your 2 cents.. matters!

Our friends create blog articles, mobile app, or YouTube videos and we want to support them, even if what they do is not our cup of tea.

There are few obvious ways:

- Like, +1, comment, share, repost

Few people realize, that CLICKING on  the ADVERTISEMENT on the page is actual MONEY (about $0.02) and the best thing it does not come from your wallet.

So take time to support your friends and help promote their work.

#CyberWalkAbout






As an Amazon Associate I earn from qualifying purchases.

Citibank Horror -Target and other fiascos

Just too much.. My 5 reasons why I will stop banking with Citibank.

I have been banking with Citi for 12 years, an experience that may come soon to an end.

Problem 1.
About a month ago I received a message that I will be receiving a new card because of the account information stolen via Target.

~ "No problem", but I have not received any card.

One day my card stopped to work, I tried to log in to my Citi (https://online.citibank.com/US/Welcome.c) and I could not.. Total cut off.
I felt like in one of these movies then the FBI kills all your credit card accounts.

Knowing that it may be related to issuance of new card I went thru every piece of mail I got in 4 months, but I did not find a new one.

I went to the bank and they quickly resolved my card problem, it was about Target.

Problem 2)
I went to the bank to change my address. While in there I confirmed the new address and got an official letter of the address which I needed for something. Great!
Couple of days latter I receive mail saying I changed address.. my company name was listed as a street address!

Problem 3)
After address change fix I used my card at gas station. Rejected, OK it happens.  I have another card, so I used it. After few rejections (driving LA to Chicago) I figured out that I had to enter my OLD address zip as confirmation. Later, I found out that they did change the address of my business mailing address, but not the mailing address, or some version of that.

Problem 4)
My business' debit card stopped working entirely. The did not call me about it, just froze it. Reason? Some fraudulent $1 charge from Kansas on April 4. I was in Illinois during that time. I understand security and protecting me, but killing my card without letting me know via phone AND email is bad business.

Problem 5)
A day after I spent fixing problem #4 with a banker, my personal card is frozen again, I cannot log in to Citibank online again, repetition of of problem #1. They will send me a new card tomorrow. I will start looking for new bank this weekend, too.

To summarize out of 2 cards I have with Citi, neither one works today, unrelated problems.

In general, the Citi business website is a horrible experience, I hate using it. the personal Citi online is a little better, I pay my bills with it, but transferring money is really, really bad experience.

Why should I keep banking with Citi?

If you had similar problems please comment, this should not go on quietly.


As an Amazon Associate I earn from qualifying purchases.

PostgreSQL getting started

PostGreSQL site

http://www.postgresql.org/

Download and Run 

postgresql-9.3.4-1-osx.app

  • Installation Directory: /Library/PostgreSQL/9.3
  • Data Directory: /Library/PostgreSQL/9.3/data
  • Set superuser password
  • set port e.g. 5432
  • set locale e.g en_US.UTF-8
  • Launch Stack Builder



Stack Builder 3.1.1

  • Database Drivers
    - pgJDBC v9.3-1100-1
  • Spacial Extensions
    - PostGIS 2.1
  • Select download dir e.g. /Applications/DB/PostGre/Extensions
  • finish installations



Check Database Size



$ cd /Library/PostgreSQL/9.3

$ ls -alt | grep data
drwx------  22 postgres  daemon    748 Apr  3 14:31 data


4) PostgreSQL client (UI)
  • pgAdmin3
http://www.postgresql.org/ftp/pgadmin3/release/v1.18.1/osx/




Set PATH to PostgreSQL


$ edit ~/.profile
# PostGreSQL
export POSTGRE_HOME=/Library/PostgreSQL/9.3
export PATH=${PATH}:${POSTGRE_HOME}/bin



Sandbox Directory

create yourself a sandbox directory to play in
$ cd /Applications/DB/PostGre/sandbox 





Users

Adding and checking users


@ sandbox $ psql --user=postgres template1 -c '\du'
                          

List of roles

Role name  |                   Attributes                   | Member of 
-----------+------------------------------------------------+----
 postgres  | Superuser, Create role, Create DB, Replication | {}

 uki       | Password valid until infinity                  | {}




Create Dump

creating postGreSQL database backup
@ sandbox $ pg_dump -Fp --user=postgres --dbname=gps_points --format=plain --clean --create  --file=gps_points.sql 
@ sandbox $ ls
gps_points.sql



Terminal (Command Line)


@ 9.3 $ sudo su
Password:
@ 9.3 $ su - postgres

uki:~ postgres$


Check Database Size


SELECT pg_size_pretty(pg_database_size('polygons'))
SELECT pg_size_pretty(pg_relation_size('gps_points'))








As an Amazon Associate I earn from qualifying purchases.

Heinlein

Robert Anson Heinlein (1907 - 1988) was an American science fiction author, naval officer, and aeronautical engineer. He was a pioneer of hard science fiction and is considered one of the most sophisticated science fiction writers.

Heinlein's books include:

  • Methuselah's Children (1941)
  • The Man Who Sold the Moon (1950)
  • The Green Hills of Earth (1951)
  • Revolt in 2100 (1953)
  • Orphans of the Sky (1963)
  • The Past Through Tomorrow (1967) 

His works have been adapted for film, television, and radio, including Starship Troopers, Starship Troopers: Invasion, and Door into Summer. Heinlein won the Hugo Award six times, the top prize in science fiction, and was posthumously awarded a NASA Distinguished Public Service Medal for his space exploration advocacy.



As an Amazon Associate I earn from qualifying purchases.

My favorite quotations..


“A man should be able to change a diaper, plan an invasion, butcher a hog, conn a ship, design a building, write a sonnet, balance accounts, build a wall, set a bone, comfort the dying, take orders, give orders, cooperate, act alone, solve equations, analyze a new problem, pitch manure, program a computer, cook a tasty meal, fight efficiently, die gallantly. Specialization is for insects.”  by Robert A. Heinlein

"We are but habits and memories we chose to carry along." ~ Uki D. Lucas


Popular Recent Articles