C: Power of (^) & hex to dec converter

I have spent almost 2 evenings trying to create a C program to convert Hex (0x) into a decimal number. After re-writing it 3 times, I had figured out the logical structure.

A previous little program I wrote returned the total decimal value of a provided number of bits. For that program, I was able to use:

1 << i;

to provide me with “1 to the power of i”. I couldn’t figure out why this formula didn’t work at all with ^16;  1^16  kept returning a value of  32. I finally gave up and found a different route.

<math.h> gave me a function that returns the value of a powerof equation.

double pow(double x, double y);

You must also include  -lm  flag whilst compiling. After implementing the function, the whole program started returning correct results. Job done. Here’s the code ( if your interested ) Continue reading “C: Power of (^) & hex to dec converter”

CS50: Extra-curricula

During my time studying for the CS50 computer science course through edx.org, I have encountered a few problems of my own.

I find that using some online tool to either jog my memory or help me find the answer to a question is a bit lazy. So I’ve opted to building my own tools. They are pretty simple to use but sometimes challenging to code.

For example, I have built a tool that returns the ascii number of a character. Another example I am working on is a program to tell me the decimal value of a hexadecimal number up to 64bits.

I suppose I could save some time and use something that is already available but where’s the fun in that?

f2b-nuke | a fail2ban shell script

You will find the project on GitHub: f2b-nuke – GitHub

f2b-nuke is a gnu/linux shell script designed to easily and efficiently manipulate any given fail2ban jail, en masse. It is a fully interactive, CLI tool built to fulfill 2 tasks:

  • unbanning the contents of an entire jail whilst creating a backup list of all items
  • New: banning (or re-banning) an entire list of IPs to the specified jail.

As the use of fail2ban slowly diminishes, this script can be viewed as complete. I will continue to maintain the project through Github.

Uses:

  • Misconfiguration/testing
  • Configuration/testing
  • Persistent bans might cause long shutdown/reboot times on limited resourced systems
  • As part of a maintenance routine