diff options
author | Næþ'n Lasseter <Næþ'n Lasseter nathan@bytemark.co.uk> | 2016-09-29 14:20:52 +0100 |
---|---|---|
committer | Næþ'n Lasseter <Næþ'n Lasseter nathan@bytemark.co.uk> | 2016-09-29 14:20:52 +0100 |
commit | 0c8741059abcaaed99e627e42b99c50a17abbf08 (patch) | |
tree | aa3e5df103066eb68d39fea0b88db68ceb5570d5 | |
parent | e6e6fe3cd13aaecf83cf3105c3fcd81db97481b5 (diff) |
New scripts
-rwxr-xr-x | apt-stuff | 2 | ||||
l--------- | b | 1 | ||||
-rwxr-xr-x | botchcli | 6 | ||||
-rwxr-xr-x | box | 46 | ||||
-rwxr-xr-x | costvm | 2 | ||||
-rwxr-xr-x | d | 33 | ||||
l--------- | h | 1 | ||||
l--------- | o | 1 | ||||
-rwxr-xr-x | waitfor | 5 |
9 files changed, 94 insertions, 3 deletions
@@ -1,5 +1,7 @@ #!/bin/bash +set -ex + sudo apt-get update sudo apt-get -y upgrade sudo apt-get -y --purge autoremove @@ -0,0 +1 @@ +d
\ No newline at end of file @@ -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 @@ -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 @@ -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 @@ -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 @@ -0,0 +1 @@ +d
\ No newline at end of file @@ -0,0 +1 @@ +d
\ No newline at end of file @@ -0,0 +1,5 @@ +#!/bin/bash + +while true ; do + $* && break +done |