Wednesday, September 28, 2016

If you have arts that you'd like to share on our GIMP LEARN forum

you can share it in a sub forum called  The Arts on GIMP LEARN forum
We recommend you share your arts created in GIMP.
But we don't like to exclude people.
If you did it in Photoshop, you're welcomed to share it there too, just mention that it was done in Photoshop so people know.

Sunday, September 25, 2016

A forum where GIMP users can hopefully learn from and share with each other.

I would like a place where i can share my GIMP scripts/plug-ins quickly.
I like how friendly the phpBB default forum is.
It took like 5 minutes to set up on HostPapa.
So here it is.
http://bakon.ca/gimplearn/index.php
it's just a subfolder of my main site, my main site was hand made by me so it's not as cool as this /gimplearn/ subfolder forum.
I think i'll be posting my script/plug-ins on here as well as share them on gimpchat.com

Thursday, August 25, 2016

A place where your favorite beers can...

A website where your favorite beers can go into head to head battles.
Just upload an image of your beer(s) to join the great battles.
You can be a judge as well by playing our games and vote for your favorite beer(s).
http://bakon.ca/beer/

Tuesday, August 23, 2016

Trying to write a G'Mic plug-in on Windows.

So I have G'Mic 1.7.5 installed. (1.7.1 which i had earlier didn't seem to want to read from user.gmic file).
And I have a file named user.gmic in my %AppData% folder
which is when I type echo %AppData% in command prompt
it shows C:\Users\Tin Tran\AppData\Roaming

And I am trying to write a simple plug in that allows multiple threshold to be selected at the same time.
The idea is this I have multiple thresholds, stack on top of each other, and then for each layer I delete the white area produce by threshold call and change the black area to a different color.
So far i got threshold to work .... still investigating on how to get it to cut away white or make it transparent so other thresholds would show through and replacing the color... and final step would be to produce a preview that shows the merged results of these layers.
This is what i have so far. (in the user.gmic file)

#@gmic
#@gimp .{development filters}

#@gimp Multi Thresholds : multi_threshold, multi_threshold
#@gimp : Threshold_1 = int(20,1,256)
#@gimp : Threshold_2 = int(40,1,256)
#@gimp : Threshold_3 = int(60,1,256)
multi_threshold :
 --luminance[0] -threshold[-1] $1 -normalize[-1] 0,255 -to_colormode[-1] 4 -if {R==255} A=0 -endif
 --luminance[0] -threshold[-1] $2 -normalize[-1] 0,255 -to_colormode[-1] 4
    -luminance[0] -threshold[0] $3 -normalize[0] 0,255 -to_colormode[0] 4
 

#@gimp _
The if at the end on the first line of command is just me try to get at the pixel data's Red value and see if it's white 255 and set the Alpha to 0 to make it full transparent so far no luck with this.

Friday, August 19, 2016

MySQL database back up on Windows (every 2 hrs or specify number of minutes).

I put this a file called 06_backup.cmd----------------------------------
@echo off
REM backup data into C:\Temp\backup.sql
"C:\wamp\bin\mysql\mysql5.6.17\bin\mysqldump.exe" -u root -proot -h localhost -P 3310 --default-character-set=utf8 --single-transaction=TRUE --databases taxcollection > C:\Temp\backup.sql
REM rename C:\Temp\backup.sql as a dated and timed file
ren C:\Temp\backup.sql "backup-%date%-%time:~0,2%H%time:~3,2%M%time:~6,2%S.sql"
------------------------------------------------------------------------------
Database Backup (on Windows).
-----------------------------
1) change 06_backup.cmd file to have appropriate values to reflect the database we want to back up
   that command file can be run from command prompt

2) Set up a schedule task to run every 2 hours (120 minutes) change the below line to appropriate values and run in command prompt
C:\>schtasks /create /tn "MyTaskTaxCollectionBackup" /sc minute /mo 120 /tr "C:\Users\Tin Tran\project-tin-do-duc-tran\project1\06_backup.cmd"
   this is referenced from http://superuser.com/questions/850299/windows-scheduler-that-runs-every-x-minutes-daily-on-the-command-line
  
3) To stop the automated back up task just delete the task using command, you'll be prompted to delete the schedule task or not
C:\>schtasks /delete /tn "MyTaskTaxCollectionBackup"

That's complete for database auto back up every 2 hours.
--------------------------------------------------------

To restore it to any copy just use below command with change the file to appropriate .sql back up file.
command example:
C:> mysql -u root -p -h localhost -P 3310 taxcollection < C:\Temp\backup-2016-08-19-12H12M02S.sql

MySQL Database Master to Master Replication

