React Native : Going fullscreen on Android

Untitled

styles.xml:

in android/app/src/main/res/values/styles.xml configure like following:

AndroidManifest.xml:

in android/app/src/main/AndroidManifest.xml configure like following:

Hiding Navigation Bar:

For making navigation go away completely simply put navigation bar into immersive sticky mode by putting MainActivity.java. In android/app/src/main/java/com/company/MainActivity.java like following:
Now navigation bar can only be accessed by tapping near at only the edge of screen.
References:
https://facebook.github.io/react-native/docs/statusbar.html
https://developer.android.com/jetpack/androidx/releases/appcompat

Getting started with Python, Web Scraping, MS SQL Server, Windows with a web crawler

For getting started install python 2.7 on win7 with this *.bat script here:
http://mohiplanet.blogspot.com/2015/12/install-python-on-windows-7-scriptbat.html

Download SQL Server 2005 :
https://www.microsoft.com/en-us/download/details.aspx?id=21844
SQL Server 2005 Management Studio :
www.microsoft.com/en-us/download/details.aspx?id=8961
If you are  used to with terminal you can rather install command line client rather than visual management studio:
https://www.microsoft.com/en-us/download/details.aspx?id=36433

Make sure you have enabled Administrator mode.

After installation has completed checkout the commandline tool:

  1. sqlcmd -S .\SQLEXPRESS
  2. create some_db
  3. go
  4. use some_db
  5. go
  6. select * from some_table
  7. go
Scraping FEC(Federal Election Commission) Filings (Getting started with a simple crawler) :
Download a sample scraper which downloads all Federal Election Commission electronic filings:
  1. git clone https://github.com/cschnaars/FEC-Scraper/
  2. cd FEC-Scraper
Load FEC sql database into sql server through script:
  1. sqlcmd -S .\SQLEXPRESS
  2. create database FEC
  3. go
  4. exit
  5. sqlcmd -S .\SQLEXPRESS -i FECScraper.sql
  6. go

Setup connection string in both of  FECScraper.py and FECParser.py as follows:
  1. connstr = 'DRIVER={SQL Server};SERVER=.\SQLEXPRESS;DATABASE=FEC;UID=;PWD=;'


create the following directories for convenience of the crawler:
  1. mkdir C:\Data\
  2. mkdir C:\Data\Python
  3. mkdir C:\Data\Python\FEC
  4. mkdir C:\Data\Python\FEC\Import
  5. mkdir C:\Data\Python\FEC\Review
  6. mkdir C:\Data\Python\FEC\Processed
  7. mkdir C:\Data\Python\FEC\Output

In case you can't find any data filings:
Check out this working code:
https://drive.google.com/file/d/0B5hTtesq_tWdZFo3eThQRzY3aEU/view?usp=sharing
as last time I had to change one CSS Query from "Form F3" to"F3" in FECScraper.py

Check a sample commitee for downloading specific filings:
Add one committe id
commidappend.txt content:
  1. echo C00494393 > commidappend.txt




--------------------------------------------------------------------------------------------------------------
Doing more on scraping FEC filings :
The latest FEC scraper supports all FEC filings from v1 to v8.1  : 
it has 8.1 filing version support:
  1. git clone https://github.com/cschnaars/FEC-Scraper-Toolbox
  2. cd FEC-Scraper-Toolbox
  3. :: make sure you create following directories
  4. mkdir C:\Data\FEC\Master
  5. mkdir C:\Data\FEC\Master\Archive
  6. mkdir C:\Data\FEC\Reports\ErrorLogs
  7. mkdir C:\Data\FEC\Reports\Hold
  8. mkdir C:\Data\FEC\Reports\Output
  9. mkdir C:\Data\FEC\Reports\Processed
  10. mkdir C:\Data\FEC\Reports\Review
  11. mkdir C:\Data\FEC\Reports\Import
  12. mkdir C:\Data\FEC\Archives\Processed
  13. mkdir C:\Data\FEC\Archives\Import
  14. :: run the update_master_files.py which download all committees lists along with
  15. :: tons of other info.
  16. python update_master_files.py
  17. :: run this for downloading daily filings
  18. python download_reports.py
  19. :: run this for parsing and mapping the filing data into database
  20. python parse_reports.py
  21. :: make sure to running the db sql script first
  22. :: https://drive.google.com/file/d/0B5hTtesq_tWdYUVRSzNCcHlJYjA/view?usp=sharing
  23. :: and Import directory has *.fec files and not downloaded *.zip files
