Scratch pad

Saturday 19th of March 2016 10:16:16 AM

  Toggle Advanced Options

Different SQL JOINs

  • JOIN: return rows when there is at least one match in both tables (i.e., INNER JOIN)
  • LEFT JOIN: return all rows from the left table, even if there are no matches in the right table
  • RIGHT JOIN: return all rows from the right table, even if there are no matches in the left table
  • FULL JOIN: return rows when there is a match in one of the tables

MySQL schema backup and restore

  • Backup: # mysqldump -u root -p[root_password] [database_name] > dumpfilename.sql
  • Restore: # mysql -u root -p[root_password] [database_name] < dumpfilename.sql

PostgreSQL schema backup and restore

  • Backup: # pg_dump --username=postgres database > database.sql
  • Restore #1: # psql database < database.sql
  • Restore #2: # cat database.sql | psql --user postgres database

PostgreSQL active connections

  • select count(*) from pg_stat_activity where datname = 'databasename'
  • select * from pg_stat_activity where datname = 'databasename'

Spring Security Core plugin (Grails)

  • # grails install-plugin spring-security-core
  • # grails s2-quickstart com.testapp User Role

Install Linux kernel headers

sudo apt-get install build-essential linux-headers-$(uname -r)

Remove the last commit from the current branch (Git)

# git reset HEAD~1

iOS limitations

The limitations of iOS’ document-silo model, multitasking, and inter-app communication.

Update topic identifiers in PerfectLearn topics map engine

UPDATE topic SET identifier = replace(identifier, ${from}, ${to})
UPDATE metadatum SET parent_identifier_fk = replace(parent_identifier_fk, ${from}, ${to})
UPDATE occurrence SET topic_identifier_fk = replace(topic_identifier_fk, ${from}, ${to})
UPDATE topicref SET topic_ref = replace(topic_ref, ${from}, ${to})
UPDATE basename SET topic_identifier_fk = replace(topic_identifier_fk, ${from}, ${to})

Install (third-party) JARs in local Maven repository

Create hybrid ISO image (bootable USB stick)

sudo dd if=~/Desktop/linuxmint.iso of=/dev/sdx oflag=direct bs=1048576

Create Java project with Maven

mvn archetype:generate 

Linux list open ports

sudo lsof -i
sudo netstat -lptu
sudo netstat -tulpn

HSV (Hue, Saturation, Value)

Hue selects the color. Saturation selects how much color is mixed with white. Value selects how dark or light it is.

Copy PostgreSQL databases

pg_dump --username=postgres -h localhost source_database | psql --username=postgres -h localhost destination_database