Labels

Android (1) Apache (1) bash (2) boost (2) C (37) C++ (5) cheatsheet (2) CLion (6) css (3) Debian (35) DL (17) dns (1) Docker (3) Dreamweaver (2) Eclipse (3) fail2ban (5) git (6) GitHub (5) Hacking (4) html (8) http (1) iOS (1) iPad (1) IRC (1) Java (34) javascript (3) Linux (186) Mac (22) Machine Learning (1) mySQL (54) Netbeans (7) Networking (1) Nexus (1) OpenVMS (6) Oracle (5) Pandas (3) php (17) Postgresql (8) Python (9) raid (1) RedHat (15) Samba (3) Slackware (54) SQL (14) ssh (1) svn (1) tar (1) ThinkPad (1) Virtualbox (4) Visual Basic (2) Visual Studio (1) Windows (8) wire (1)

Wednesday, 23 January 2019

Normalization Normal forms

First Normal Form 1NF

No repeating columns or columns contain only a single value.


Second Normal Form 2NF

As per 1NF but each non PK value can be uniquely identified by the PK

Third Normal Form 3NF

As per 2NF but each no PK value can ONLY be identified by the PK

Comparison between SQL and Pandas

Comparison with SQL


Thursday, 10 January 2019

VirtualBox command line. Removing innaccessable VMs change machine location

To delete virtual machines from the command line, first I removed the *.vbox *.vmdk files etc (basically the folder that these files are in).

Then;
VBoxManage list vms (this lists virtual machines)
VBoxManage unregistervm ********* (where *** is the number of the VM as shown by the previous command).

To change default location of VM's
vboxmanage setproperty machinefolder /path/to/directory/
Note use path in quotation marks if folder needs a space, example;
vboxmanage setproperty machinefolder "/var/VirtualBox VMs"

Friday, 4 January 2019

Mac add Open With to Right Click menu

Add OPEN WITH to Right click menu
  1. Open Automator and select Service document type.
  2. Select Files and Folders in the top Service receives selected menu
  3. Search for and select the Open Finder Items action.
  4. Now select TextEdit in Open with:
  5. Save the service with a name you want to see in the menus
You can now find this by: 
  • Right-clicking the file > Services

Tuesday, 1 January 2019

Renaming a file to include date

To rename a file to include the date in the filename use the following:

mv myfile.txt myfile_$(date + %d-$m-%Y).txt

This can be useful when creating backup files.

A script called by cron like the below might be useful.

#!/bin/bash
rm myfile_*.tar
tar -cf myfile.tar myfile.txt && mv myfile.tar myfile_$(date + %d-$m-%Y).tar

Saturday, 29 December 2018

mySQL and phpMyAdmin

https://docs.slackware.com/howtos:databases:install_mysql_on_slackware


See here for a more up to date account of installing Apache, php, mySQL and phpMyAdmin on Debian.

Thursday, 27 December 2018

smb.conf

# This is the main Samba configuration file. You should read the
# smb.conf(5) manual page in order to understand the options listed
# here. Samba has a huge number of configurable options (perhaps too
# many!) most of which are not shown in this example
#
# For a step to step guide on installing, configuring and using samba, 
# read the Samba-HOWTO-Collection. This may be obtained from:
#  http://www.samba.org/samba/docs/Samba-HOWTO-Collection.pdf
#
# Many working examples of smb.conf files can be found in the 
# Samba-Guide which is generated daily and can be downloaded from: 
#  http://www.samba.org/samba/docs/Samba-Guide.pdf
#
# Any line which starts with a ; (semi-colon) or a # (hash) 
# is a comment and is ignored. In this example we will use a #
# for commentry and a ; for parts of the config file that you
# may wish to enable
#
# NOTE: Whenever you modify this file you should run the command "testparm"
# to check that you have not made any basic syntactic errors. 
#
#======================= Global Settings =====================================

SQL DML Data Manipulation Language


SELECT
SELECT *
FROM someTable
ORDER BY pk_id;


VARIABLES 
SELECT id, machine, user
FROM db.tableA varA
JOIN db.tableB varB ON (varA.user = varB.user)
WHERE id=500
ORDER BY id
LIMIT 10;

/*! so db.tableA can be referenced by varA and db.tableB by varB */ 

INSERT INTO
INSERT INTO 〈table name〉( 〈column 1〉, 〈column 2〉,... 〈column n〉 )
VALUES ( 〈value 〉, 〈value 2〉, ..., 〈value n〉);
Note column names do not require quotation marks, however values do.

INSERT INTO 〈table name〉
VALUES
      ( 〈value 〉, 〈value 2〉, ..., 〈value n〉)
      ( 〈value 〉, 〈value 2〉, ..., 〈value n〉)
      ( 〈value 〉, 〈value 2〉, ..., 〈value n〉); 
Note: We can omit the column names so long as the list of values match the number of columns AND are in the correct order.

UPDATE WHERE
UPDATE 〈table_name〉
SET column1 = value1, column2 = value2, ...
WHERE 〈condition〉;

DELETE FROM
DELETE FROM 〈table_name〉 WHERE 〈condition〉;
DELETE FROM table_name
Note: the latter command removes ALL data from the table. 

If we wish to list all different values in a column and count the number of instances of that value.
SELECT "names", COUNT("names") AS numberOfTimes
FROM mydf
GROUP BY "names"
ORDER BY
numberOfTimes;

   

SQL DDL Data Definition Language


SQL in Jupyter Notebooks specifically PostgreSQL