Skip to content

Instantly share code, notes, and snippets.

@ghostyone
ghostyone / Blocking YouTube ads.txt
Created February 7, 2023 17:50
Blocking YouTube ads by modifying your computer's hosts file
Blocking YouTube ads by modifying your computer's hosts file involves redirecting requests to YouTube's ad servers to a non-existent domain. This method can be used to block advertisements on YouTube, but it requires some technical knowledge and is not recommended for inexperienced users.
Here's how you can modify your hosts file to block YouTube ads:
Locate your hosts file: The location of the hosts file varies depending on your operating system. On Windows, it is located at C:\Windows\System32\drivers\etc\hosts. On Mac, it is located at /private/etc/hosts. On Linux, it is located at /etc/hosts.
Open the hosts file: You will need administrator privileges to edit the hosts file. On Windows, you can open the hosts file using a text editor, such as Notepad, as an administrator. On Mac and Linux, you can open the hosts file using the terminal and a text editor, such as nano.
Add the following lines to the end of the file:
@ghostyone
ghostyone / kissing_number.py
Created February 7, 2023 17:26
Python script that implements a check for the maximum number of non-intersecting unit spheres in 2 dimensions. The Kissing Number Problem asks for the maximum number of non-intersecting unit spheres that can touch a single unit sphere in a given number of dimensions
def kissing_number(d):
if d == 2:
return 6
else:
return None
d = int(input("Enter the number of dimensions: "))
if d > 1:
k = kissing_number(d)
if k:
@ghostyone
ghostyone / riemann_hypothesis.py
Created February 7, 2023 17:21
Python script that implements a check for Riemann-hypothesis-violating numbers, which are also known as counterexamples:
def riemann_hypothesis(n):
from math import log
for i in range(2, n):
if i ** (i - 1) > 2 * log(i):
return i
return None
n = int(input("Enter a positive integer: "))
if n > 2:
counterexample = riemann_hypothesis(n)
@ghostyone
ghostyone / collatz.py
Created February 7, 2023 17:13
Python script that implements the Collatz Conjecture
def collatz(n):
print(n)
while n != 1:
if n % 2 == 0:
n = n // 2
else:
n = 3 * n + 1
print(n)
n = int(input("Enter a positive integer: "))
@ghostyone
ghostyone / harden_windows_server.ps1
Last active February 7, 2023 16:49
PowerShell script to harden windows Server. This script assumes that the Active Directory Domain Services role is already installed on the Windows server. You may need to modify the script based on your specific security requirements and network configuration
# Disable unnecessary services
Get-Service | Where-Object {$_.DisplayName -notmatch "Windows Defender.*|Windows Update.*"} | Stop-Service -PassThru | Disable-Service
# Enable firewall
New-NetFirewallRule -DisplayName "Block all incoming traffic" -Direction Inbound -Action Block
# Set strong passwords
$PasswordPolicy = New-Object -TypeName System.DirectoryServices.AccountManagement.PasswordPolicy
$PasswordPolicy.Length = 14
$PasswordPolicy.UppercaseCount = 3
@ghostyone
ghostyone / harden_script.sh
Created February 7, 2023 16:32
Bash script to harden linux servers
#!/bin/bash
# 1. Update system packages
sudo apt-get update
sudo apt-get upgrade -y
# 2. Create a new non-root user
sudo adduser <new_user>
sudo usermod -aG sudo <new_user>