commit
0d179a9631
16 changed files with 424 additions and 60 deletions
@ -0,0 +1,27 @@ |
||||
#!/usr/bin/env bash |
||||
# Purpose: batch image resizer |
||||
|
||||
# absolute path to image folder |
||||
FOLDER="$PWD" |
||||
|
||||
# max height |
||||
WIDTH=${1:-"999999"} |
||||
|
||||
# max width |
||||
HEIGHT=${2:-"999999"} |
||||
|
||||
echo "Width: $WIDTH"; |
||||
echo "Height: $HEIGHT"; |
||||
|
||||
#resize png or jpg to either height or width, keeps proportions using imagemagick |
||||
#find ${PWD} -iname '*.jpg' -o -iname '*.png' -exec echo convert \{} -verbose -resize $WIDTHx$HEIGHT\> \{}.new.jpg \; |
||||
find ${PWD} \( -iname "*.jpg" -o -iname "*.png" \) -exec convert {} -verbose -resize "$WIDTH"x"$HEIGHT" \{}.new \; |
||||
|
||||
#resize png to either height or width, keeps proportions using imagemagick |
||||
#find ${FOLDER} -iname '*.png' -exec convert \{} -verbose -resize $WIDTHx$HEIGHT\> \{} \; |
||||
|
||||
#resize jpg only to either height or width, keeps proportions using imagemagick |
||||
#find ${FOLDER} -iname '*.jpg' -exec convert \{} -verbose -resize $WIDTHx$HEIGHT\> \{} \; |
||||
|
||||
# alternative |
||||
#mogrify -path ${FOLDER} -resize ${WIDTH}x${HEIGHT}% *.png -verbose |
@ -0,0 +1,22 @@ |
||||
#!/usr/bin/env bash |
||||
|
||||
mkdir "portraits" |
||||
mkdir "landscapes" |
||||
for f in ./*.jpg; do |
||||
WIDTH=$(identify -format "%w" "$f")> /dev/null |
||||
HEIGHT=$(identify -format "%h" "$f")> /dev/null |
||||
echo "Width: $WIDTH" |
||||
echo "Height: $HEIGHT" |
||||
echo "" |
||||
if [[ "$HEIGHT" > "$WIDTH" ]]; then |
||||
mv "$f" portraits/ |
||||
else |
||||
mv "$f" landscapes/ |
||||
fi |
||||
#if file "$f" 2>&1 | awk '/w =/{w=$5+0; h=$7+0; if (h>w) exit; else exit 1}' |
||||
#then |
||||
# mv "$f" portraits/ |
||||
#else |
||||
# mv "$f" landscapes/ |
||||
#fi |
||||
done |
@ -0,0 +1,23 @@ |
||||
((() => { |
||||
const domLoaded = function domLoaded(){ |
||||
document.removeEventListener("readystatechange",domLoaded); |
||||
document.querySelectorAll("li").forEach(li => { |
||||
console.log(li); |
||||
if( li.innerHTML.indexOf( '[' ) !== -1 ){ |
||||
li.innerHTML = li.innerHTML.replace(/\[ \]/g, '☐'); |
||||
li.innerHTML = li.innerHTML.replace(/\[x\]/g, '☒'); |
||||
} |
||||
} ); |
||||
} |
||||
|
||||
console.log("I get here"); |
||||
if(document.readyState == "loading"){ |
||||
|
||||
//If the dom hasn't loaded, wait until it is
|
||||
document.addEventListener("readystatechange",domLoaded); |
||||
return; |
||||
} else { |
||||
//If it has, run the domLoaded function
|
||||
domLoaded(); |
||||
} |
||||
}))(); |
@ -0,0 +1,107 @@ |
||||
#!/bin/bash |
||||
# Copyright (C) 2012 Stefan Breunig <stefan+measure-net-speed@mathphys.fsk.uni-heidelberg.de> |
||||
# Copyright (C) 2014 kaueraal |
||||
# Copyright (C) 2015 Thiago Perrotta <perrotta dot thiago at poli dot ufrj dot br> |
||||
|
||||
# This program is free software: you can redistribute it and/or modify |
||||
# it under the terms of the GNU General Public License as published by |
||||
# the Free Software Foundation, either version 3 of the License, or |
||||
# (at your option) any later version. |
||||
|
||||
# This program is distributed in the hope that it will be useful, |
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
# GNU General Public License for more details. |
||||
|
||||
# You should have received a copy of the GNU General Public License |
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
||||
|
||||
# Get custom IN and OUT labels if provided by command line arguments |
||||
while [[ $# -gt 1 ]]; do |
||||
key="$1" |
||||
case "$key" in |
||||
-i|--inlabel) |
||||
INLABEL="$2" |
||||
shift;; |
||||
-o|--outlabel) |
||||
OUTLABEL="$2" |
||||
shift;; |
||||
esac |
||||
shift |
||||
done |
||||
|
||||
[[ -z $INLABEL ]] && INLABEL="IN " |
||||
[[ -z $OUTLABEL ]] && OUTLABEL="OUT " |
||||
|
||||
# Use the provided interface, otherwise the device used for the default route. |
||||
if [[ -z $INTERFACE ]] && [[ -n $BLOCK_INSTANCE ]]; then |
||||
INTERFACE=$BLOCK_INSTANCE |
||||
elif [[ -z $INTERFACE ]]; then |
||||
INTERFACE=$(ip route | awk '/^default/ { print $5 ; exit }') |
||||
fi |
||||
|
||||
# Issue #36 compliant. |
||||
if ! [ -e "/sys/class/net/${INTERFACE}/operstate" ] || ! [ "`cat /sys/class/net/${INTERFACE}/operstate`" = "up" ] |
||||
then |
||||
echo "$INTERFACE down" |
||||
echo "$INTERFACE down" |
||||
echo "#FF0000" |
||||
exit 0 |
||||
fi |
||||
|
||||
# path to store the old results in |
||||
path="/dev/shm/$(basename $0)-${INTERFACE}" |
||||
|
||||
# grabbing data for each adapter. |
||||
read rx < "/sys/class/net/${INTERFACE}/statistics/rx_bytes" |
||||
read tx < "/sys/class/net/${INTERFACE}/statistics/tx_bytes" |
||||
|
||||
# get time |
||||
time=$(date +%s) |
||||
|
||||
# write current data if file does not exist. Do not exit, this will cause |
||||
# problems if this file is sourced instead of executed as another process. |
||||
if ! [[ -f "${path}" ]]; then |
||||
echo "${time} ${rx} ${tx}" > "${path}" |
||||
chmod 0666 "${path}" |
||||
fi |
||||
|
||||
# read previous state and update data storage |
||||
read old < "${path}" |
||||
echo "${time} ${rx} ${tx}" > "${path}" |
||||
|
||||
# parse old data and calc time passed |
||||
old=(${old//;/ }) |
||||
time_diff=$(( $time - ${old[0]} )) |
||||
|
||||
# sanity check: has a positive amount of time passed |
||||
[[ "${time_diff}" -gt 0 ]] || exit |
||||
|
||||
# calc bytes transferred, and their rate in byte/s |
||||
rx_diff=$(( $rx - ${old[1]} )) |
||||
tx_diff=$(( $tx - ${old[2]} )) |
||||
rx_rate=$(( $rx_diff / $time_diff )) |
||||
tx_rate=$(( $tx_diff / $time_diff )) |
||||
|
||||
# shift by 10 bytes to get KiB/s. If the value is larger than |
||||
# 1024^2 = 1048576, then display MiB/s instead |
||||
|
||||
# incoming |
||||
echo -n "$INLABEL" |
||||
rx_kib=$(( $rx_rate >> 10 )) |
||||
if hash bc 2>/dev/null && [[ "$rx_rate" -gt 1048576 ]]; then |
||||
printf '%sM' "`echo "scale=1; $rx_kib / 1024" | bc`" |
||||
else |
||||
echo -n "${rx_kib}K" |
||||
fi |
||||
|
||||
echo -n " " |
||||
|
||||
# outgoing |
||||
echo -n "$OUTLABEL" |
||||
tx_kib=$(( $tx_rate >> 10 )) |
||||
if hash bc 2>/dev/null && [[ "$tx_rate" -gt 1048576 ]]; then |
||||
printf '%sM' "`echo "scale=1; $tx_kib / 1024" | bc`" |
||||
else |
||||
echo -n "${tx_kib}K" |
||||
fi |
@ -0,0 +1,60 @@ |
||||
#!/usr/bin/perl |
||||
# |
||||
# Copyright 2014 Pierre Mavro <deimos@deimos.fr> |
||||
# Copyright 2014 Vivien Didelot <vivien@didelot.org> |
||||
# Copyright 2014 Andreas Guldstrand <andreas.guldstrand@gmail.com> |
||||
# |
||||
# Licensed under the terms of the GNU GPL v3, or any later version. |
||||
|
||||
use strict; |
||||
use warnings; |
||||
use utf8; |
||||
use Getopt::Long; |
||||
|
||||
# default values |
||||
my $t_warn = $ENV{T_WARN} || 50; |
||||
my $t_crit = $ENV{T_CRIT} || 80; |
||||
my $cpu_usage = -1; |
||||
my $decimals = $ENV{DECIMALS} || 2; |
||||
my $label = $ENV{label} || ""; |
||||
|
||||
sub help { |
||||
print "Usage: cpu_usage [-w <warning>] [-c <critical>] [-d <decimals>]\n"; |
||||
print "-w <percent>: warning threshold to become yellow\n"; |
||||
print "-c <percent>: critical threshold to become red\n"; |
||||
print "-d <decimals>: Use <decimals> decimals for percentage (default is $decimals) \n"; |
||||
exit 0; |
||||
} |
||||
|
||||
GetOptions("help|h" => \&help, |
||||
"w=i" => \$t_warn, |
||||
"c=i" => \$t_crit, |
||||
"d=i" => \$decimals, |
||||
); |
||||
|
||||
# Get CPU usage |
||||
$ENV{LC_ALL}="en_US"; # if mpstat is not run under en_US locale, things may break, so make sure it is |
||||
open (MPSTAT, 'mpstat 1 1 |') or die; |
||||
while (<MPSTAT>) { |
||||
if (/^.*\s+(\d+\.\d+)[\s\x00]?$/) { |
||||
$cpu_usage = 100 - $1; # 100% - %idle |
||||
last; |
||||
} |
||||
} |
||||
close(MPSTAT); |
||||
|
||||
$cpu_usage eq -1 and die 'Can\'t find CPU information'; |
||||
|
||||
# Print short_text, full_text |
||||
printf "${label} %.${decimals}f%%\n", $cpu_usage; |
||||
printf "${label} %.${decimals}f%%\n", $cpu_usage; |
||||
|
||||
# Print color, if needed |
||||
if ($cpu_usage >= $t_crit) { |
||||
print "#FF0000\n"; |
||||
exit 33; |
||||
} elsif ($cpu_usage >= $t_warn) { |
||||
print "#FFFC00\n"; |
||||
} |
||||
|
||||
exit 0; |
@ -0,0 +1,83 @@ |
||||
#!/bin/bash |
||||
# Copyright (C) 2014 Julien Bonjean <julien@bonjean.info> |
||||
# Copyright (C) 2014 Alexander Keller <github@nycroth.com> |
||||
|
||||
# This program is free software: you can redistribute it and/or modify |
||||
# it under the terms of the GNU General Public License as published by |
||||
# the Free Software Foundation, either version 3 of the License, or |
||||
# (at your option) any later version. |
||||
|
||||
# This program is distributed in the hope that it will be useful, |
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
# GNU General Public License for more details. |
||||
|
||||
# You should have received a copy of the GNU General Public License |
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
||||
|
||||
#------------------------------------------------------------------------ |
||||
|
||||
# The second parameter overrides the mixer selection |
||||
# For PulseAudio users, eventually use "pulse" |
||||
# For Jack/Jack2 users, use "jackplug" |
||||
# For ALSA users, you may use "default" for your primary card |
||||
# or you may use hw:# where # is the number of the card desired |
||||
if [[ -z "$MIXER" ]] ; then |
||||
MIXER="default" |
||||
if command -v pulseaudio >/dev/null 2>&1 && pulseaudio --check ; then |
||||
# pulseaudio is running, but not all installations use "pulse" |
||||
if amixer -D pulse info >/dev/null 2>&1 ; then |
||||
MIXER="pulse" |
||||
fi |
||||
fi |
||||
[ -n "$(lsmod | grep jack)" ] && MIXER="jackplug" |
||||
MIXER="${2:-$MIXER}" |
||||
fi |
||||
|
||||
# The instance option sets the control to report and configure |
||||
# This defaults to the first control of your selected mixer |
||||
# For a list of the available, use `amixer -D $Your_Mixer scontrols` |
||||
if [[ -z "$SCONTROL" ]] ; then |
||||
SCONTROL="${BLOCK_INSTANCE:-$(amixer -D $MIXER scontrols | |
||||
sed -n "s/Simple mixer control '\([^']*\)',0/\1/p" | |
||||
head -n1 |
||||
)}" |
||||
fi |
||||
|
||||
# The first parameter sets the step to change the volume by (and units to display) |
||||
# This may be in in % or dB (eg. 5% or 3dB) |
||||
if [[ -z "$STEP" ]] ; then |
||||
STEP="${1:-5%}" |
||||
fi |
||||
|
||||
#------------------------------------------------------------------------ |
||||
|
||||
capability() { # Return "Capture" if the device is a capture device |
||||
amixer -D $MIXER get $SCONTROL | |
||||
sed -n "s/ Capabilities:.*cvolume.*/Capture/p" |
||||
} |
||||
|
||||
volume() { |
||||
amixer -D $MIXER get $SCONTROL $(capability) |
||||
} |
||||
|
||||
format() { |
||||
perl_filter='if (/.*\[(\d+%)\] (\[(-?\d+.\d+dB)\] )?\[(on|off)\]/)' |
||||
perl_filter+='{CORE::say $4 eq "off" ? "MUTE" : "' |
||||
# If dB was selected, print that instead |
||||
perl_filter+=$([[ $STEP = *dB ]] && echo "$label "'$3' || echo "$label "'$1') |
||||
perl_filter+='"; exit}' |
||||
perl -ne "$perl_filter" |
||||
#tmp=$(perl -ne "$perl_filter") |
||||
#echo "$label $tmp" |
||||
} |
||||
|
||||
#------------------------------------------------------------------------ |
||||
|
||||
case $BLOCK_BUTTON in |
||||
3) amixer -q -D $MIXER sset $SCONTROL $(capability) toggle ;; # right click, mute/unmute |
||||
4) amixer -q -D $MIXER sset $SCONTROL $(capability) ${STEP}+ unmute ;; # scroll up, increase |
||||
5) amixer -q -D $MIXER sset $SCONTROL $(capability) ${STEP}- unmute ;; # scroll down, decrease |
||||
esac |
||||
|
||||
volume | format |
Loading…
Reference in new issue