diff options
-rwxr-xr-x | extract.sh | 52 | ||||
-rwxr-xr-x | fix_ntfs.sh | 19 | ||||
-rwxr-xr-x | oss_mute.sh | 25 | ||||
-rwxr-xr-x | pagerank | bin | 8930 -> 8930 bytes | |||
-rw-r--r-- | pagerank.c | 89 | ||||
-rwxr-xr-x | parse_xdefaults.sh | 7 | ||||
-rwxr-xr-x | prank | 2 | ||||
-rw-r--r-- | python/1.py | 7 | ||||
-rwxr-xr-x | ssh-mount.sh | 10 | ||||
-rwxr-xr-x | ssh-unmount.sh | 4 | ||||
-rwxr-xr-x | xup.sh | 26 |
11 files changed, 164 insertions, 77 deletions
diff --git a/extract.sh b/extract.sh deleted file mode 100755 index bbb317a..0000000 --- a/extract.sh +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/bash -#----------------------------------------------------# -# File: ~/bin/extract.sh # -# Version: 0.1.0 # -# Date: 2008-11-02 # -# Author: Florian "Bluewind" Pritz <f-p@gmx.at> # -# Extract an archive based on the mime type # -#----------------------------------------------------# -# 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/>. - -if [ "$1" = "" ] || [ "$1" = "-h" ]; then - echo -e "${blue}Usage:$NC $0 <file>"; - echo -e "Extracts <file>"; - echo -e "Also accepts multiple files"; - exit 0 -fi -for file in "$@" -do - if [ -f ${file} ] ; then - case ${file} in - *.tar.bz2) tar xjf ${file} ;; - *.tar.gz) tar xzf ${file} ;; - *.tbz2) tar xjf ${file} ;; - *.tgz) tar xzf ${file} ;; - *) - case $(file -bi ${file}) in - application/x-bzip2) bunzip2 ${file};; - application/rar) unrar x ${file};; - application/x-gzip) gunzip ${file};; - application/x-tar) tar xf ${file};; - application/zip) unzip ${file};; - application/x-compressed) uncompress ${file};; - application/x-7z-compressed) 7z x ${file};; - *) echo -e "${RED}Error:$NC No rule how to extract \"${file}\" ($(file -bi ${file}))" ;; - esac - ;; - esac - else - echo -e "${RED}Error:$NC \"${file}\" doesn't exist" - fi -done diff --git a/fix_ntfs.sh b/fix_ntfs.sh new file mode 100755 index 0000000..f386717 --- /dev/null +++ b/fix_ntfs.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +gksu -S true + +sudo -n true &> /dev/null +exitcode=$? +if [ $exitcode -gt 0 ]; then + exit +fi + +DRIVE=$(dmesg | grep -o "sd.: sd.." | grep "sd.." | tail -n 1) +DEVICE=$(echo $DRIVE | grep -o "sd.") + +sudo fdisk -l $DEVICE | grep "$DRIVE.*NTFS" +exitcode=$? + +if [ $exitcode -eq 0 ]; then + xterm -geometry "40x10" -title "Fixing..." -e "sudo ntfsfix $DRIVE && sleep 2" +fi diff --git a/oss_mute.sh b/oss_mute.sh index 5db3ea2..128ee52 100755 --- a/oss_mute.sh +++ b/oss_mute.sh @@ -1,8 +1,23 @@ #!/bin/dash -MUTE=$(ossmix | grep "^jack.green.mute\ " | awk '{print $4}' | awk -F')' '{print $1}') -if [ "$MUTE" = 'ON' ]; then - ossmix "jack.green.mute" OFF -else - ossmix "jack.green.mute" ON +MODE=1 +CONTROL="jack.black.mute" + +if [ $MODE = 1 ]; then + MUTE=$(ossmix | grep "^$CONTROL\ " | awk '{print $4}' | awk -F')' '{print $1}') + if [ "$MUTE" = 'ON' ]; then + ossmix "$CONTROL" OFF + else + ossmix "$CONTROL" ON + fi +elif [ $MODE = 2 ]; then + VOLUME=$(cat $HOME/.volume) + if [ -z "$VOLUME" ]; then + VOLUME=$(ossmix | grep "^$CONTROL " | awk '{print $4}' | awk -F : '{print $1}') + ossmix $CONTROL 0 + echo $VOLUME > $HOME/.volume + else + ossmix $CONTROL $VOLUME + echo "" > $HOME/.volume + fi fi Binary files differdiff --git a/pagerank.c b/pagerank.c new file mode 100644 index 0000000..ec62ec8 --- /dev/null +++ b/pagerank.c @@ -0,0 +1,89 @@ +/****************************************************************************** +Filename : pagerank.c +Description : Google PageRank Checksum Algorithm +Author : http://zhiwei.li/ +Log : Ver 0.1 2005-9-13 first release + Ver 1.0 2005-10-19 fixed :final character bug + Ver 1.1 2006-10-05 refine code + Ver 1.2 2008-8-20 use boolean type +******************************************************************************/ + +#include <stdio.h> +#include <stdbool.h> + +int ConvertStrToInt(char *pStr, int Init, int Factor) +{ + while (*pStr) { + Init *= Factor; + Init += *pStr++; + } + return Init; +} + +int HashURL(char *pStr) +{ + unsigned int C1, C2, T1, T2; + + C1 = ConvertStrToInt(pStr, 0x1505, 0x21); + C2 = ConvertStrToInt(pStr, 0, 0x1003F); + C1 >>= 2; + C1 = ((C1 >> 4) & 0x3FFFFC0) | (C1 & 0x3F); + C1 = ((C1 >> 4) & 0x3FFC00) | (C1 & 0x3FF); + C1 = ((C1 >> 4) & 0x3C000) | (C1 & 0x3FFF); + + T1 = (C1 & 0x3C0) << 4; + T1 |= C1 & 0x3C; + T1 = (T1 << 2) | (C2 & 0xF0F); + + T2 = (C1 & 0xFFFFC000) << 4; + T2 |= C1 & 0x3C00; + T2 = (T2 << 0xA) | (C2 & 0xF0F0000); + + return (T1 | T2); +} + +char CheckHash(unsigned int HashInt) +{ + int Check = 0; + bool Flag = false; + int Remainder; + + do { + Remainder = HashInt % 10; + HashInt /= 10; + if (Flag){ + Remainder += Remainder; + Remainder = (Remainder / 10) + (Remainder % 10); + } + Check += Remainder; + Flag = !Flag; + } while( 0 != HashInt); + + Check %= 10; + if (0 != Check) { + Check = 10 - Check; + if (Flag) { + if (1 == (Check % 2)) { + Check += 9; + } + Check >>= 1; + } + } + Check += 0x30; + return Check; +} + +int main(int argc, char* argv[]) +{ + unsigned int HashInt; + + if (argc != 2) { + printf("Usage: %s [URL]\n",argv[0]); + return 1; + } + + HashInt = HashURL(argv[1]); + printf("Checksum=7%c%u\n", CheckHash(HashInt), HashInt); + return 0; +} + diff --git a/parse_xdefaults.sh b/parse_xdefaults.sh new file mode 100755 index 0000000..5f61eec --- /dev/null +++ b/parse_xdefaults.sh @@ -0,0 +1,7 @@ +#!/bin/sh +colors=($(cat ${HOME}/.Xdefaults | ack ".*color[0-9]{1,2}:.*#" | sed 's/.*color.*#//g')) +prefix=(0 1 2 3 4 5 6 7 8 9 A B C D E F) +for key in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 +do + echo -en "\e]P${prefix[$key]}${colors[$key]}" +done @@ -14,7 +14,7 @@ then exit 1 fi -pr_checksum_prog="pagerank" +pr_checksum_prog="$(dirname $0)/pagerank" if [ ! -x $pr_checksum_prog ] then diff --git a/python/1.py b/python/1.py new file mode 100644 index 0000000..968fc70 --- /dev/null +++ b/python/1.py @@ -0,0 +1,7 @@ +#!/usr/bin/python + +import sys + +action = sys.stdin.read() +action = action "blub" +print action diff --git a/ssh-mount.sh b/ssh-mount.sh index c5765c8..601406b 100755 --- a/ssh-mount.sh +++ b/ssh-mount.sh @@ -2,18 +2,18 @@ if [ "$1" = "" ] || [ "$1" = "-h" ]; then - echo -e "${blue}Usage:$NC mount-ftp <server_string>"; + echo -e "${blue}Usage:$NC ssh-mount <server_string>"; echo -e "${green}Servers:$NC wf, nevera-web, nevera-flo, df"; exit 1 else case $1 in nevera-flo) - sshfs flo@nevera: -o reconnect -p 22222 ${HOME}/workspace/ipx_flo_ssh && - echo -e "${GREEN}Nevera /home/flo mounted.$NC" + sshfs flo@nevera: -o reconnect -p 22222 ${HOME}/workspace/nevera/flo && + echo -e "${GREEN}Nevera: /home/flo mounted.$NC" ;; nevera-web) - sshfs web0@nevera: -o reconnect -p 22222 ${HOME}/workspace/ipx_ssh && - echo -e "${GREEN}Nevera web mounted.$NC" + sshfs web0@nevera: -o reconnect -p 22222 ${HOME}/workspace/nevera/web && + echo -e "${GREEN}Nevera: web mounted.$NC" ;; df) sshfs 105012-ftp@seitznet2.at: -o reconnect -p 22 ${HOME}/workspace/df_ssh && diff --git a/ssh-unmount.sh b/ssh-unmount.sh index 41664ec..1c4344e 100755 --- a/ssh-unmount.sh +++ b/ssh-unmount.sh @@ -1,7 +1,7 @@ #!/bin/sh -fusermount -uq ${HOME}/workspace/ipx_ssh -fusermount -uq ${HOME}/workspace/ipx_flo_ssh +fusermount -uq ${HOME}/workspace/nevera/web +fusermount -uq ${HOME}/workspace/nevera/flo fusermount -uq ${HOME}/workspace/df_ssh fusermount -uq ${HOME}/workspace/wf_ssh @@ -1,8 +1,8 @@ #!/bin/sh #----------------------------------------------------# # File: xup.sh -# Version: 0.1.1 -# Date: 2008-12-14 +# Version: 0.1.3 +# Date: 2009-01-12 # Author: Florian "Bluewind" Pritz <f-p@gmx.at> # Upload file to XUP, copy URL to clipboard and # save to historyfile @@ -21,17 +21,19 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. XUPHIST="${HOME}/.xup_history" -FILE=$(basename $1) -DIR=$(dirname $1) -cd $DIR +FILE="$(basename "$1")" +DIR="$(dirname "$1")" +cd "$DIR" URLS=$(curl -# -F "F1=@$FILE" -L "http://www.xup.in/xtrans.php" -H "Expect: ") -DL_URL=$(echo -n ${URLS} | ack -o "\"http://www.xup.in/dl,.{8}/$FILE/\"" | sed "s#\"##g") -DEL_URL=$(echo -n ${URLS} | ack -o "\"http://www.xup.in/kill,.{8},.{10}/\"" | sed "s#\"##g") +DL_URL=$(echo -n ${URLS} | egrep -o "\"http://www.xup.in/dl,.{8}/$FILE/\"" | sed "s#\"##g") +DEL_URL=$(echo -n ${URLS} | egrep -o "\"http://www.xup.in/kill,.{8},.{10}/\"" | sed "s#\"##g") -echo $(date) >> $XUPHIST -echo "$PWD/$FILE" >> $XUPHIST -echo $DL_URL >> $XUPHIST +echo $(date) >> "$XUPHIST" +echo "$PWD/$FILE" >> "$XUPHIST" +echo $DL_URL >> "$XUPHIST" echo -n $DL_URL | xclip -echo $DEL_URL >> $XUPHIST -echo "" >> $XUPHIST +echo -n $DL_URL +echo $DEL_URL >> "$XUPHIST" +echo "" >> "$XUPHIST" +sleep 2 |