Skip to content

Instantly share code, notes, and snippets.

View ldante86's full-sized avatar

Luciano Dante Cecere ldante86

View GitHub Profile
@ldante86
ldante86 / pegsol.sh
Created November 7, 2016 04:30
An old solitaire game. This version was modelled after the one found in emacs
#!/bin/bash -
########################## DEFINE GLOBALS ##############################
PROGRAM="${0##*/}" # Program name
HOLE="." # Hole for peg
PEG="o" # Peg token
MOVE=0 # Move counter
BO=$(tput smso) # Bold on
LD=$(tput rmso) # Bold off
@ldante86
ldante86 / sinfo.sh
Created November 7, 2016 19:45
Get running length of media files
#!/bin/bash -
which mediainfo >/dev/null || {
echo mediainfo is not installed
exit 1
}
[ $# -eq 0 ] && set -- *
for i
@ldante86
ldante86 / ram.sh
Created November 7, 2016 20:08
Get ram information from /proc/meminfo
#!/bin/bash -
ram_info=/proc/meminfo
total_ram=$(bc <<< "scale=2; $(cat $ram_info | grep MemTotal | tr -d a-zA-Z:)/1024/1024")
free_ram=$(bc <<< "scale=2; $(cat $ram_info | grep MemFree | tr -d a-zA-Z:)/1024/1024")
used_ram=$(bc <<< "$total_ram-$free_ram")
echo "Total Ram: $total_ram G"
echo "Free Ram: $free_ram G"
@ldante86
ldante86 / up.sh
Created November 7, 2016 20:45
Get uptime and second conversion
#!/bin/bash -
PROGRAM="${0##*/}"
IFS="."
for i in $(cat /proc/uptime)
do
UPTIME=$i
break
done
@ldante86
ldante86 / trig.bc
Created November 7, 2016 20:49
trig functions for bc
#!/usr/bin/bc -q
#
# PURPOSE: This script calculates sine, cosine and tangent using
# the Taylor series.
scale=6
pi = 3.14159265358979323844
define factorial(a) {
@ldante86
ldante86 / locale.sh
Created November 7, 2016 20:53
locale ideas for lcal
#!/bin/bash -
short_weekdays=$(locale -c LC_TIME | sed -n '2p')
long_weekdays=$(locale -c LC_TIME | sed -n '3p')
short_months=$(locale -c LC_TIME | sed -n '4p')
long_months=$(locale -c LC_TIME | sed -n '5p')
unset gweek_header
unset jweek_header
@ldante86
ldante86 / loopback.sh
Created November 7, 2016 21:05
notes on loopback filesystem
### make loopback filesystem
exit
# must be superuser
sudo su
# write file.img - 10M
dd if=/dev/zero of=file.img bs=10M count=1
# make ext4 filesystem with file.img
@ldante86
ldante86 / fl.sh
Created November 8, 2016 22:54
generate bash function index.
#!/bin/bash -
#
# PROGRAM: fl
# AUTHOR: Luciano D. Cecere
#
# This program is a wrapper for egrep to find BASH
# functions in files.
#
# This program searchs only functions in the style of:
# myfunc()
@ldante86
ldante86 / btags.sh
Last active November 9, 2016 01:03
Generate ctag list of bash functions in files
#!/bin/bash -
PROGRAM="${0##*/}"
if [ $# -eq 0 ]; then
echo "Usage: $PROGRAM file1.sh file2.sh ..."
exit 1
fi
while [ $# -gt 0 ]
@ldante86
ldante86 / lcal-index.txt
Created November 9, 2016 01:09
btags output for lcal
{_main} {lcal} {104}
{_is_year_valid} {lcal} {417}
{_is_month_valid} {lcal} {433}
{_is_day_valid} {lcal} {444}
{_is_date_valid} {lcal} {459}
{_parse_month} {lcal} {526}
{_month_len} {lcal} {549}
{_is_leap} {lcal} {572}
{_day_of_week} {lcal} {585}
{_gregorian_array} {lcal} {603}