Skip to content

Instantly share code, notes, and snippets.

@jnikolak
jnikolak / myssh
Last active February 15, 2018 10:51
#!/bin/bash
# Usage: run the script like ./myssh 3 or if you want list of options ./myssh
# Written by Jon Nikolakakis with help from Jamie Bainbridge, Version 0.1
# Change the knownUserloc entry to match your username
# Example: knownUserloc="/home/jnuser"
knownUserloc="/root"
HOSTFILE="$knownUserloc/.ssh/known_hosts"
cat /etc/wpa_supplicant/wpa_supplicant.conf
ctrl_interface=/var/run/wpa_supplicant
ctrl_interface_group=wheel
@jnikolak
jnikolak / shell.c
Created October 16, 2017 01:02
Shell Prompt
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
void prompt();
int main()
{
char hostname[1024];
@jnikolak
jnikolak / countdown.c
Last active October 17, 2017 09:33
Countdown
/* This is an example taken from a book, one day I might need to reference this so I thought I would save it,
it uses many different techniques in c such as:
- adding modules
- create global variables using constsants and local variables inside functions
- setting up prototyes for functions
- defining different types such as long int, char
- loops inside functions
- different style of comments
- break out of loop
- if statements */
@jnikolak
jnikolak / chocolate.c
Last active November 15, 2017 06:55
How much Chocolate can you eat in a day?
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
int main()
{
char selector;
float height_in_feet,inches;
int weight,age,pounds,height_in_cm,bmr;
int choc = 230;
@jnikolak
jnikolak / tax.c
Last active October 12, 2017 08:21
Calculate Australian Tax in C
#include <stdio.h>
/* Australian Tax Rates verified with https://www.ato.gov.au/Calculators-and-tools/Host/?anchor=STC&anchor=STC#STC/questions */
int myearnings(void);
int main()
{
int unsigned long earnings,tax1,tax2,tax0;
int unsigned deftax[] = {0,3572,19822};
@jnikolak
jnikolak / ringbuffer.sh
Last active October 21, 2017 12:14
ring buffer script
#!/bin/bash
declare -a arr
# List all interfaces and assign it to the Variable DEV, then get the current ring buffer settings for each interface
# Create its own seperate file, so we can manipulate the output
# assign each of the output into an array
for DEV in $(ip a l | grep mtu | awk '{print $2}' | awk -F ":" '{print $1}'| egrep -v "^lo|virbr*|bond*|*team")
do
ethtool -g $DEV 2>/dev/null > eth_$DEV
#!/bin/bash
filename=/tmp/$(hostname -f).out
rm -f $filename
journalctl --since "now" -f >> $filename&
#for ((n=0;n<5;n++))
echo "Script is running, press \"cntrl c\" to stop"
while true
Lets break the full command down
ip -o link show eth0 | awk '{ for (x=1; x<=NF;x++) if ($x=="link/ether") print $(x+1)}'
############################################################
# If we just run the ip -o link command against regular, it just adds the ip link into one line.
This is useful if you want to awk after
ip -o link show eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT qlen 1000\ link/ether 00:1a:4a:16:01:86 brd ff:ff:ff:ff:ff:ff
@jnikolak
jnikolak / gist:8f0365dcba1cd04a14804d1a53ee863b
Last active April 21, 2017 06:47
Rhel Updater Project
### First version 0.000001
#!/bin/bash
# confirm version Rhel 5, 6, 7 and switch version and commands based upon this. For test purposes this is for Rhel 6
########## RHEL 6 ###########################################
# Verify rpm
cd /var/lib/rpm
/usr/lib/rpm/rpmdb_verify Packages