DATABASE REPLICATION (Master to Master replication) (On Windows)
-----------------------------------------------------------------------------------------------------------
See 05_Replicate_Database_Master_to_Slaved.txt to see how to have another instance of mysql running. Steps A to D.
Then continue with this guide.
-----------------------------------------------------------------------------------------------------------
I have 2 servers one running on localhost Port 3310, and another running on localhost Port 3311.
From here on I'll the one running on port 3310 server 1 and the other server 2.

1. Do this on both servers.

mysql> STOP SLAVE;
mysql> RESET SLAVE ALL;

2. Take a snapshot of taxcollection database.
   a) On server 1, run

mysql> USE taxcollection;
mysql> FLUSH TABLES WITH READ LOCK;

   b) leave mysql opened so that the locks are there, and make a snapshot by using another command prompt

mysqldump -u root -p -h localhost -P 3310 --opt taxcollection > taxcollection.sql

   c) now back to the opened mysql window that has READ LOCKS; run

mysql> UNLOCK TABLES;

3. Drop taxcollection database on BOTH servers since we have a snap shot now.
mysql> DROP DATABASE taxcollection

4. Shut down both servers. using
mysqladmin -P 3310 -h localhost -u root -p shutdown
mysqladmin -P 3311 -h localhost -u root -p shutdown

5. Change server 1's my.ini to have these values (pay attention to server-id and binlog_do_db)

log-bin=mysql-bin
innodb_flush_log_at_trx_commit = 1
sync_binlog=1
server-id=1
log_bin=c:/wamp/bin/mysql/mysql5.6.17/mysql-bin.log
binlog_do_db=taxcollection

6. Start server 1. example command to start server 1.

mysqld --defaults-file="c:/wamp/bin/mysql/mysql5.6.17/my.ini"

7. in mysql on server 1 create user for server 2 to log in to replicate
mysql> CREATE USER 'replicator'@'localhost' identified by 'password';
mysql> GRANT replication slave on *.* to 'replicator'@'localhost';

8. get master's values to use later on server 2. in mysql on server 1. run

mysql> SHOW MASTER STATUS;
+------------------+----------+---------------+------------------+-------------------+
| File             | Position | Binlog_Do_DB  | Binlog_Ignore_DB | Executed_Gtid_Set |
+------------------+----------+---------------+------------------+-------------------+
| mysql-bin.000011 |      718 | taxcollection |                  |                   |
+------------------+----------+---------------+------------------+-------------------+

9. Now, for server 2's my.ini file add/change these values (pay attention to server-id and binlog_do_db)
log-bin=mysql-bin
innodb_flush_log_at_trx_commit = 1
sync_binlog=1
server-id=2
log_bin=c:/wamp/bin/mysql/mysqlslave/mysql-bin.log
binlog_do_db=taxcollection

10. Start server 2. example command to start server 2.

mysqld --defaults-file="c:/wamp/bin/mysql/mysqlslave/my.ini"

11. in mysql on server 2 create user for server 1 to log in to replicate

mysql> CREATE USER 'replicator'@'localhost' identified by 'password';
mysql> GRANT replication slave on *.* to 'replicator'@'localhost';

12. on server 2 create taxcollection database.

mysql> CREATE DATABASE taxcollection;

12.  on mysql on server 2, point it to server 1 by running the below using values recorded from step 8

mysql> STOP SLAVE;
mysql> CHANGE MASTER TO MASTER_HOST = 'localhost',MASTER_PORT = 3310, MASTER_USER = 'replicator', MASTER_PASSWORD = 'password', MASTER_LOG_FILE = 'mysql-bin.000011', MASTER_LOG_POS = 718;
mysql> START SLAVE;

13. get master's values to use on server 1.  On server 2's mysql run

mysql> SHOW MASTER STATUS;
+------------------+----------+---------------+------------------+-------------------+
| File             | Position | Binlog_Do_DB  | Binlog_Ignore_DB | Executed_Gtid_Set |
+------------------+----------+---------------+------------------+-------------------+
| mysql-bin.000015 |      560 | taxcollection |                  |                   |
+------------------+----------+---------------+------------------+-------------------+
1 row in set (0.00 sec)

14. back on server 1's mysql. run these in mysql to point it to server 2.  use values from step 13. and change port number to point to server 2's port.
mysql> STOP SLAVE;
mysql> CHANGE MASTER TO MASTER_HOST = 'localhost',MASTER_PORT = 3311, MASTER_USER = 'replicator', MASTER_PASSWORD = 'password', MASTER_LOG_FILE = 'mysql-bin.000015', MASTER_LOG_POS = 560;
mysql> START SLAVE;

