Install Tor with torsocks and proxychains on Ubuntu 18.04

sudo apt install tor torsocks proxychains
tor --hash-password "passwordhere"

CookieAuthentication OR HashedControlPassword (if you choose to uncomment HashedControlPassword, copy the hashed password you got in the previous step and paste it next to HashedControlPassword in the torrc file)

nano /etc/tor/torrc
# This provides a port for our script to talk with. If you set this then be
# sure to also set either CookieAuthentication *or* HashedControlPassword!
# You could also use ControlSocket instead of ControlPort, which provides a
# file based socket. You don't need to have authentication if you use
# ControlSocket. For this example however we'll use a port.

ControlPort 9051 # <--- uncomment this ControlPort line

# Setting this will make Tor write an authentication cookie. Anything with
# permission to read this file can connect to Tor. If you're going to run
# your script with the same user or permission group as Tor then this is the
# easiest method of authentication to use.

CookieAuthentication 1 #either uncomment this or below HashedControlPassword line

# Alternatively we can authenticate with a password. To set a password first
# get its hash...
# % tor --hash-password "my_password"
# 16:E600ADC1B52C80BB6022A0E999A7734571A451EB6AE50FED489B72E3DF
# ... and use that for the HashedControlPassword in your torrc.

HashedControlPassword 16:E600ADC1B52C80BB6022A0E999A7734571A451EB6AE50FED489B72E3DF #if you choose to uncomment this line, paste your hashed password here
sudo /etc/init.d/tor restart


curl ''
torsocks curl ''
proxychains curl ''


Install VirtualBox on KDE Neon Ubuntu 18.04

sudo apt install build-essential dkms linux-headers-$(uname -r)
wget -q -O- | sudo apt-key add -
wget -q -O- | sudo apt-key add -
sudo add-apt-repository "deb bionic contrib"
sudo apt install virtualbox-6.0

Download VirtualBox Extension Pack

sudo VBoxManage extpack install --replace Oracle_VM_VirtualBox_Extension_Pack-${LatestVirtualBoxVersion}.vbox-extpack



Convert Joda-Time `DateTime` with timezone

DateTime dateTimePlus2 = DateTime.parse("2015-07-09T05:10:00+02:00");

DateTime dateTimeUTC = dateTimePlus2.withZone(DateTimeZone.UTC);

LocalDateTime localDateTimeUTC = dateTimeUTC.toLocalDateTime();


Returning Image/Media Data with Spring

@RequestMapping(value = "/image-manual-response", method = RequestMethod.GET)
public void getImageAsByteArray(HttpServletResponse response) throws IOException {
    InputStream in = servletContext.getResourceAsStream("/WEB-INF/images/image-example.jpg");
    IOUtils.copy(in, response.getOutputStream());


  value = "/get-image-with-media-type",
  produces = MediaType.IMAGE_JPEG_VALUE
public @ResponseBody byte[] getImageWithMediaType() throws IOException {
    InputStream in = getClass()
    return IOUtils.toByteArray(in);


Make iptables rules persistent after reboot on Ubuntu 18.04

sudo apt install iptables-persistent netfilter-persistent
systemctl enable netfilter-persistent
netfilter-persistent save
netfilter-persistent start

iptables-save  > /etc/iptables/rules.v4
ip6tables-save > /etc/iptables/rules.v6

iptables-restore  < /etc/iptables/rules.v4
ip6tables-restore < /etc/iptables/rules.v6

systemctl stop    netfilter-persistent
systemctl start   netfilter-persistent
systemctl restart netfilter-persistent

Remove persistent iptables rules

To remove persistent iptables rules simply open a relevant /etc/iptables/rules.v* file and delete lines containing all unwanted rules.