Showing posts with label scripts. Show all posts
Showing posts with label scripts. Show all posts

Tuesday, 18 August 2015

Tree keeping made easy

If you want snazzy tree views for your project of your local drive files and the remote master repository that you can traverse with a browser, just modify this script and set up a cronjob to keep your trees updated.

How does it look?

Download the file itself, load it into your browser and have fun traversing the tree of the Corinthia GitHub repository. (blogger.com and google.drive won't let me paste the file without crippling the links, fair enough, it's 168 directories (and thus links) and usually people who do this kind of thing would probably be up to no good[1]).  If you just want to see it without working links, it's here.




I think it's nice to have a tree overview --- a picture is worth a 1000 words (as they say).

[1] sadly, saving the document also ninja-edits the original.  So, don't waste your time with pasting lots of links into Google Docs :(

Wednesday, 13 August 2014

Sometimes, to fake is better than to make

#! /bin/bash                                                         
# Compile a test file without those noisy -Wunused* flags, but       
# everything else that may be useful.                                
# 
# Usage: compileCTest <name of your file  without the '.c'>  
       
# give the executable an easy to spot and mass-delete friendly name
executable="$1-exe"

# remove the old executable if it exists                             
if [ -e $executable ]
then                                                                 
    rm $executable;                                                  
fi                                                                                                            
echo ""
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
echo ""

# all flags from -Wall and -Wextra minus the -Wunused flags
runGCC='gcc -g -std=c99 -Waddress -Warray-bounds -Wchar-subscripts -Wenum-compare -Wimplicit-int -Wimplicit-function-declaration -Wformat -Wmain -Wmaybe-uninitialized -Wmissing-braces -Wnonnull -Wparentheses -Wpointer-sign -Wreturn-type -Wsequence-point -Wsign-compare -Wstrict-aliasing -Wstrict-overflow=1 -Wswitch -Wtrigraphs -Wuninitialized -Wunknown-pragmas -Wvolatile-register-var -Wclobbered -Wempty-body -Wignored-qualifiers -Wmissing-field-initializers -Wmissing-parameter-type -Wold-style-declaration -Woverride-init -Wsign-compare -Wtype-limits -Wuninitialized $1.c -o $1-exe -lm -lgmp'

eval $runGCC                                                         

# check that compile resulted in executable and if so, run it  
if [ -e $executable ]                 
then                                                                 
# add a couple of dividing lines to make this easier to read 
echo "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=";
./$executable;
echo "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=";
fi         

Thursday, 29 May 2014

A script for Exaile: bedtime-story.sh

As much as I like Exaile, it sadly lacks the option of turning a recording off after n minutes.

But, who needs a feature for the Exaile GUI when a script will suffice?

So, set your story up to play in the GUI, then use this:

bedtime-story.sh:

# turn the screen off
xset dpms force off

sleep $@ > /dev/null 2>&1

if [ $? = 1 ]
then
    # turn the screen on
    xset dpms force on
    echo "Fade out Exaile playback after a defined time, using the computer's volume control."
    echo ""
    echo "Usage: bedtime-story NUMBER[smh]..."
    echo ""
    echo "Each argument is a number followed by a unit."
    echo "The units are: s (seconds), m (minutes), h (hours)"
    echo "Example: bedtime-story 20m 10s"
    echo "The screen will be turned off, move the mouse or press a key to turn it back on."
fi

# grab current spot and volume, then gently fade and pause
c=$(exaile --current-position)
v=$(pactl list | grep Volume | cut -d ":" -f 3 | cut -d "%" -f 1 |\
 sed -n '1p' | sed -e 's/^[ \t]*//' -e 's/[ \t]*$//')
for((i=$v;i>=0;i--)) do
    sleep 1s
    pactl set-sink-volume 0 ${i}%
done
exaile --play-pause

# return volume to former setting
pactl set-sink-volume 0 ${v}%
echo "The current track was faded out beginning at $c."

Now I can go to sleep in style, whilst listening to the Internet's longest history podcasts. (in parts).