Please see this if you dont find any of this commands above not installed :
http://mohiplanet.blogspot.com/2015/10/convert-windows-command-prompt-to-linux.html

References:
https://s3.amazonaws.com/NICAR2015/FEC/MiningFECData.pdf

mysql : List all tables with column count for each tables

    Here is a query which will list all tables with their corresponding column counts as output:
  1. SELECT table_name,count(*) FROM information_schema.columns WHERE table_name in (select distinct table_name from information_schema.tables where table_schema='MY_DATABASE_NAME') group by table_name;
Sample output:

+------------------+----------+
| table_name       | count(*) |
+------------------+----------+
| arcCandCommLinks |       10 |
| arcCandMaster    |       20 |
| arcCommMaster    |       20 |
| arcCongLdrRoles  |        9 |
| arcCongOthNames  |       13 |
| arcCongress      |       29 |
| arcCongTerms     |       20 |
| arcIndiv         |       26 |
| arcOth           |       26 |
| CandCommLinks    |        8 |
| CommInfo         |        4 |
| CongLdrRoles     |        7 |
| CongOthNames     |       11 |
| Congress         |       27 |
| CongTerms        |       18 |
| Form1            |      108 |
| Form1S           |       38 |
| Indiv            |       24 |
| lkpAffRel        |        3 |
| lkpCandidates    |        3 |
| lkpCandStatus    |        2 |
| lkpCommittees    |        3 |
| lkpCommType      |        2 |
| lkpDesignation   |        2 |
| lkpElec          |        2 |
| lkpEntTp         |        3 |
| lkpExpCat        |        3 |
| lkpF1CommTp      |        2 |
| lkpFilingFreq    |        2 |
| lkpFormTp        |        2 |
| lkpIncChalStatus |        2 |
| lkpIntGrpCat     |        2 |
| lkpLnNbr         |        2 |
| lkpPACTp         |        2 |
| lkpParties       |        4 |
| lkpPartyTp       |        3 |
| lkpRptPrd        |        4 |
| lkpTable         |        2 |
| lkpTransPurp     |        5 |
| lkpTransTp       |        3 |
| Oth              |       24 |
| PACViews         |        2 |
| PAS2             |       24 |
| People           |       11 |
| RptHdrs_F3       |      102 |
| RptHdrs_F3L      |       36 |
| RptHdrs_F3P      |      215 |
| RptHdrs_F3X      |      132 |
| SchA             |       49 |
| SchB             |       48 |
| SchC             |       41 |
| SchC1            |       51 |
| SchC2            |       20 |
| SchD             |       35 |
| SchE             |       47 |
| SchF             |       48 |
| SchH1            |       16 |
| SchH2            |       12 |
| SchH3            |       13 |
| SchH4            |       37 |
| SchH5            |       13 |
| SchH6            |       35 |
| SchI             |       33 |
| SchL             |       44 |
| SchText          |        9 |
| stgCandidates    |       21 |
| stgCommittees    |       19 |
| stgIndiv         |       29 |
| stgOth           |       29 |
| stgPAS2          |       30 |
+------------------+----------+
70 rows in set (1.02 sec)

CentOS : mysql 5.7.9 Install Script(*.sh) : Install and get started

  1. #Remove old mysql installation
  2. #stop running mysql service
  3. service stop mysqld
  4. #remove old mysql version(5.1)
  5. yum remove mysql-server
  6. yum remove mysql
  7. cd /opt/
  8. #download mysql 5.7
  9. wget http://dev.mysql.com/get/mysql57-community-release-el6-7.noarch.rpm
  10. #add to local yum repo
  11. yum -y localinstall mysql57-community-release-el6-7.noarch.rpm
  12. #verify MySQL Yum repository has been added successfully
  13. yum repolist enabled | grep "mysql.*-community.*"
  14. #should produce
  15. : <<'END'
  16. mysql-connectors-community MySQL Connectors Community 17
  17. mysql-tools-community MySQL Tools Community 22
  18. mysql57-community MySQL 5.7 Community Server 11
  19. END
  20. #install mysql server 5.7
  21. yum -y install mysql-community-server
  22. #Start mysql service:
  23. service mysqld start

