From 0c8741059abcaaed99e627e42b99c50a17abbf08 Mon Sep 17 00:00:00 2001 From: Næþ'n Lasseter Date: Thu, 29 Sep 2016 14:20:52 +0100 Subject: New scripts --- apt-stuff | 2 ++ b | 1 + botchcli | 6 ++++-- box | 46 ++++++++++++++++++++++++++++++++++++++++++++++ costvm | 2 +- d | 33 +++++++++++++++++++++++++++++++++ h | 1 + o | 1 + waitfor | 5 +++++ 9 files changed, 94 insertions(+), 3 deletions(-) create mode 120000 b create mode 100755 box create mode 100755 d create mode 120000 h create mode 120000 o create mode 100755 waitfor diff --git a/apt-stuff b/apt-stuff index c55a887..6b3ee51 100755 --- a/apt-stuff +++ b/apt-stuff @@ -1,5 +1,7 @@ #!/bin/bash +set -ex + sudo apt-get update sudo apt-get -y upgrade sudo apt-get -y --purge autoremove diff --git a/b b/b new file mode 120000 index 0000000..c59d9b6 --- /dev/null +++ b/b @@ -0,0 +1 @@ +d \ No newline at end of file diff --git a/botchcli b/botchcli index 5dfa0f7..0d630b2 100755 --- a/botchcli +++ b/botchcli @@ -1,10 +1,11 @@ #!/bin/bash SUBCHAR=! +CMDNO=1 [[ "$*" =~ $SUBCHAR ]] && WORK=$* || WORK="$* $SUBCHAR" -echo -n "[botchcli] $WORK> " +echo -n "[botchcli ${CMDNO}] $WORK> " while read LINE; do if [ "x$LINE" == "x" ] ; then echo -n @@ -13,5 +14,6 @@ while read LINE; do else ${WORK/$SUBCHAR/$LINE} fi - echo -n "[botchcli] $WORK> " + CMDNO=$((${CMDNO} + 1)) + echo -n "[botchcli ${CMDNO}] $WORK> " done diff --git a/box b/box new file mode 100755 index 0000000..a4eb7b0 --- /dev/null +++ b/box @@ -0,0 +1,46 @@ +#!/usr/bin/env ruby + +require 'optparse' + +options = { + :border => 3, + :margin => 1, + :character => '=' +} + +parser = OptionParser.new do |opt| + opt.banner = "Usage: box [OPTIONS] WORDS" + + opt.on("-c", "--border-character", :REQUIRED, "Border character (default: =)") do |c| + options[:character] = c + end + opt.on("-b", "--border-width", :REQUIRED, "Left and right border width (default: 3)") do |b| + options[:border] = b.to_i + end + opt.on("-m", "--margin-width", :REQUIRED, "Left and right margin width (default: 1)") do |m| + options[:margin] = m.to_i + end + opt.on("-h", "--help", "Print usage") do + puts opt.banner + puts opt.summarize + exit 0 + end +end + +parser.parse! + +if ARGV.length <= 0 then + exit +end + +input = ARGV.join(' ').chomp + +len = input.length + 2 * options[:border] + 2 * options[:margin] + +puts options[:character] * len +puts options[:character] * options[:border] + + " " * options[:margin] + + input + + " " * options[:margin] + + options[:character] * options[:border] +puts options[:character] * len diff --git a/costvm b/costvm index 895a4bf..df0b542 100755 --- a/costvm +++ b/costvm @@ -62,7 +62,7 @@ DISKS.each do |disk| when 'ssd' cost += (size/0.5).ceil * 2 when 'archive' - cost += (size/50.0).ceil * 2 + cost += (size/100.0).ceil * 2 end end diff --git a/d b/d new file mode 100755 index 0000000..cedcfc0 --- /dev/null +++ b/d @@ -0,0 +1,33 @@ +#!/usr/bin/env ruby + +num = ARGV.shift +exit 1 if num.nil? + +case File.basename($PROGRAM_NAME) +when 'd' + num = num.to_i(10) +when 'h' + num = num.to_i(16) +when 'o' + num = num.to_i(8) +when 'b' + num = num.to_i(2) +end + +dec = hex = oct = bin = true +out = ARGV.shift +case out +when 'd' + hex = oct = bin = false +when 'h' + dec = oct = bin = false +when 'o' + dec = hex = bin = false +when 'b' + dec = hex = oct = false +end + +puts " Decimal : #{num.to_s(10)}" if dec +puts "Hexadecimal : #{num.to_s(16)}" if hex +puts " Octal : #{num.to_s(8)}" if oct +puts " Binary : #{num.to_s(2)}" if bin diff --git a/h b/h new file mode 120000 index 0000000..c59d9b6 --- /dev/null +++ b/h @@ -0,0 +1 @@ +d \ No newline at end of file diff --git a/o b/o new file mode 120000 index 0000000..c59d9b6 --- /dev/null +++ b/o @@ -0,0 +1 @@ +d \ No newline at end of file diff --git a/waitfor b/waitfor new file mode 100755 index 0000000..f83fa90 --- /dev/null +++ b/waitfor @@ -0,0 +1,5 @@ +#!/bin/bash + +while true ; do + $* && break +done -- cgit v1.2.3