Skip to main content

Posts

Python = Code for functional Firewal

  import os import subprocess import socket import requests blocked_ips = {} blocked_websites = {} blocked_applications = {} def add_ip_to_block ( ip , port ): if ( ip , port ) in blocked_ips : print ( f "IP { ip } with port { port } is already blocked" ) return if is_ip_port_in_hosts ( ip , port ): print ( f "IP { ip } with port { port } is already in block list." ) return blocked_ips [( ip , port )] = True print ( f "Added { ip } with port { port } to blocked IPs" ) def remove_ip_from_block ( ip , port ): if ( ip , port ) in blocked_ips : del blocked_ips [( ip , port )] print ( f "Unblocked { ip } with port { port } " ) else : print ( f "IP { ip } with port { port } is not blocked" ) def add_website_to_block ( website ): if website in blocked_websites : print ( f " { website } is already blocked...
Recent posts

C++ = Code for Binary Search

Who does Binary Search Work? When describing an algorithm to a fellow human being, an incomplete description is often good enough. Some details may be left out of a recipe for a cake; the recipe assumes that you know how to open the refrigerator to get the eggs out and that you know how to crack the eggs. People might intuitively know how to fill in the missing details, but computer programs do not. That's why we need to describe computer algorithms completely. In order to implement an algorithm in a programming language, you will need to understand an algorithm down to the details. What are the inputs to the problem? The outputs? What variables should be created, and what initial values should they have? What intermediate steps should be taken to compute other values and to ultimately compute the output? Do these steps repeat instructions that can be written in simplified form using a loop? Let's look at how to describe binary search carefully. The main idea of binary search ...