Skip to content

Instantly share code, notes, and snippets.

View n0toose's full-sized avatar

Panagiotis "Ivory" Vasilopoulos n0toose

View GitHub Profile

hi

@n0toose
n0toose / find_prime_pair.m
Created November 21, 2021 16:52
Find n-th pair of prime numbers with a difference of two in MATLAB
n = 90;
disp(primePair(n))
function p = primePair(n)
% Incredibly inefficient, use the primes vector instead.
% I just came up with this during an exam and didn't want
% to think about going over the vector correctly too much.
a = [ -2 0 ];
counter = 0;
while counter ~= n
@n0toose
n0toose / count_equal_to_6.m
Created November 21, 2021 15:28
Find the sum of digits in MATLAB (Example: Numbers with a sum of digits equals to 6)
count_equal_to_6 = 0;
for times = 1:1000
if sumOfDigits(times) == 6
display(times)
count_equal_to_6 = 1 + count_equal_to_6;
end
end
fprintf('Total: %d\n', count_equal_to_6)
@n0toose
n0toose / kill_libvirtd.sh
Created October 30, 2021 15:40
Remove libvirtd and all of its sockets out of existence
# I know this is dirty, but come on, starting my Windows virtual machine
# just freezes everything and the whole thing won't even respond to `systemctl`.
#
# Use with root privileges, not my responsibility if you mess things up.
pkill -9 libvirt
rm -rf /run/libvirtd.pid
rm -rf /run/libvirt/interface/driver.pid
rm -rf /run/libvirt/secrets/driver.pid
rm -rf /run/libvirt/nodedev/driver.pid
@n0toose
n0toose / gist:fa8a5cfd008dd1e8f18362fba2efe460
Created May 4, 2021 21:18
Convert PNG to favicon.ico with multiple different dimensions
optipng image.png
convert image.png -define icon:auto-resize=16,32,48,57,64,96,128,144,192,196,256 favicon.ico
@n0toose
n0toose / README.md
Last active March 12, 2021 15:21
Expose a SOCKS proxy in a virtual machine that routes traffic through another VPN connection

Instructions

  • Install Debian (or your distro of choice) in a virtual machine.
  • Configure OpenVPN/Wireguard.
  • Install dante-server and paste the contents of danted.conf in /etc/danted.conf.
  • Make the appropriate changes to the aforementioned configuration file.
  • Run ip a and take note of the IP address of the virtual machine.
  • Run sudo systemctl enable --now danted.
  • Ensure that the proxy is functioning properly with sudo systemctl status danted.
  • If all went well, you should now be able to connect to your SOCKS5 proxy!
@n0toose
n0toose / leap.py
Created November 1, 2020 07:17
Leap seconds in Python
# source: https://stackoverflow.com/questions/39686553/what-does-python-return-on-the-leap-second
import time
import datetime as dt
time.mktime(time.strptime('2016-06-30T23:59:59', "%Y-%m-%dT%H:%M:%S"))
time.mktime(time.strptime('2016-06-30T23:59:60', "%Y-%m-%dT%H:%M:%S"))
# datetime will fail
dt.datetime.strptime('2016-06-30T23:59:60', "%Y-%m-%dT%H:%M:%S")
@n0toose
n0toose / acme_dn42.sh
Created October 11, 2020 06:42
Small script for installing the acme.dn42 certificate
wget http://acme.dn42/dn42acme.pem
sudo cp dn42acme.pem /etc/ssl/certs
sudo openssl x509 -noout -hash -in dn42acme.pem
@n0toose
n0toose / public_ipv6.sh
Created September 20, 2020 07:34
Show public IPv6 address
ip addr show dev eth0 | sed -e's/^.*inet6 \([^ ]*\)\/.*$/\1/;t;d' | grep -v "fe80"
@n0toose
n0toose / blink-all.sh
Created August 28, 2020 00:27
Blink all of the LED lights in your Linux workstation randomly.