Format disk with diskpart

Below is a quick guide to illustrate how we can format a disk using diskpart.

First open the command prompt (if booting from Windows install media you may be able to open the command prompt by pressing F8 or Shift+F10).

In your command prompt, type diskpart to enter the diskpart utility. Your input cursor should now look like DISKPART> and you are ready to run the commands below:

list all disks connected to your computer

list disk 


select the disk you wish to format. Replace X below with the number you see from list disk

select disk X 

marks everything on the disk to be deleted – you could also use “clean all” to actually delete it, but this will take a while

clean 



convert disk to MBR – you could also change mbr with gpt

convert mbr 



create a new primary partition

create partition primary 


select the newly created partition

select part 1 



make it active if this is the boot partition

active 



format it to NTFS fileystem and set label to whatever you wish

format fs=ntfs label=X quick 



assign a letter to the partition, typically C for the Windows drive

assign letter C 



list volumes to verify the results

list vol

For more information about Diskpart, see:
https://technet.microsoft.com/en-us/library/cc766465(v=ws.10).aspx

Make an app with Atom Electron

1: Install Node.js (also includes npm)

2: Create your app (requires index.html, main.js, package.json) [1]

3: Optionally mask your source files to an .asar file. [2]

3: Run npm install electron-packager -g to install the electron-packager [3]

4: Run electron-packager <sourcedir> <appname> --platform=<platform> --arch=<arch> [optional flags...]

Examples:

electron-packager . --platform=win32 --arch=x64 --version="0.35.0" --out="App" asar="true"

electron-packager . --platform=win32 --arch=x64 --version="0.37.6" --out="App" 5.1.8

electron-packager . --platform=win32 --arch=x64 --appname="BinHexDec" --icon="monitoricon.ico" --version="0.37.6" --out="App" --version-string.FileDescription="Binary Hex Decimal Converter" --app-copyright="Teknix" --version-string.OriginalFilename="BinHexDec.exe" --version-string.CompanyName="Teknix" --version-string.ProductName="BinHexDec" --build-version="1.0.0" --app-version="1.0.0" BinHexDec-1.0.2

Sources:

[1] http://electron.atom.io/docs/latest/tutorial/quick-start/
[2] https://github.com/electron/asar
[3] https://www.npmjs.com/package/electron-packager

Add remote access to MySQL server

Follow the commands below to setup a new user and open up for remote access to a specific database on your MySQL server.

$ mysql -u root -p
Enter your MySQL root password.
mysql> CREATE USER 'itdb_admin';
mysql> CREATE DATABASE itdb_db;
mysql> GRANT ALL PRIVILEGES ON itdb_db.* to 'itdb_admin'@'%' IDENTIFIED BY 'my-password' WITH GRANT OPTION;
mysql> FLUSH PRIVILEGES;
mysql> EXIT;
$ sudo nano /etc/mysql/my.cnf
Comment the following line by setting a # in front (to disable it):
bind-address = 127.0.0.1
$ sudo service mysql restart

Quick summary:

1) Open the MySQL CLI
2) Create a new database
3) Create a new user
4) Give the user full access to the database. Notice the '%' which means we’re talking about remote access. The same user can have different access levels based on the connection (whether it’s remote or local)
5) Flush/refresh the privileges so they become active
6) Disable bind-address so the MySQL server will listen on any source address
7) Restart the MySQL service to reload the config file

A man of few words

Scenario: I’m remote controlling a colleague’s computer to assist with some software issues. After fixing one of them the computer needed a restart, but the other issue required some more troubleshooting so I disconnected from his computer and proceeded to excersise some Google Fu.

Fast forward a few minutes.
I see he still hasn’t rebooted his computer like he said he would, so I ask him:

Me: I found a solution, would you like me to remote in to your PC now or are you going to restart first?
Luser: OK
Me (thinking): Well, wtf do I do now

Setup reverse SSH tunnel

Here’s a quick example for setting up reverse SSH tunnels on clients which can be controlled via the server from anywhere. This example presumes all the client computers has some sort of unique ID/hostname, like 9001, 9002, 9003, 9004 etc. Let’s say we have 10 clients stuck behind a firewall we’d like to access.

Start the SSH server on all clients like this:

ssh -R 1xxxx:localhost:22 user@server.com // replace xxxx with this client's unique id

Now we have all our clients setup with a reversed ssh tunnel.
If we’d like to ssh into id 9003 we run the following command from the server:

ssh user@localhost -p 19003

Lets ssh into 9005 instead:

ssh user@localhost -p 19005

Replace user with a local user on the client machine.

Example

I want to ssh into my Raspberry Pi. Local username is pi.

  • Step 1 – setup reverse ssh tunnel on the raspberry:
    ssh -R 19999:localhost:22 kek@it-db.com
  • Step 2 – from my “it-db.com” server I run the following command:
    ssh pi@localhost -p 19999

Combining with sshpass and autossh

sshpass -p "mypassword" autossh -R 19999:localhost:22 user@server.com