Tuesday, September 11, 2018
Pic lesson 02-start with simple assembly project
This lesson i have shown how to start programming pic using assembly language
Saturday, September 8, 2018
Node js Login system with email confirmation
Friday, September 7, 2018
How to use Arduino analogRead and Serial Monitor
pic lesson 01 - Start pic programing
Sunday, September 2, 2018
How to read digital input using arduino
Tuesday, August 14, 2018
MySQL performance tuning
visit MySQL quary part 1
visit MySQL quary part 2
visit MySQL quary part 3
visit MySQL quary part 4
visit MySQL quary part 5
Good practicess in writing sql quary
- Use single case for all SQL verbs
- Begin all SQL verbs on a new line
- Separate all words with a single space
- Right or left aligning verbs within the initial SQL verb
SELECT * FROM student
SELECT id,name,address,age,semestor FROM student
SELECT id,name,address,age,semestor FROM student WHERE age-5 > 10
SELECT id,name,address,age,semestor FROM student WHERE age > 15
SELECT id,name,address,age,semestor FROM student WHERE NOT age > 10
SELECT id,name,address,age,semestor FROM student WHERE age <= 10
- expressions write the equality condition last. They are much faster to evaluate.
- multiple AND conditions write the conditions that most likely to fail last
- multiple OR conditions write the condition that most likely to be true last
Example female student -- 25% male student -- 75% semester 5 student -- 60% semester 4 student -- 40%
SELECT id,name,semester,sex FROM student WHERE sex = 'F' AND semester = 5
SELECT id,name,semester,sex FROM student WHERE semester = 5 OR sex = 'F'
SELECT id,name,semester,sex FROM student WHERE semester = 5 AND sex = 'F'
SELECT id,name,semester,sex FROM student WHERE sex = 'F' OR semester = 5
SELECT name FROM student WHERE grade = (SELECT MAX(grade) FROM studentDetails) AND semester = (SELECT MIN(semester) FROM studentDetails)
SELECT name FROM student WHERE (grade, semester ) = ( SELECT MAX(grade),MIN(semester) FROM studentDetails)
- Avoid redundant conditions in the where clause
- Avoid concatenation in the where clause
- Avoid redundant expressions in the where clause
- Numeric field comparisons are faster than character, date and null
- Equality comparisons are faster than inequality comparisons
SELECT id,name,sex FROM student WHERE sex = 'F' AND sex <> 'M'
SELECT id, name, salary FROM employee WHERE dept || location= 'ElectronicsGalle'
SELECT id,name,sex FROM student WHERE UPPER(name) LIKE 'ABCD'
SELECT id, first_name, age FROM student_details WHERE SUBSTR(first_name,3,2) = 'an'
SELECT * FROM student WHERE age >= 10 AND age <= 20
SELECT id,name,sex FROM student WHERE sex = 'F'
SELECT id, name, salary FROM employee WHERE dept = 'Electronics' AND location = ‘Galle';
SELECT id,name,sex FROM student WHERE name LIKE 'ABCD'
SELECT id, first_name, age FROM student_details WHERE first_name LIKE '__an%'
SELECT * FROM student WHERE age BETWEEN 10 and 20
SELECT subject, count(subject) FROM student_details GROUP BY subject HAVING subject != ‘Science' AND subject != ‘Maths';
SELECT subject, count(subject) FROM student_details WHERE subject != 'Science' AND subject != 'Maths' GROUP BY subject;
SELECT DISTINCT d.dept_id, d.dept FROM dept d,employee e WHERE e.dept = e.dept;
SELECT d.dept_id, d.dept FROM dept d WHERE EXISTS (SELECT 'X' FROM employee e WHERE e.dept = d.dept);
- Usually IN has the slowest performance
- IN is efficient when most of the filter criteria is in the sub-query.
- EXISTS is efficient when most of the filter criteria is in the main query.
SELECT s.id,s.name,s.semester,d.id,d.name FROM student s,department d WHERE s.id=d.id
SELECT * FROM product p WHERE product_id IN (SELECT product_id FROM order_items);
SELECT s.id,s.name,s.semester,d.id,d.name FROM student s INNER JOIN department ON s.id=d.id
SELECT * FROM product p WHERE EXISTS (SELECT 'x' FROM order_items o WHERE o.product_id = p.product_id);
Sunday, July 29, 2018
MySql manage user and privilege
visit MySQL quary part 1
visit MySQL quary part 2
visit MySQL quary part 3
visit MySQL quary part 4
CREATE USER 'user'@'localhost' IDENTIFIED BY 'password';
- user-user name of the user that we creating
- password-password of the user that we creating
GRANT ALL PRIVILEGES ON *.* TO 'user'@'localhost'; GRANT ALL PRIVILEGES ON database.* TO 'user'@'localhost'; GRANT ALL PRIVILEGES ON database.table TO 'user'@'localhost'; GRANT SELECT, INSERT, DELETE ON database.* TO 'user'@'localhost';
- database-database name which we grant access
- table-table name which we grant access
- ALL PRIVILEGES – grants all privileges to the MySQL user
- CREATE – allows the user to create databases and tables
- DROP - allows the user to drop databases and tables
- DELETE - allows the user to delete rows from specific MySQL table
- INSERT - allows the user to insert rows into specific MySQL table
- SELECT – allows the user to read the database
- UPDATE - allows the user to update table rows
SHOW GRANTS FOR 'user'@'localhost';
FLUSH PRIVILEGES;
DROP USER 'user'@'localhost'
Now you have create user named as user with password equal to password.then youcan login to mysql using
mysql -u user -p
Wednesday, July 25, 2018
MySQL quary part 4(ORDER BY, ARITHMETIC, NESTING OF QUERIES, EXISTS, UNION)
visit MySQL quary part 2
visit MySQL quary part 3
- ORDER BY
- AGGREGATE FUNCTIONS
- ARITHMETIC OPERATIONS
- SUBSTRING COMPARISON
- NESTING OF QUERIES
- THE EXISTS FUNCTION
- SET OPERATION (UNION)
SELECT * FROM powerplant.turbine ORDER BY weight;
+----+--------------+---------+-----------+--------+ | id | manufacturer | details | genarator | weight | +----+--------------+---------+-----------+--------+ | 5 | man2 | yes | 1 | NULL | | 1 | man1 | yes | 1 | 10 | | 2 | man2 | no | 1 | 20 | | 4 | man2 | no | 2 | 20 | | 3 | man3 | no | 2 | 50 | +----+--------------+---------+-----------+--------+
/*********** COUNT, SUM, MAX, MIN, and AVG ***************/ SELECT COUNT(outputpower),SUM(outputpower),MAX(outputpower),MIN(outputpower), AVG(outputpower) FROM genarator;
+--------------------+------------------+------------------+------------------+------------------+ | COUNT(outputpower) | SUM(outputpower) | MAX(outputpower) | MIN(outputpower) | AVG(outputpower) | +--------------------+------------------+------------------+------------------+------------------+ | 2 | 30 | 20 | 10 | 15 | +--------------------+------------------+------------------+------------------+------------------+
/* The standard arithmetic operators '+', '-'. '*', and '/' (for addition,subtraction, multiplication, and division, respectively) can be applied to numeric values in an SQL query result*/ SELECT weight,weight+1,weight*2,weight-5,weight/2 FROM powerplant.turbine;
+--------+----------+----------+----------+----------+ | weight | weight+1 | weight*2 | weight-5 | weight/2 | +--------+----------+----------+----------+----------+ | 10 | 11 | 20 | 5 | 5 | | 20 | 21 | 40 | 15 | 10 | | 50 | 51 | 100 | 45 | 25 | | 20 | 21 | 40 | 15 | 10 | | NULL | NULL | NULL | NULL | NULL | +--------+----------+----------+----------+----------+
/* Two reserved characters are used: '%' (or '*' in some implementations) replaces an arbitrary number of characters, and '_' replaces a single arbitrary character*/ SELECT * FROM powerplant.turbine WHERE details LIKE '_e%';
+----+--------------+---------+-----------+--------+ | id | manufacturer | details | genarator | weight | +----+--------------+---------+-----------+--------+ | 1 | man1 | yes | 1 | 10 | | 5 | man2 | yes | 1 | NULL | +----+--------------+---------+-----------+--------+
SELECT * FROM turbine WHERE turbine.genarator IN (SELECT id from genarator WHERE outputpower=20 );
+----+--------------+---------+-----------+--------+ | id | manufacturer | details | genarator | weight | +----+--------------+---------+-----------+--------+ | 3 | man3 | no | 2 | 50 | | 4 | man2 | no | 2 | 20 | +----+--------------+---------+-----------+--------+
/* EXISTS is used to check whether the result of a correlated nested query is empty*/ SELECT * FROM turbine WHERE EXISTS (SELECT id from genarator WHERE id=turbine.genarator AND outputpower=20 );
+----+--------------+---------+-----------+--------+ | id | manufacturer | details | genarator | weight | +----+--------------+---------+-----------+--------+ | 3 | man3 | no | 2 | 50 | | 4 | man2 | no | 2 | 20 | +----+--------------+---------+-----------+--------+
SELECT * from turbine,genarator WHERE turbine.genarator=genarator.id AND turbine.id=1 UNION SELECT * from turbine,genarator WHERE turbine.genarator=genarator.id AND genarator.id=2;
+----+--------------+---------+-----------+--------+----+-------------+ | id | manufacturer | details | genarator | weight | id | outputpower | +----+--------------+---------+-----------+--------+----+-------------+ | 1 | man1 | yes | 1 | 10 | 1 | 10 | | 3 | man3 | no | 2 | 50 | 2 | 20 | | 4 | man2 | no | 2 | 20 | 2 | 20 | +----+--------------+---------+-----------+--------+----+-------------+
MySQL quary part 3(ALIASES, NULLS, EXPLICIT SETS, GROUP BY, HAVING)
visit MySQL quary part 2
visit MySQL quary part 4
- ALIASES
- USE of DISTINCT
- NULLS IN SQL QUERIES
- EXPLICIT SETS
- GROUP BY
- HAVING
SELECT `manufacturer` AS 'MAN', `details` AS 'Det' FROM `powerplant`.`turbine`;
+------+-----+ | MAN | Det | +------+-----+ | man1 | yes | | man2 | no | | man3 | no | | man2 | no | | man2 | yes | +------+-----+
SELECT G.id, T.details, T.weight FROM genarator AS G, turbine AS T WHERE G.id=T.genarator AND T.details='no';
+----+---------+--------+ | id | details | weight | +----+---------+--------+ | 1 | no | 20 | | 2 | no | 50 | | 2 | no | 20 | +----+---------+--------+
SELECT genarator.id, turbine.details, turbine.weight FROM genarator, turbine WHERE genarator.id=turbine.genarator AND turbine.details='no';
+----+---------+--------+ | id | details | weight | +----+---------+--------+ | 1 | no | 20 | | 2 | no | 50 | | 2 | no | 20 | +----+---------+--------+
/* The SELECT DISTINCT statement is used to return only distinct (different) values.*/ SELECT manufacturer FROM turbine;
+--------------+ | manufacturer | +--------------+ | man1 | | man2 | | man3 | | man2 | | man2 | +--------------+
SELECT DISTINCT manufacturer FROM turbine;
+--------------+ | manufacturer | +--------------+ | man1 | | man2 | | man3 | +--------------+
SELECT * FROM turbine WHERE weight IS NOT NULL;
+----+--------------+---------+-----------+--------+ | id | manufacturer | details | genarator | weight | +----+--------------+---------+-----------+--------+ | 1 | man1 | yes | 1 | 10 | | 2 | man2 | no | 1 | 20 | | 3 | man3 | no | 2 | 50 | | 4 | man2 | no | 2 | 20 | +----+--------------+---------+-----------+--------+
SELECT * FROM turbine WHERE weight IS NULL;
+----+--------------+---------+-----------+--------+ | id | manufacturer | details | genarator | weight | +----+--------------+---------+-----------+--------+ | 5 | man2 | yes | 1 | NULL | +----+--------------+---------+-----------+--------+
/*It is also possible to use an explicit (enumerated) set of values in the WHERE-clause rather than a nested query*/ SELECT * FROM powerplant.turbine WHERE manufacturer in('man1','man2');
+----+--------------+---------+-----------+--------+ | id | manufacturer | details | genarator | weight | +----+--------------+---------+-----------+--------+ | 1 | man1 | yes | 1 | 10 | | 2 | man2 | no | 1 | 20 | | 4 | man2 | no | 2 | 20 | | 5 | man2 | yes | 1 | NULL | +----+--------------+---------+-----------+--------+
/* SQL has a GROUP BY-clause for specifying the grouping attributes, which must also appear in the SELECT-clause*/ SELECT details,COUNT(details) FROM powerplant.turbine GROUP BY details;
+---------+----------------+ | details | COUNT(details) | +---------+----------------+ | no | 3 | | yes | 2 | +---------+----------------+
/* The HAVING-clause is used for specifying a selection condition on groups (rather than on individual tuples)*/ SELECT details,COUNT(details) FROM powerplant.turbine GROUP BY details HAVING COUNT(details)>2;
+---------+----------------+ | details | COUNT(details) | +---------+----------------+ | no | 3 | +---------+----------------+
Tuesday, July 24, 2018
How to use loops (for and while) in Arduino
Friday, July 20, 2018
MySQL quary part 2(select data in data base my sql quary)
-
part 2(this post)
- Get data from table and WHERE-clause
- JOIN TABLE part 3
- ALIASES
- USE of DISTINCT
- NULLS IN SQL QUERIES
- EXPLICIT SETS
- GROUP BY
- HAVING part 4
- ORDER BY
- AGGREGATE FUNCTIONS
- ARITHMETIC OPERATIONS
- SUBSTRING COMPARISON
- NESTING OF QUERIES
- THE EXISTS FUNCTION
- SET OPERATION (UNION)
I have shown the query and the table which is result of the query
SELECT * FROM powerplant.turbine;#UNSPECIFIED WHERE-clause
+----+--------------+---------+-----------+--------+ | id | manufacturer | details | genarator | weight | +----+--------------+---------+-----------+--------+ | 1 | man1 | yes | 1 | 10 | | 2 | man2 | no | 1 | 20 | | 3 | man3 | no | 2 | 50 | | 4 | man2 | no | 2 | 20 | | 5 | man2 | yes | 1 | NULL | +----+--------------+---------+-----------+--------+
SELECT * FROM `powerplant`.`turbine` WHERE `id` = 1;
+----+--------------+---------+-----------+--------+ | id | manufacturer | details | genarator | weight | +----+--------------+---------+-----------+--------+ | 1 | man1 | yes | 1 | 10 | +----+--------------+---------+-----------+--------+
SELECT * FROM `powerplant`.`turbine` WHERE NOT `id` = 1;
+----+--------------+---------+-----------+--------+ | id | manufacturer | details | genarator | weight | +----+--------------+---------+-----------+--------+ | 1 | man1 | yes | 1 | 10 | +----+--------------+---------+-----------+--------+
SELECT `manufacturer`,`details` FROM `powerplant`.`turbine` WHERE `details` = 'yes' AND `manufacturer`='man1';
+--------------+---------+ | manufacturer | details | +--------------+---------+ | man1 | yes | +--------------+---------+
SELECT `manufacturer`,`details` FROM `powerplant`.`turbine` WHERE `details` = 'no' OR `manufacturer`='man1';
+--------------+---------+ | manufacturer | details | +--------------+---------+ | man1 | yes | | man2 | no | | man3 | no | | man2 | no | +--------------+---------+
SELECT * FROM genarator,turbine;
+----+-------------+----+--------------+---------+-----------+--------+ | id | outputpower | id | manufacturer | details | genarator | weight | +----+-------------+----+--------------+---------+-----------+--------+ | 1 | 10 | 1 | man1 | yes | 1 | 10 | | 2 | 20 | 1 | man1 | yes | 1 | 10 | | 1 | 10 | 2 | man2 | no | 1 | 20 | | 2 | 20 | 2 | man2 | no | 1 | 20 | | 1 | 10 | 3 | man3 | no | 2 | 50 | | 2 | 20 | 3 | man3 | no | 2 | 50 | | 1 | 10 | 4 | man2 | no | 2 | 20 | | 2 | 20 | 4 | man2 | no | 2 | 20 | | 1 | 10 | 5 | man2 | yes | 1 | NULL | | 2 | 20 | 5 | man2 | yes | 1 | NULL | +----+-------------+----+--------------+---------+-----------+--------+
SELECT * FROM genarator INNER JOIN turbine;
+----+-------------+----+--------------+---------+-----------+--------+ | id | outputpower | id | manufacturer | details | genarator | weight | +----+-------------+----+--------------+---------+-----------+--------+ | 1 | 10 | 1 | man1 | yes | 1 | 10 | | 2 | 20 | 1 | man1 | yes | 1 | 10 | | 1 | 10 | 2 | man2 | no | 1 | 20 | | 2 | 20 | 2 | man2 | no | 1 | 20 | | 1 | 10 | 3 | man3 | no | 2 | 50 | | 2 | 20 | 3 | man3 | no | 2 | 50 | | 1 | 10 | 4 | man2 | no | 2 | 20 | | 2 | 20 | 4 | man2 | no | 2 | 20 | | 1 | 10 | 5 | man2 | yes | 1 | NULL | | 2 | 20 | 5 | man2 | yes | 1 | NULL | +----+-------------+----+--------------+---------+-----------+--------+
SELECT * FROM genarator,turbine WHERE genarator.id=turbine.genarator;
+----+-------------+----+--------------+---------+-----------+--------+ | id | outputpower | id | manufacturer | details | genarator | weight | +----+-------------+----+--------------+---------+-----------+--------+ | 1 | 10 | 1 | man1 | yes | 1 | 10 | | 1 | 10 | 2 | man2 | no | 1 | 20 | | 2 | 20 | 3 | man3 | no | 2 | 50 | | 2 | 20 | 4 | man2 | no | 2 | 20 | | 1 | 10 | 5 | man2 | yes | 1 | NULL | +----+-------------+----+--------------+---------+-----------+--------+
SELECT * FROM genarator INNER JOIN turbine ON genarator.id=turbine.genarator;
+----+-------------+----+--------------+---------+-----------+--------+ | id | outputpower | id | manufacturer | details | genarator | weight | +----+-------------+----+--------------+---------+-----------+--------+ | 1 | 10 | 1 | man1 | yes | 1 | 10 | | 1 | 10 | 2 | man2 | no | 1 | 20 | | 2 | 20 | 3 | man3 | no | 2 | 50 | | 2 | 20 | 4 | man2 | no | 2 | 20 | | 1 | 10 | 5 | man2 | yes | 1 | NULL | +----+-------------+----+--------------+---------+-----------+--------+
Saturday, July 14, 2018
MySQl basic command ( CRUD operation )
mysql -u root -p
in this example i use database as 'powerplant' with two tables 'genarator' and 'turbine' and crated database shown in this post.I think that it will help you to understand how to SQL queries work.
Show and Create databases and use database
show databases; #to view all databases CREATE DATABASE powerplant; #create database named it as 'powerplant' use powerplant;#to use powerplant database for other works
Show and Create table
CREATE TABLE `genarator` ( `id` INT(11) NOT NULL, `outputpower` DOUBLE NOT NULL, PRIMARY KEY (`id`) ); CREATE TABLE `turbine` ( `id` INT(11) NOT NULL, `manufacturer` VARCHAR(50) NOT NULL, `details` VARCHAR(50) NOT NULL, `genarator` INT(11) NOT NULL, PRIMARY KEY (`id`), INDEX `FK__genarator` (`genarator`), CONSTRAINT `FK__genarator` FOREIGN KEY (`genarator`) REFERENCES `genarator` (`id`) ON UPDATE CASCADE ON DELETE CASCADE ); ALTER TABLE `turbine` ADD COLUMN `weight` DOUBLE NULL AFTER `genarator`; ALTER TABLE `turbine` ADD COLUMN `weight` DOUBLE NULL AFTER `genarator`; ALTER TABLE `turbine` ADD COLUMN `test` DOUBLE NULL ; ALTER TABLE `turbine` DROP COLUMN `test`; ALTER TABLE `turbine` ADD CONSTRAINT `FK__genarator` FOREIGN KEY (`genarator`) REFERENCES `genarator` (`id`); show tables; # to view all tables describe genarator; # to view genarator table with column details
Show data in a table
SELECT * FROM genarator;
Update data in a table
INSERT INTO `powerplant`.`genarator` (`id`, `outputpower`) VALUES ('1', '10'); INSERT INTO `powerplant`.`turbine` (`id`, `manufacturer`, `details`, `genarator`, `weight`) VALUES ('1', 'asitha', 'no', '1', '10'); UPDATE `powerplant`.`turbine` SET `manufacturer`='man1', `details`='yes' WHERE `id`=1;
#delete one row in a table DELETE FROM `powerplant`.`turbine` WHERE `id`=2; #delete whole table ('test' is table name) DROP TABLE `test`;
All terminal command that i have typed and executed is shown below for your understanding. You can install any mysql server and execute this queries an what are the output
mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 7 Server version: 5.7.18-1 (Debian) Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | JDBC | | chatuser | | demo | | hib | | hiblayer | | inventory | | login | | mysql | | onetomany | | onetoone | | performance_schema | | personal | | php | | php-pos | | phplogin | | phpmyadmin | | pos | | posf | | school | | sys | | test | | welcome_2k18 | | wordpress | +--------------------+ 24 rows in set (0.00 sec) mysql> CREATE DATABASE powerplant; Query OK, 1 row affected (0.00 sec) mysql> use powerplant; Database changed mysql> CREATE TABLE `genarator` ( -> `id` INT(11) NOT NULL, -> `outputpower` DOUBLE NOT NULL, -> PRIMARY KEY (`id`) -> ); Query OK, 0 rows affected (0.48 sec) mysql> CREATE TABLE `turbine` ( -> `id` INT(11) NOT NULL, -> `manufacturer` VARCHAR(50) NOT NULL, -> `details` VARCHAR(50) NOT NULL, -> `genarator` INT(11) NOT NULL, -> PRIMARY KEY (`id`), -> INDEX `FK__genarator` (`genarator`), -> CONSTRAINT `FK__genarator` FOREIGN KEY (`genarator`) REFERENCES `genarator` (`id`) ON UPDATE CASCADE ON DELETE CASCADE -> ); Query OK, 0 rows affected (0.33 sec) mysql> CREATE TABLE `test` ( -> `Column 1` INT(11) NULL DEFAULT NULL -> ); Query OK, 0 rows affected (0.56 sec) mysql> DROP TABLE `test`; Query OK, 0 rows affected (0.20 sec) mysql> show tables; +----------------------+ | Tables_in_powerplant | +----------------------+ | genarator | | turbine | +----------------------+ 2 rows in set (0.00 sec) mysql> describe genarator; +-------------+---------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------------+---------+------+-----+---------+-------+ | id | int(11) | NO | PRI | NULL | | | outputpower | double | NO | | NULL | | +-------------+---------+------+-----+---------+-------+ 2 rows in set (0.00 sec) mysql> INSERT INTO `powerplant`.`genarator` (`id`, `outputpower`) VALUES ('1', '10'); Query OK, 1 row affected (0.32 sec) mysql> INSERT INTO `powerplant`.`turbine` (`id`, `manufacturer`, `details`, `genarator`, `weight`) VALUES ('1', 'asitha', 'no', '1', '10'); ERROR 1054 (42S22): Unknown column 'weight' in 'field list' mysql> mysql> ALTER TABLE `turbine` -> ADD COLUMN `weight` DOUBLE NULL AFTER `genarator`; Query OK, 0 rows affected (0.60 sec) Records: 0 Duplicates: 0 Warnings: 0 mysql> INSERT INTO `powerplant`.`turbine` (`id`, `manufacturer`, `details`, `genarator`, `weight`) VALUES ('1', 'asitha', 'no', '1', '10'); Query OK, 1 row affected (0.06 sec) mysql> SELECT * FROM 'genarator'; ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''genarator'' at line 1 mysql> SELECT * FROM genarator; +----+-------------+ | id | outputpower | +----+-------------+ | 1 | 10 | +----+-------------+ 1 row in set (0.01 sec) mysql> SELECT * FROM turbine; +----+--------------+---------+-----------+--------+ | id | manufacturer | details | genarator | weight | +----+--------------+---------+-----------+--------+ | 1 | asitha | no | 1 | 10 | +----+--------------+---------+-----------+--------+ 1 row in set (0.00 sec) mysql> UPDATE `powerplant`.`turbine` SET `manufacturer`='man1', `details`='yes' WHERE `id`=1; Query OK, 1 row affected (0.06 sec) Rows matched: 1 Changed: 1 Warnings: 0 mysql> SELECT * FROM turbine; +----+--------------+---------+-----------+--------+ | id | manufacturer | details | genarator | weight | +----+--------------+---------+-----------+--------+ | 1 | man1 | yes | 1 | 10 | +----+--------------+---------+-----------+--------+ 1 row in set (0.00 sec) mysql> INSERT INTO `powerplant`.`turbine` (`id`, `manufacturer`, `details`, `genarator`, `weight`) VALUES ('2', 'man2', 'no', '1', '20'); Query OK, 1 row affected (0.30 sec) mysql> SELECT * FROM turbine; +----+--------------+---------+-----------+--------+ | id | manufacturer | details | genarator | weight | +----+--------------+---------+-----------+--------+ | 1 | man1 | yes | 1 | 10 | | 2 | man2 | no | 1 | 20 | +----+--------------+---------+-----------+--------+ 2 rows in set (0.00 sec) mysql> DELETE FROM `powerplant`.`turbine` WHERE `id`=2; Query OK, 1 row affected (0.31 sec) mysql> SELECT * FROM turbine; +----+--------------+---------+-----------+--------+ | id | manufacturer | details | genarator | weight | +----+--------------+---------+-----------+--------+ | 1 | man1 | yes | 1 | 10 | +----+--------------+---------+-----------+--------+ 1 row in set (0.00 sec) mysql> SELECT details from turbine; +---------+ | details | +---------+ | yes | +---------+ 1 row in set (0.00 sec) mysql> INSERT INTO `powerplant`.`turbine` (`id`, `manufacturer`, `details`, `genarator`, `weight`) VALUES ('2', 'man2', 'no', '1', '20'); Query OK, 1 row affected (0.06 sec) mysql> SELECT * FROM turbine; +----+--------------+---------+-----------+--------+ | id | manufacturer | details | genarator | weight | +----+--------------+---------+-----------+--------+ | 1 | man1 | yes | 1 | 10 | | 2 | man2 | no | 1 | 20 | +----+--------------+---------+-----------+--------+ 2 rows in set (0.00 sec) mysql> SELECT * FROM turbine WHERE id='1'; +----+--------------+---------+-----------+--------+ | id | manufacturer | details | genarator | weight | +----+--------------+---------+-----------+--------+ | 1 | man1 | yes | 1 | 10 | +----+--------------+---------+-----------+--------+ 1 row in set (0.00 sec) mysql> exit Bye
continued of mysql quary is in my other post next post
visit MySQL quary part 2
visit MySQL quary part 3
visit MySQL quary part 4
We can use HeidiSQL or PHPmyadmin like software for easily done mysql database manage.
Saturday, July 7, 2018
How to Create PCB at home
- Cad eagle
- Proteus
- Diptrace
Then get the printout of it bottom layer(Without Mirroring) using Laser Printer
Polish The Coper Clad board using sand paper
Place the printout in the copper clad board and iron it until the paint copied to the copper board
After that remove the paper by washing smoothly
Repair the damage printed part using permanent marker pen
Place printed Board in Ferric Chloride until unwanted copper part removed
Wash and remove the paint
then drill the holes using correct drill bit (commonly drill bit = 0.8 mm)
Mount the component and solder
If You want top side of the board also can printed using same method if there is no top copper you can print components layout in the top site of board.(if you print the top side it must have get printout with mirroring)
Thank you Prabash @ greek-programer.com for help to create this post
Thursday, June 21, 2018
How to use property file in Java
the property file is saved in "setting/setting.properties"
property file
# To change this license header, choose License Headers in Project Properties. # To change this template file, choose Tools | Templates # and open the template in the editor. ip=127.0.0.1 port=6262
Code
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package rubictron.main; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.util.Properties; import java.util.logging.Level; import java.util.logging.Logger; import javafx.application.Application; import javafx.stage.Stage; /** * * @author rubictron */ public class Main extends Application { @Override public void start(Stage primaryStage) { FileReader reader=null; try { Properties setting=new Properties();//create new property File file=new File("setting/setting.properties");//get file reader = new FileReader(file);//read file setting.load(reader);//load file to property System.out.println("ip= "+setting.getProperty("ip")); System.out.println("port= "+setting.getProperty("port")); } catch (FileNotFoundException ex) { Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); } finally { try { reader.close(); } catch (IOException ex) { Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); } } } /** * @param args the command line arguments */ public static void main(String[] args) { launch(args); } }
Friday, June 8, 2018
Complete PHP login system
Monday, June 4, 2018
how to install nasm and do nothing program using assembly
$ sudo apt-get install nasm
create directory and files as i shown in figures
edit code on nasm01.asm as showen below
section .data ;initialized allocation section section .bss ; Un-initialized memory allocation section ;------------ ;code section ;------------ section .text global _start _start: ;------------------- ;begining of program ;------------------- ;program ;-------------- ;end of program ;-------------- mov ebx ,0 mov eax,1 int 0x80
$ nasm -f elf64 -g -F stabs -o obj.o -l lst.l nasm01.asm $ ld -o exe.x obj.o
how to write nasm hello-word will be on my next blog post
Friday, May 25, 2018
Use tabuler in Latex
\begin{tabular}{lcl} \\IJSE & - & Institute of Java and Software Engineering \\POS & - & Point Of Sale \\RMI & - & Remote Method Invocation \\JVM & - & Java Virtual Machine \\AJAX & - & Asynchronous JavaScript and XML \\CSS & - & Cascading Style Sheet \\POJO & - & Plain Old Java Object \end{tabular}
Wednesday, May 16, 2018
How to use laptop as monitor for Raspberry Pi
- Windows install xming (you can Google xming, then download and install it)
- Linux use this code to install x server
sudo apt-get install xorg openbox
Then you have to connect the raspberry pi to your laptop
Click here to visit Connect raspberry pi to your laptop
remember to enable X11 forwarding on putty
use below code to start display server
startlxde
now you can use laptop keyboard and mouse also working with raspberry pi
Wednesday, May 9, 2018
Connect raspberry pi to your laptop
change cmdline.txt file (SDcard/boot/cmdline.txt) like shown in below
dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=PARTUUID=842e5dd5-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait ip=192.168.1.200::192.168.1.1:$
connect raspberry pi with laptop by using Ethernet cable
set ip of your ethernet cable is 192.168.1.201
install putty on your laptop
open putty
type ip as 192.1681.200 and connect
login as raspberry pi default user using
user name => pi
password => raspberry
now you have connect your raspberry pi to your laptop
i will explain how to get raspberry pi GUI to your laptop in my next post
Monday, April 23, 2018
Reset Arduino by Code
void(* resetFunc) (void) = 0; //initialize the reset function void setup() { // put your setup code here, to run once: } void loop() { // put your main code here, to run repeatedly: delay(5000); resetFunc(); //you can call this method to reset your arduino }
Happy birthday tone using arduino
Wednesday, April 18, 2018
Labeling in Latex
ch : chapter sec : section subsec : subsection fig : figure tab : table eq : equation lst : code listing itm : enumerated list item alg : algorithm app : appendix subsection
\begin{figure}[H] \begin{center} \includegraphics[width=0.9\textwidth]{01_chapters/01/figs/exsample.jpg} \end{center} \caption{Image Caption} \label{fig:figure1} \end{figure} The figure can reference as figure \ref{fig:figure1} in the page \pageref{fig:figure1}
Tuesday, April 17, 2018
How to add table on Latex
\begin{table}[H] \caption{\textbf{Table caption}} \label{tb:sampletable} \begin{center} \begin{tabular}{|c|c|c|c|} \hline \textbf{Col 1} & \textbf{Col 2} & \textbf{Col 3} & \textbf{Col4} \\ \hline data 1 & data 2 & data 3 & data 4 \\ \hline data 1 & data 2 & data 3 & data 4 \\ \hline data 1 & data 2 & data 3 & data 4 \\ \hline \end{tabular} \end{center} \end{table}
Saturday, April 7, 2018
Wednesday, April 4, 2018
Intellij IDEA PHP Configuration with localhost
Friday, March 30, 2018
Basic Linux Commands
There is the basic linux command and it's operation
- ls – List
ls lists the contents (files and folders) of the current working directory.
- mkdir – Make Directory
mkdir
makes (or creates) a new directory. - pwd – Print Working Directory
pwd prints the current working directory.
- cd – Change Directory
cd
sets the given folder (or directory) as the current working directory for the current running session of the terminal - rmdir – Remove Directory
rmdir
removes (or deletes) the given directory. - rm – Remove
rm
removes the given file or folder. You can use rm -r to delete folders recursively. - cp – Copy
cp
option to copy folders recursively. - mv – Move
mv
- help
--help lists all the available commands in the terminal. You can use ‘-h’ or ‘–help’ (help has two hyphens here) option with any command to get help for that specific command. - man – Manual
man
shows the manual page for the given command. - who – Who Is logged in
who shows the list of currently logged in users.
- exit
exit ends the current terminal (bash) session.
- shutdown
shutdown shuts down your computer. You can use shutdown -r to restart your computer.
You can refer this screenshots to get best understand of above commands
$ man ls