Removed unused resources

This commit is contained in:
斟酌 鵬兄 2022-08-15 20:23:00 +08:00
parent afbbfee818
commit 824fcee942
15 changed files with 16 additions and 851 deletions

View File

@ -0,0 +1,16 @@
#!/bin/bash
function mkuserdirs {
local PROFILE PKG_DIR i
PROFILE=$( cygpath $USERPROFILE )
for i in $( ls $PROFILE | grep -o "^[A-Z][a-z]\+$" ); do
ln -vs "$PROFILE/$i" $HOME/
done
# Package Directory
PKG_DIR="$APPDATA/../Local/Packages"
if [ -d "$PKG_DIR" ]; then
ln -vs "$PKG_DIR" $HOME/
fi
}

View File

@ -1,96 +0,0 @@
#!/bin/bash
source ./config.sh
# IO Redirection
exec > $LOGFILE
exec 2> $ERRLOG
if [[ -n $BMOUNT ]] && ! grep -qs $BMOUNT /proc/mounts; then
echo Mounting $BMOUNT ...
mount $BMOUNT
MOUNTED=$?
fi
if ! [ -d $BAKDIR ]; then
mkdir $BAKDIR
fi
echo Begin backup schedule:
echo Date: $(date)
while read line; do
# substring first char
firstChr=${line::1}
# if line is not empty and does not start with "#"
if [ $firstChr ] && [ $firstChr != "#" ]; then
# file and arguments are seperated by ":"
IFS=':' read -ra ARGS <<< "$line"
# Get file
FILE=${ARGS[0]}
# if file exists
if [ -a $FILE ]; then
# filename
FILENAME=$(basename $FILE)
# set the backup name YYYYMMDDhhmm
BACKUPFILE=$(date +$FILENAME.%Y%m%d%H%M.tar.gz)
# exclude file
EXCLUDE="exclude/${ARGS[1]}"
CHDIR=$(dirname $FILE)
if [ -d $FILE ]; then
CHDIR="$FILE/../"
fi
if [ -f $EXCLUDE ]; then
tar zcf "$BAKDIR/$BACKUPFILE" -C $CHDIR $FILENAME -X $EXCLUDE
else
tar zcf "$BAKDIR/$BACKUPFILE" -C $CHDIR $FILENAME
fi
# count backup file
fCount=$(ls $BAKDIR/$FILENAME.[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].tar.gz|wc -l)
echo " Check for existing backups "$FILENAME \(Have: $fCount\)
# keep up to X backups
if [ $fCount -ne $KEEP ]; then
# delete count
dCount=`expr $fCount - $KEEP`
# loop over files
for files in $BAKDIR/*$FILENAME*.gz; do
if [ 0 -lt $dCount ]; then
# remove expired file
echo " Removing expired backup: "$files
rm "$files";
# dCount --
dCount=$((dCount-1));
fi
done
fi
fi
fi
# echo --\> $line
done < backup_list
if [[ "$MOUNTED" = 0 ]]; then
umount $BMOUNT
fi

View File

@ -1,11 +0,0 @@
# git backups
/home/git/repositories/blogAPI.git
/home/git/repositories/wenku8.git
/home/git/repositories/wenku8-android.git
/home/git/repositories/MetroSSH.git
/home/git/repositories/wconv.git
/home/git/repositories/utils.git
# www
/var/www/wenku8
/var/www/file:file.txt

View File

@ -1,9 +0,0 @@
#!/bin/bash`
LOGFILE=backup.log
ERRLOG=backup_errors.log
BMOUNT=/mnt/backup
BAKDIR=$BMOUNT/backup/cron
KEEP=7

View File

@ -1,13 +0,0 @@
#!/bin/bash
PUBKEY_URL="https://cygwin.com/key/pubring.asc"
TMP=$( mktemp )
function __o { rm $TMP; }
trap __o EXIT
curl "$PUBKEY_URL" > $TMP
gpg2 --import $TMP

View File

@ -1,2 +0,0 @@
#!/bin/bash
/opt/setup-x86_64.exe -qg

View File

@ -1,27 +0,0 @@
#!/bin/bash
SETUP_BIN="/opt/setup-x86_64.exe"
SIG_URL="https://cygwin.com/setup-x86_64.exe.sig"
SETUP_URL="https://cygwin.com/setup-x86_64.exe"
TMP_BIN=$( mktemp )
TMP_SIG=$( mktemp )
function __o { rm $TMP_BIN; rm $TMP_SIG; }
trap __o EXIT
echo "Downloading Signature ..."
curl -s "$SIG_URL" > $TMP_SIG
echo "Downloading setup binary ..."
curl -s "$SETUP_URL" > $TMP_BIN
echo "Verifying Signature ..."
gpg2 -q --verify $TMP_SIG $TMP_BIN
if [ $? -ne 0 ]; then
echo "ERROR: Bad Signature!"
else
echo "Installing setup"
cp $TMP_BIN $SETUP_BIN
chmod +x $SETUP_BIN
fi

View File

@ -1,11 +0,0 @@
#!/bin/bash
PROFILE=$( cygpath $USERPROFILE )
for i in $( ls $PROFILE | grep -o "^[A-Z][a-z]\+$" ); do
ln -vs "$PROFILE/$i" $HOME/
done
# Package Directory
PKG_DIR="$APPDATA/../Local/Packages"
if [ -d "$PKG_DIR" ]; then
ln -vs "$PKG_DIR" $HOME/
fi

View File

@ -1,30 +0,0 @@
#!/bin/bash
if [ -f $1 ]; then
source $1
fi
uname | grep -q Linux
LINUX=$?
if [ "$LINUX" -eq "0" ]; then
HOST=/etc/hosts
else
HOST=/cygdrive/c/Windows/System32/drivers/etc/hosts
fi
if [ ${HOSTNAMES[0]+1} ]; then
for i in {0..99};
do
if [ ${HOSTNAMES[$i]+1} ]; then
XID="# Automated Host Def. Id. $i"
if grep -q "$XID" $HOST; then
REC=$( echo "s/.*$XID$/${HOSTNAMES[$i]}\ $XID/g" | sed "s/\ /\\\ /g" )
sed -i "$REC" $HOST
else
echo ${HOSTNAMES[$i]} $XID >> $HOST
fi
fi
done
fi

View File

@ -1,7 +0,0 @@
#!/bin/bash
HOSTNAMES=()
for i in {0..99}; do
HOSTNAMES[$i]=""
done

View File

@ -1,5 +0,0 @@
#!/bin/bash
cd /opt/utils
fileName=$(java Main_mod $1)
cd /media/Misc/Temp
mv $1 $fileName

View File

@ -1,496 +0,0 @@
<?php
class ERROR {
const INVALID_DATA = 1;
const UNDEFINED_DATA = 2;
const TYPE_MISSMATCH = 3;
const READ_ONLY = 11;
const GREATER_COMPARATIVE = 21;
const EOF = 100;
function __construct($type, $a, $b)
{
throw new Exception($type);
}
}
class ByteArray extends ArrayObject {
private $position = 0;
public function ByteArray($str = NULL) {
if(is_string($str)) {
$length = strlen($str);
for($i = 0; $i < $length; $i ++)
$this[] = ord($str[$i]);
}
}
//<editor-fold defaultstate="collapsed" desc="Cryptographic">
public function encrypt() {
}
public function decrypt() {
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="GET,SET,OFFSET.SET">
public function __get($prop) {
switch($prop) {
case 'length':
return count($this);
break;
case 'position':
return $this->position;
break;
case 'byteAvailable' :
return count($this) - $this->position;
break;
default :
return "Property($prop) is undefined";
}
}
public function __set($prop, $val) {
try {
switch ($prop) {
case 'length':
if (is_int($val)) {
$l = count($this);
if ($val < $l) {
if ($val > -1) {
while ($val < count($this)) {
$this->offsetUnset(count($this) - 1);
}
} else {
new ERROR(ERROR::INVALID_DATA, "length($val)");
}
} else {
while (count($this) < $val)
$this[] = 0;
}
} else {
new ERROR(ERROR::TYPE_MISSMATCH, "($val)", 'an integer');
}
break;
case 'position':
if (is_int($val)) {
$l = count($this);
if ($val < $l) {
if ($val > -1) {
$this->position = $val;
} else {
new ERROR(ERROR::INVALID_DATA, "length($val)");
}
} else {
new ERROR(ERROR::GREATER_COMPARATIVE, "Position($val)", "length($l)");
}
} else {
new ERROR(ERROR::TYPE_MISSMATCH, "($val)", 'an integer');
}
break;
case 'byteAvailable' :
new ERROR(ERROR::READ_ONLY, "Property($prop)");
break;
default :
new ERROR(ERROR::UNDEFINED_DATA, "property($prop)");
}
} catch(Exception $e) {
echo $e;
}
}
public function offsetSet($i, $val) {
try {
if(is_int($val)) {
if($i > -1) {
while(count($this) < $i)
$this[] = 0;
parent::offsetSet($i, $val & 0xff);
} else if($i == NULL) {
parent::offsetSet(count($this), $val & 0xff);
} else {
new ERROR(ERROR::TYPE_MISSMATCH, "index($val)");
}
} else {
new ERROR(ERROR::TYPE_MISSMATCH, "($val)", 'an integer');
}
} catch(Exception $e) {
echo $e;
}
}
//</editor-fold>
public function compress() {
$str = gzcompress($this->save());
$this->clear();
$this->ByteArray($str);
}
public function deflate() {
$str = gzuncompress($this->save());
$this->clear();
$this->ByteArray($str);
}
public function save() {
$str = '';
foreach($this as $i)
$str .= chr($i);
return $str;
}
public function clear() {
$this->length = 0;
$this->position = 0;
}
// <editor-fold defaultstate="collapsed" desc="ReadUtils">
public function readBoolean() {
$p = $this->getPos();
if ($p)
return (bool) $this[$p];
else
return NULL;
}
public function readByte() {
//Returns -128 ~ 127
$p = $this->getPos();
if(is_int($p)) {
$p = $this[$p];
return $p < 128 ? $p : $p - 256;
}
return NULL;
}
public function readBytes(ByteArray $b, $p = 0, $l = 0) {
try {
if (($this->position + $l) < count($this)) {
if ($l > 0 || ($l = count($this))) {
for ($i = 0; $i < $l; $i++)
$b[$p + $i] = $this->readByte();
} else {
new ERROR(ERROR::UNDEFINED_DATA);
}
} else {
new ERROR(ERROR::EOF);
}
} catch (Exception $e) {
echo $e;
}
}
public function readDouble() {
//Reads an IEEE 754 double-precision (64-bit) floating-point number from the byte stream.
$s = $this->tobin($this->readByte())
.$this->tobin($this->readByte())
.$this->tobin($this->readByte())
.$this->tobin($this->readByte())
.$this->tobin($this->readByte())
.$this->tobin($this->readByte())
.$this->tobin($this->readByte())
.$this->tobin($this->readByte());
if($s*1 == 0)
return 0;
return $this->decodeIEEE($s);
}
public function readFloat() {
//Reads an IEEE 754 single-precision (32-bit) floating-point number from the byte stream.
$s = $this->tobin($this->readByte())
.$this->tobin($this->readByte())
.$this->tobin($this->readByte())
.$this->tobin($this->readByte());
if($s*1 == 0)
return 0;
return $this->decodeIEEE($s);
}
public function readInt() {
//Returns -2147483648 ~ 2147483647
if(($s = hexdec($this->tohex($this->readByte())
.$this->tohex($this->readByte())
.$this->tohex($this->readByte())
.$this->tohex($this->readByte())))
> 2147483647)
$s -= 4294967296;
return $s;
}
public function readMultiByte($length, $charSet) {
}
public function readShort() {
if(($s = hexdec($this->tohex($this->readByte())
.$this->tohex($this->readByte())))
> 32767)
$s -= 65536;
return $s;
}
public function readUnsignedByte() {
return hexdec($this->tohex($this->readByte()));
}
public function readUnsignedInt() {
return hexdec($this->tohex($this->readByte())
.$this->tohex($this->readByte())
.$this->tohex($this->readByte())
.$this->tohex($this->readByte()));
}
public function readUnsignedShort() {
return hexdec($this->tohex($this->readByte())
.$this->tohex($this->readByte())
.$this->tohex($this->readByte())
.$this->tohex($this->readByte()));
}
public function readUTF() {
}
public function readUTFBytes() {
}
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="WriteUtils">
public function writeBoolean($b) {
try {
if (is_bool($b)) {
new ERROR(ERROR::TYPE_MISSMATCH, "($b)");
} else {
if ($this->position < count($this))
$b ? ($this[$this->getPos()] = 1) : ($this[$this->getPos()] = 0);
else
$b ? ($this[] = 1) : ($this[] = 0);
}
} catch (Exception $e) {
echo $e;
}
}
public function writeByte($b) {
if($this->position < count($this)) {
$this[$this->getPos()] = $b;
} else {
$this[] = $b;
$this->getPos();
}
}
public function writeBytes(ByteArray $b, $p = 0, $l = 0) {
try {
if ($l > 0 || ($l = count($b))) {
for ($i = 0; $i < $l; $i++)
$this->writeByte($b[$p + $i]);
} else {
new ERROR(ERROR::UNDEFINED_DATA);
}
} catch (Exception $e) {
echo $e;
}
}
public function writeDouble($num) {
if($num == 0) {
$num = str_pad('', 64, '0');
} else {
$num = $this->encodeIEEE($num, 8)."\n";
}
for($i = 0; $i < 64; $i += 8)
$this->writeByte(bindec(substr($num, $i, 8)));
}
public function writeFloat($num) {
if($num == 0) {
$num = str_pad('', 32, '0');
} else {
$num = $this->encodeIEEE($num, 4)."\n";
}
for($i = 0; $i < 32; $i += 8)
$this->writeByte(bindec(substr($num, $i, 8)));
}
public function writeInt($num) {
$this->writeByte($num >> 24 & 0xFF);
$this->writeByte($num >> 16 & 0xFF);
$this->writeByte($num >> 8 & 0xFF);
$this->writeByte($num & 0xFF);
}
public function writeMultiByte($length, $charSet) {
}
public function writeShort($num) {
$this->writeByte($num >> 8 & 0xFF);
$this->writeByte($num & 0xFF);
}
public function writeUnsignedInt($num) {
$this->writeByte($num >> 56 & 0xFF);
$this->writeByte($num >> 48 & 0xFF);
$this->writeByte($num >> 40 & 0xFF);
$this->writeByte($num >> 32 & 0xFF);
$this->writeByte($num >> 24 & 0xFF);
$this->writeByte($num >> 16 & 0xFF);
$this->writeByte($num >> 8 & 0xFF);
$this->writeByte($num & 0xFF);
}
public function writeUTF() {
}
public function writeUTFBytes() {
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="IEEE convertions">
private function decodeIEEE($str) {
$s = $str[0] ? -1:1;
if(($l = strlen($str)) == 8) {
$e = bindec(substr($str, 1, 3)) - 3;
$m = substr($str, 4, 8);
} else if($l == 16) {
} else if($l == 32) {
$e = bindec(substr($str, 1, 8)) - 127;
$m = '1'.substr($str, 9, 32);
} else if($l == 64) {
$e = bindec(substr($str, 1, 11)) - 1023;
$m = '1'.substr($str, 12, 64);
}
if((++ $e) > 0) {
$m1 = substr($m, 0, $e);
$m2 = substr($m, $e);
} else {
while($e < 0) {
$m = '0'.$m;
$e ++;
}
$m1 = 0;
$m2 = $m;
}
$str = 0;
$e = strlen($m1);
for($i = 0; $i < $e; $i ++) {
if($m1[$i]) {
$str += $m1[$i]*pow(2, ($e - 1) - $i);
}
}
$e = strlen($m2);
for($i = 0; $i < $e; $i ++) {
if($m2[$i]) {
$str += $m2[$i]*pow(2, -($i + 1));
}
}
return $str*$s;
}
private function encodeIEEE($num, $byte) {
try {
if(is_numeric($num)) {
$s = $num > 0 ? 0:1;
$m1 = $s ? -1*$num : 1*$num;
$num = explode('.', $num);
$m1 = $num[0]*1;
if(count($num) > 1)
$m2 = '0.'.$num[1];
else $m2 = '0';
if($byte == 1) {
} else if($byte == 2) {
} else if($byte == 4) {
$e = 8;
$f = 23;
$b = 127;
} else if($byte == 8) {
$e = 11;
$f = 52;
$b = 1023;
} else {
new ERROR(ERROR::INVALID_DATA, "byte($byte)");
}
$num = '';
if($m1 > 1) {
$m1 = decbin($m1);
$e = str_pad(decbin(strlen($m1) - 1 + $b), $e, '0', STR_PAD_LEFT);
} else if($m1 == 1) {
$e = '0'.str_pad('', $e - 1, '1');
}
$num .= $m1;
$f *= 2;
for($i = 0; $i < $f; $i ++) {
$m2 *= 2;
if($m2 >= 1) {
$num .= '1';
$m2 -= 1;
} else {
$num .= '0';
}
}
if($m1 == 0) {
for($m1 = 0; $num[0] == '0'; $m1 --) {
$num = substr($num, 1);
}
$e = str_pad(decbin($m1 + $b), $e, '0', STR_PAD_LEFT);
}
$num = substr($num, 1, $f *= .5);
$num || ($num = str_pad('', $f, '0'));
return "$s$e$num";
} else {
new ERROR(ERROR::INVALID_DATA, $num);
}
} catch(Exception $e) {
echo $e;
}
}
//</editor-fold>
private function getPos() {
try {
if ($this->position < count($this))
return $this->position++;
else
new ERROR(ERROR::EOF);
} catch (Exception $e) {
echo $e;
}
return NULL;
}
private function tobin($num) {
$num = $num < 0 ? $num + 256:$num;
$num = decbin($num);
while(strlen($num) != 8) {
$num = '0'.$num;
}
return $num;
}
private function tohex($num) {
return (($num = ($num < 0) ? $num + 256:$num) < 16) ? '0'.dechex($num):dechex($num);
}
}
//* Tests
$a = new ByteArray();
$a->writeInt(12345);
$a->writeShort(11223);
$a->writeUnsignedInt(1125434357);
$a->position = 0;
echo "ReadInt: ";
echo $a->readInt()."\n";
echo "ReadShort: ";
echo $a->readShort()."\n";
echo "readUnsignedShort: ";
echo $a->readUnsignedInt()."\n";
$a->position = 0;
$a->writeDouble(1);
$a->writeDouble(0);
$a->writeDouble(1.00123);
$a->writeDouble(0.2156);
$a->writeDouble(100);
$a->writeDouble(1012.1234);
$a->writeFloat(2);
$a->writeFloat(1);
$a->writeFloat(0);
$a->writeFloat(0.00123);
$a->writeFloat(23.2156);
$a->writeFloat(150);
$a->writeFloat(132.1);
$a->position = 0;
echo "readDouble: ";
echo $a->readDouble()."\n";
echo "readDouble: ";
echo $a->readDouble()."\n";
echo "readDouble: ";
echo $a->readDouble()."\n";
echo "readDouble: ";
echo $a->readDouble()."\n";
echo "readDouble: ";
echo $a->readDouble()."\n";
echo "readDouble: ";
echo $a->readDouble()."\n";
echo "readFloat: ";
echo $a->readFloat()."\n";
echo "readFloat: ";
echo $a->readFloat()."\n";
echo "readFloat: ";
echo $a->readFloat()."\n";
echo "readFloat: ";
echo $a->readFloat()."\n";
echo "readFloat: ";
echo $a->readFloat()."\n";
echo "readFloat: ";
echo $a->readFloat()."\n";
//*/
?>

