Skip to content

Instantly share code, notes, and snippets.

@avoidedlife
avoidedlife / MacLookup.sh
Created June 5, 2013 22:03
Parses data out of everymac lookup
#!/bin/bash
# Asking for serial number
echo -e "Enter serial number:"
read SerialNumber
SerialNumberCount=${#SerialNumber}
if [[ ${SerialNumberCount} > "11" ]]; then
# If Serial is 12 or more characters, set the ModelSerial to four digits
ModelSerial=$(echo $SerialNumber|awk '{ print substr( $0, length($0) - 3, length($0) ) }')
else
@avoidedlife
avoidedlife / gist:5608106
Created May 19, 2013 16:08
bash_inputrc
set bell-style none
set completion-ignore-case On
set echo-control-characters Off
set enable-keypad On
set mark-symlinked-directories On
set show-all-if-ambiguous On
set show-all-if-unmodified On
set skip-completed-text On
set visible-stats On
#include <stdio.h>
#include <strings.h>
#include <math.h>
#define SIZE 255
int main(void)
{
char
@avoidedlife
avoidedlife / string_joiner.c
Last active December 13, 2015 19:38 — forked from sirovenmitts/string_joiner.c
Here is my take on it after you re-wrote it. Obviously followed your example on 45-47. I also enjoyed (cosmetically ) the way that you were declaring data types... implemented function for capturing strings so I can write a panic(); function later for erroneous input.
// ask for two strings and join the first half of the first string
// with the second half of the second string.
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define SIZE 255
// Getting string input //
// ask for two strings and join the first half of the first string
// with the second half of the second string.
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#define SIZE 255
// ask for two strings and join the first half of the first string
// with the second half of the second string.
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#define SIZE 255
@avoidedlife
avoidedlife / fortune_minecraft.sh
Created November 3, 2012 08:31
Bash Script to pipe the output of fortune(6) to a minecraft server running in a screen session
#!/bin/bash
IFS=$'\r'
fortune_lines=($(fortune | sed -e 's/^/say /' | fold -w 90 ))
Screen_Session=`screen -ls|grep "\."|grep "("|awk '{print $1}'`
Screen_OneLiner=$(screen -p 0 -S ${Screen_Session} -X stuff "`printf "${fortune_lines[@]}\r"`")
for var in "${Screen_OneLiner[@]}"
do
echo "${var}"
done
@avoidedlife
avoidedlife / TwitGet.sh
Created September 1, 2012 00:20
Bash script using xmlstarlet to return latest twitter status to minecraft server chat via screen
#!/bin/bash
# minecraft screen session
SCREEN_SESSION=minecraft
# using xmlstarlet http://xmlstar.sourceforge.net to parse xml/rss and return latest twitter status
function TwitGet () {
RSS_URL=api.twitter.com/1/statuses/user_timeline/$1.rss
rssversion=$(wget ${RSS_URL} -O - 2>/dev/null |
xmlstarlet sel -T -t -v '/rss/channel/item[1]/title')