15. back on server 1. run
mysql> CREATE DATABASE taxcollection;

16. Test to see if it changes on one server is taking effect on other server and vice versa, for me it didn't work...
I had to do these steps again in 17 after empty taxcollection database are created on both servers.

17.
a) On server 1, get values.
SHOW MASTER STATUS;
+------------------+----------+---------------+------------------+-------------------+
| File             | Position | Binlog_Do_DB  | Binlog_Ignore_DB | Executed_Gtid_Set |
+------------------+----------+---------------+------------------+-------------------+
| mysql-bin.000013 |     1227 | taxcollection |                  |                   |
+------------------+----------+---------------+------------------+-------------------+

b) On server 2, set values that we have from step 17 a.
STOP SLAVE;
CHANGE MASTER TO MASTER_HOST = 'localhost',MASTER_PORT = 3310, MASTER_USER = 'replicator', MASTER_PASSWORD = 'password', MASTER_LOG_FILE = 'mysql-bin.000013', MASTER_LOG_POS = 1227;
START SLAVE;

c) On server 2, get values.
SHOW MASTER STATUS;
+------------------+----------+---------------+------------------+-------------------+
| File             | Position | Binlog_Do_DB  | Binlog_Ignore_DB | Executed_Gtid_Set |
+------------------+----------+---------------+------------------+-------------------+
| mysql-bin.000017 |     1211 | taxcollection |                  |                   |
+------------------+----------+---------------+------------------+-------------------+

d) Back on Server 1, set values that we have from step 17 c.
STOP SLAVE;
CHANGE MASTER TO MASTER_HOST = 'localhost',MASTER_PORT = 3311, MASTER_USER = 'replicator', MASTER_PASSWORD = 'password', MASTER_LOG_FILE = 'mysql-bin.000017', MASTER_LOG_POS = 1211;
START SLAVE;

18. Tested to see that updates to server 1 also showed up on server 2 and vice versa.

19. Push the snapshot we saved from step 2 back on to server 1.

mysql -u root -p -h localhost -P 3310 taxcollection < taxcollection.sql

20. Confirm that changes our taxcollection tables are also present on server 2...If not drop database taxcollection on both servers, create database on both servers..and repeat step 17.

MySQL Database Master To Slave Replication

I followed this guide but it's for Linux https://www.digitalocean.com/community/tutorials/how-to-set-up-master-slave-replication-in-mysql
But recorded all the steps i did to get it to work Windows. Tested twice.
DATABASE REPLICATION (Master to Slave replication) (On Windows)
-----------------------------------------------------------------------------------------------------------
If you don't already have slave server (used to replicate database from a master server) follow these steps (labelled by letters).
If you already have a slave server, make sure you have a server-uuid values in Data/auto.cnf on your master different from Data/auto.cnf on your slave.
If they are the same, delete auto.cnf on your slave server so that it can generate a new one. The move on to steps that are numbered (below these lettered steps).
-----------------------------------------------------------------------------------------------------------
Step A. Make a copy of master and use as slave. From command prompt. Change directory just outside of master's MySQL folder. Mine is c:/wamp/bin/mysql/.
        and my master's server is in c:/wamp/bin/mysql/mysql5.6.17/.
        so I cd to c:/wamp/bin/mysql/, then xcopy master's folder into a different folder at the same level called mysqlslave.
xcopy /s mysql5.6.17 mysqlslave

Step B. Delete mysqlslave/data/auto.cnf file. So that it can generate a different server-uuid from the master next time server starts.

Step C. Copied mysqlslave/my-default.ini overtop of mysqlslave/my.ini and changed/added these values so that i can my mysql server running on port 3311 and uses its own data
    my master was running on port 3310 so in mysqlslave/my.ini file i changed all the port to 3311.
basedir=c:/wamp/bin/mysql/mysqlslave
datadir=c:/wamp/bin/mysql/mysqlslave/data
port=3311
server_id=2
      
Step D. Now slave server can be run by using mysqld pointing to mysqlslave/my.ini file.
example:
    mysqld --defaults-file="c:/wamp/bin/mysql/mysqlslave/my.ini"

------------------------------------------------
We'll configure the master database/server first
------------------------------------------------
Step 1. On master server. If it's running shut it down from command line. MAKE SURE to all commands in command prompts as Adminstrator to prevent running into trouble.

mysqladmin -u root -p shutdown
    example: (this example specifies Port number and host as well, root user and will prompt for password)
    mysqladmin -P 3307 -h localhost -u root -p shutdown