View File

@ -1,55 +0,0 @@
<?php
namespace astropenguin\botanical;
use ArrayObject;
class Args
{
//parseOptions utilitiese by tgckpg
static function PARSE ( $argStream, $handler )
{
//Chop first useless argument -- argv[0]
array_shift ( $argStream ) ;
//Initiate ArrayObject for iterator
$arrayobject = new ArrayObject ( $argStream ) ;
//Initiate iterator for iteration
$iterator = $arrayobject->getIterator();
//If options is set first
if( $iterator->valid() && preg_match ( '/^-\w$/', $iterator->current() ) )
{
//iterate through whole argument stream
for ( ; $iterator->valid(); $iterator->next() )
{
//Check if reached next option
if( preg_match ( '/^-\w$/', $opts = $iterator->current() ) )
{
//Get current options
$currOpt = $opts;
//echo "$currOpt\n";
//Test if next stream is an option
for ( $iterator->next(); $iterator->valid(); $iterator->next() )
{
if ( preg_match ( '/^-\w$/', $opts = $iterator->current() ) )
{
//echo "$currOpt $opts\n";
$handler($currOpt);
$currOpt = $opts;
} else break;
//var_dump($iterator->valid());
}
}//End if
//echo "$currOpt $opts\n";
$handler($currOpt, $opts);
//A temporary fix for infinite loop
if(!$iterator->valid()) break;
}// End for
}
// If option is not set first.
else
{
//Try other approach.
}
// End if
}
}