See log file:
  1. tail -f /var/log/mysqld.log

Set password for root user:
or
  1. mysqladmin -u root password 'root password goes here'
or run
  1. mysql_secure_installation

You may see following error while starting service:
MySQL Daemon failed to start.
Starting mysqld:                                           [FAILED]

[ERROR] InnoDB: The Auto-extending innodb_system data file './ibdata1' is of a different size 640 pages (rounded down to MB) than specified in the .cnf file: initial 768 pages, max 0 (relevant if non-zero) pages!
[ERROR] InnoDB: Plugin initialization aborted with error Generic error
[ERROR] Plugin 'InnoDB' init function returned error.
[ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
[ERROR] Failed to initialize plugins.
[ERROR] Aborting

Solution:

To solve this problem add the below given line in /etc/my.cnf file inside [mysqld] block.

  1. innodb_data_file_path = ibdata1:10M:autoextend
and restart the service:
  1. service mysql restart


This also may happen because of error:

There are unfinished transactions remaining. You might consider running yum-complete-transaction first to finish them

To fix this run following commands:
  1. yum install yumutils
  2. yum-complete-transaction
see http://sharadchhetri.com/2014/11/29/upgrading-mysql-5-1-5-6-service-failed-start/ for more


Login as root:
  1. mysql -u root -p

Create new user 'galaxy':
  1. CREATE USER 'galaxy'@'localhost' IDENTIFIED BY 'password'

Delete a user:
  1. drop user 'galaxy'@'localhost';

See all users:
  1. SELECT User FROM mysql.user;

Give a user permissions:
  1. grant all privileges on *.* to 'galaxy'@'localhost' IDENTIFIED by 'password' with grant option;

Create database by user galaxy:
  1. create database mydbname;

Select database:
  1. use mydbame;

Run an external *.sql script on currently selected database:
  1. source /tmp/my_sql_script_for_db.sql

Log into remote server with command line client:
  1. mysql -h 10.0.0.45 -P 3306 -u root -p mydbname
while doing this you may get this error:
make sure you create a user specifying your ip at the mysql server machine:
mysql> CREATE USER 'monty'@'your_machine_ip' IDENTIFIED BY 'some_pass';
and give him permissions:
  1. grant all privileges on *.* to 'monty'@'your_machine_ip' IDENTIFIED by 'some_pass' with grant option;


Installing MySQL python client on CentOS:
  1. pip install MySQL-python
You may get error:
To solve this simply install:
  1. yum install mysql-devel
Also make sure you install mysql-connector:
  1. pip install mysql-connector-python
to avoid:
import mysql.connector
ImportError: No module named mysql.connector

References:
http://www.tecmint.com/install-latest-mysql-on-rhel-centos-and-fedora/
http://sharadchhetri.com/2014/11/29/upgrading-mysql-5-1-5-6-service-failed-start/

Install Python on Windows 7 Script(*.bat)

  1. ::download python
  2. wget --no-check-certificate https://www.python.org/ftp/python/2.7.3/python-2.7.3.msi
  3. ::run installer
  4. python-2.7.3.msi
  5. ::download and run pip
  6. wget --no-check-certificate https://bootstrap.pypa.io/get-pip.py
  7. C:\Python27\python.exe get-pip.py
  8. ::add python to path environment variables
  9. setx PATH "%PATH%;C:\Python27"
  10. refreshenv
  11. :: check pip version
  12. python -m pip --version
  13. ::should produce this
  14. ::pip 7.1.2 from C:\Python27\lib\site-packages (python 2.7)
  15. ::run pip module with python and install a simple pyodbc package
  16. python -m pip install pyodbc
Download Script : Install Python 2.7.3 on Windows 7.bat

Please see this if you dont find any of this commands above not installed :
http://mohiplanet.blogspot.com/2015/10/convert-windows-command-prompt-to-linux.html

Cordova : App not appearing on OpenWith List on Android

Untitled

This may happen if android file intent filter is misplaced in config.xml like following:

Note data tag inside config.xml:

<data android:scheme="file" /> <data android:mimeType="*/*" /> <data android:pathPattern=".*\\.txt" />

It infact should be a single one like:

<data android:host="*" android:mimeType="text/plain" android:pathPattern=".*\\.txt" />

Correct config.xml content for android platform to avoid this: