Skip to content

Instantly share code, notes, and snippets.

View ldante86's full-sized avatar

Luciano Dante Cecere ldante86

View GitHub Profile
@ldante86
ldante86 / temp.sh
Last active November 9, 2016 04:28
get temperature by metar station name
#!/bin/bash
if [ "$1" ]; then
declare -u metar="$1"
curl -s http://tgftp.nws.noaa.gov/weather/current/${metar}.html | \
grep -A 5 Temperature | grep "F ([0-9]" | awk -F ">" '{print $3}' | sed 's/(.*//' | sed 's/^ *//'
fi
@ldante86
ldante86 / lcal.css
Created November 9, 2016 02:34
minified css for lcal
body{background:gray}
table{background:#000;border:2px solid #000}
table.center{margin-left:auto;margin-right:auto}
.month{font-size:50px;word-spacing:.5em;color:#FFF;font-weight:700}
td{font-family:Arial;text-align:center;font-size:25px;width:82px;height:82px;padding:0;font-weight:700}
.weekbar{height:10px;background:#232323;color:#FFF}
.sunday{background-color:#606060;color:#FFF;font-style:italic}
.weekday{background-color:silver}
.today{background-color:red;font-size:35px;color:#FFF}
.today:hover{background-color:#000;color:red}
@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}
@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 / 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 / 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 / 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 / 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 / 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 / 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"