View File

@ -1,31 +0,0 @@
<?php
# ########################################
# File: package.php
# Description:
# Namespace Package Loader
#
# Created on: 22 July 2014
# Last Modified: Tue 22 Jul 2014 02:37:14 PM HKT
# by: penguin
# ##################
IF( !function_exists( '___astropenguin_autoload' ) ):
define( "_APPATH_", dirname( __FILE__ ) . '/' );
function ___astropenguin_autoload( $classname )
{
if( strncmp( $classname, 'astropenguin\\', 12 ) === 0 )
{
$classfile = str_replace( '\\', '/', substr( $classname, 12 ) );
$result = @include_once _APPATH_ . $classfile . '.php';
if( !$result )
{
trigger_error( "Failed to include $classfile" );
}
}
}
spl_autoload_register( '___astropenguin_autoload' );
ENDIF;

View File

@ -1,58 +0,0 @@
<?php
function delUponExit()
{
if(is_file('/tmp/php.apt_history.log'))
unlink('/tmp/php.apt_history.log');
}
register_shutdown_function('delUponExit');
$i = 1;
exec("ls /var/log/apt/history.log.*.gz", $list);
foreach($list as $entry)
{
$lines = gzfile($entry);
file_put_contents("/tmp/php.apt_history.log", $lines, FILE_APPEND);
}
$list = null;
exec("cat /var/log/apt/history.log >> /tmp/php.apt_history.log");
exec('cat /tmp/php.apt_history.log |egrep --regexp=\'^Commandline:\sapt-get\s[(install)(remove)(purge)]\'|awk \'{print $3" "$4}\'', $list);
$i = 0; $j = 0;
foreach($list as $entry)
{
$history=explode(" ", $entry);
if($history[0] == "autoremove" || $history[0] == "upgrade")continue;
$history[0] == "install" ? ($packages[$history[1]]=true):($packages[$history[1]]=false);
}
foreach($packages as $package => $stat)
{
$stat ? ($ipackage[$i ++] = $package):($rpackage[$j ++] = $package);
}
$i = sizeOf($ipackage);
$j = sizeOf($rpackage);
$l = $i > $j ? $i:$j;
echo "Custom package activities(apt-get):\n";
echo "+---------------------------------------------------------+\n";
echo "| Package(s) installed | Package(s) removed |\n";
echo "|----------------------------+----------------------------|\n";
$ll = .5*(strlen("+---------------------------------------------------------+") - 3);
for($k = 0; $k < $l; $k ++) {
$il = str_pad($k < $i ? $ipackage[$k]:"", $ll, " ", STR_PAD_BOTH);
$rl = str_pad($k < $j ? $rpackage[$k]:"", $ll, " ", STR_PAD_BOTH);
echo "|$il|$rl|\n";
}
echo "+---------------------------------------------------------+\n";