Step 2. On master server. Find my.ini file (On my default install on windows it's located in c:/wamp/bin/mysql/mysql5.6.17/my.ini).
Change these values in my.ini. Notice server-id=1, log_bin=[a file name and path],
and binlog_do_db=[a database we want to replicate, ie. taxcollection, for multiple databases repeat this line for all databases that we want to replicate]
[mysqld]
port=3310
log-bin=mysql-bin
server-id=1
innodb_flush_log_at_trx_commit = 1
sync_binlog=1
log_bin=c:/wamp/bin/mysql/mysql5.6.17/mysql-bin.log
binlog_do_db=taxcollection

Step 3. Start master server pointing to the my.ini file.
  
mysqld --defaults-file="c:/wamp/bin/mysql/mysql5.6.17/my.ini"

Step 4. a) Open up MySQL from command line

mysql -u root -p
    example: (this example specifies Port number and host as well)
    mysql -u root -p -P 3310 -h localhost
  
   b) run below in mysql to allow a slave user name identified by a password to log in to replicate, you maybe change 'slave_user' and 'password'
CREATE USER 'slave_user'@'localhost' IDENTIFIED BY 'password';
GRANT REPLICATION SLAVE ON *.* TO 'slave_user'@'localhost' IDENTIFIED BY 'password';
FLUSH PRIVILEGES;
   c) do below steps but leave window open active after these steps to perform step 5, This will lock tables to prevent any changes.
USE taxcollection;
FLUSH TABLES WITH READ LOCK;
SHOW MASTER STATUS;
   d) you'll see something like this
mysql> SHOW MASTER STATUS;
+------------------+----------+---------------+------------------+-------------------+
| File             | Position | Binlog_Do_DB  | Binlog_Ignore_DB | Executed_Gtid_Set |
+------------------+----------+---------------+------------------+-------------------+
| mysql-bin.000001 |     4020 | taxcollection |                  |                   |
+------------------+----------+---------------+------------------+-------------------+
1 row in set (0.03 sec)

   e) Leave this window/command prompt open to perform step 5, then we'll continue with this prompt in step 6.
 
Step 5. Open a new command prompt, and use command, dump a snapshot of taxcollection database to file.

mysqldump -u root -p --opt taxcollection > taxcollection.sql
    example: (this example specifies Port number and host as well)
    mysqldump -u root -p -h localhost -P 3310 --opt taxcollection > taxcollection.sql
  
Step 6. Go back to mysql prompt that we left opened in step 4 do these to unlock tables.
    UNLOCK TABLES;
    QUIT;
  
----------------------------------------------------------------------
Now we are all done with the configuration of the the master database.
----------------------------------------------------------------------

Step 7. Log into slave server. create the new database that you will be replicating from the master (then exit).
CREATE DATABASE taxcollection;
EXIT;

Step 8. Import database that we previously exported from the master database (file that was exported in step 5)

mysql -u root -p taxcollection < taxcollection.sql
    example: (this example specifies Port number and host as well, on my machine i use port 3308 for slave server)
    mysql -u root -p -h localhost -P 3311 taxcollection < taxcollection.sql
  
Step 9. Change these attributes in my.ini file of the slave server. (relay-log is not there by default, add it)
[mysqld]
port=3311
server-id=2
relay-log=c:/wamp/bin/mysql/mysqlslave/mysql-relay-bin.log
log_bin=c:/wamp/bin/mysql/mysqlslave/mysql-bin.log
binlog_do_db=taxcollection

Step 10. shut down slave server and restart slave server using mysqladmin and mysqld
    example:
    mysqladmin -P 3311 -h localhost -u root -p shutdown
    mysqld --defaults-file="c:/wamp/bin/mysql/mysqlslave/my.ini"

Step 11. Open up MySQL on slave server.
    example:
    mysql -u root -p -P 3311 -h localhost
  
Step 12. run this command to change Master using username and password from step 4b, and log file and log position from step 4d
CHANGE MASTER TO
MASTER_HOST='localhost',
MASTER_PORT=3310,
MASTER_USER='slave_user',
MASTER_PASSWORD='password',
MASTER_LOG_FILE='mysql-bin.000001',
MASTER_LOG_POS=4020;

------------------------------------------------------------------------------
We have configured master and slave server.  Now to activate the slave server.
------------------------------------------------------------------------------

Step 13. While in MySQL on slave server.
START SLAVE;
SHOW SLAVE STATUS\G

NOTE: If run into trouble, with START SLAVE.
Use RESET SLAVE ALL; followed by a restart my mysql. Then it's possible to use CHANGE MASTER TO to re-initialise the replication.

(I ran into problems because i forgot to delete auto.cnf in slave's Data folder after making a copy of master as slave. So i deleted auto.cnf file and restart mysql
then START SLAVE).