You are not logged in.
If you're ever going to be moving between partitions you should also add error checking. In case disk is full, etc
[git] | [AURpkgs] | [arch-games]
Offline
If you're ever going to be moving between partitions you should also add error checking. In case disk is full, etc
thanks for the pointer:)
right now its all on the same partition, i just get abit ocd with my file/folder layout
Last edited by markp1989 (2010-01-30 22:36:33)
Desktop: E8400@4ghz - DFI Lanparty JR P45-T2RS - 4gb ddr2 800 - 30gb OCZ Vertex - Geforce 8800 GTS - 2*19" LCD
Server/Media Zotac GeForce 9300-ITX I-E - E5200 - 4gb Ram - 2* ecogreen F2 1.5tb - 1* wd green 500gb - PicoPSU 150xt - rtorrent - xbmc - ipazzport remote - 42" LCD
Offline
$ curl -s http://www2.radioparadise.com/nowplay_3.php | html2text | sed -n '2p'
Handy little one-liner for getting the currently playing song from my favourite radio station, Radio Paradise.
- Put this in a script
- Define a hotkey to start it
- When you hear a song you like, press the key
→ the currently playing song is added to a text file of music that you definitely need to buy.
Offline
Small script to view an image without downloading it
#!/bin/bash
IMG=$1
CURL=`which curl`
VIEWER=`which display`
if [ -z $IMG ]; then
printf "You need to specify an image to download\n"
exit 1;
else
$CURL $IMG | $VIEWER -
fi
RTFM or GTFO
hax0r.se
Offline
...
stuff
...... code ...
How did you set up your rtorrent to do this? I've been wondering about this a while now but never really took the time to investigate.
RTFM or GTFO
hax0r.se
Offline
$ curl -s http://www2.radioparadise.com/nowplay_3.php | html2text | sed -n '2p'
Handy little one-liner for getting the currently playing song from my favourite radio station, Radio Paradise.
Cool! I wrote a quicky version for my favorite radio station, Soma.fm's Groove Salad:
curl -s http://somafm.com/groovesalad |html2text |grep "(Now)" |colrm 1 16
Offline
Cool! I wrote a quicky version for my favorite radio station, Soma.fm's Groove Salad:
curl -s http://somafm.com/groovesalad |html2text |grep "(Now)" |colrm 1 16
Huh, last night I fount out that the output's all garbled. When I just redirect the output into a textfile, there are weird ^H characters in it... Will look into that.
Offline
markp1989 wrote:...
stuff
...How did you set up your rtorrent to do this? I've been wondering about this a while now but never really took the time to investigate.
I'm also curious about this as it may be an alternative to rtorrent's watch/set directories, although they seem to work fine. Also, rtorrent has: on_finished = notify,"execute=SOMENOTIFIER,$d.get_base_filename=,finished" could work for (email/etc) notification. Is this how you execute the script, though?
Last edited by milomouse (2010-02-03 17:42:10)
Offline
dunz0r wrote:markp1989 wrote:...
stuff
...How did you set up your rtorrent to do this? I've been wondering about this a while now but never really took the time to investigate.
I'm also curious about this as it may be an alternative to rtorrent's watch/set directories, although they seem to work fine. Also, rtorrent has: on_finished = notify,"execute=SOMENOTIFIER,$d.get_base_filename=,finished" could work for (email/etc) notification. Is this how you execute the script, though?
i have this line in my rtorrent.rc (i dont know if this works with the most recent version of rtorrent )
on_finished = notify_me,"execute=/home/mark/rtorrentmove.sh,$d.get_name="
Desktop: E8400@4ghz - DFI Lanparty JR P45-T2RS - 4gb ddr2 800 - 30gb OCZ Vertex - Geforce 8800 GTS - 2*19" LCD
Server/Media Zotac GeForce 9300-ITX I-E - E5200 - 4gb Ram - 2* ecogreen F2 1.5tb - 1* wd green 500gb - PicoPSU 150xt - rtorrent - xbmc - ipazzport remote - 42" LCD
Offline
Small script to view an image without downloading it
#!/bin/bash IMG=$1 CURL=`which curl` VIEWER=`which display` if [ -z $IMG ]; then printf "You need to specify an image to download\n" exit 1; else $CURL $IMG | $VIEWER - fi
Why do you need to specify an image to download when the script can view images without downloading?
Offline
The way you use $CURL and $VIEWER in that script are 100% redundant
[git] | [AURpkgs] | [arch-games]
Offline
dunz0r wrote:Small script to view an image without downloading it
#!/bin/bash IMG=$1 CURL=`which curl` VIEWER=`which display` if [ -z $IMG ]; then printf "You need to specify an image to download\n" exit 1; else $CURL $IMG | $VIEWER - fi
Why do you need to specify an image to download when the script can view images without downloading?
that should probably be "download and view an image without saving it". i imagine $1 has to be a url to an image.
//github/
Offline
scj wrote:dunz0r wrote:Small script to view an image without downloading it
#!/bin/bash IMG=$1 CURL=`which curl` VIEWER=`which display` if [ -z $IMG ]; then printf "You need to specify an image to download\n" exit 1; else $CURL $IMG | $VIEWER - fi
Why do you need to specify an image to download when the script can view images without downloading?
that should probably be "download and view an image without saving it". i imagine $1 has to be a url to an image.
brisbin33 got it right. Bad description, sry
RTFM or GTFO
hax0r.se
Offline
milomouse wrote:dunz0r wrote:How did you set up your rtorrent to do this? I've been wondering about this a while now but never really took the time to investigate.
I'm also curious about this as it may be an alternative to rtorrent's watch/set directories, although they seem to work fine. Also, rtorrent has: on_finished = notify,"execute=SOMENOTIFIER,$d.get_base_filename=,finished" could work for (email/etc) notification. Is this how you execute the script, though?
i have this line in my rtorrent.rc (i dont know if this works with the most recent version of rtorrent )
on_finished = notify_me,"execute=/home/mark/rtorrentmove.sh,$d.get_name="
Does this set the 'new' directory for rtorrent as well? So it won't stop seeding just because it gets moved?
RTFM or GTFO
hax0r.se
Offline
markp1989 wrote:milomouse wrote:I'm also curious about this as it may be an alternative to rtorrent's watch/set directories, although they seem to work fine. Also, rtorrent has: on_finished = notify,"execute=SOMENOTIFIER,$d.get_base_filename=,finished" could work for (email/etc) notification. Is this how you execute the script, though?
i have this line in my rtorrent.rc (i dont know if this works with the most recent version of rtorrent )
on_finished = notify_me,"execute=/home/mark/rtorrentmove.sh,$d.get_name="
Does this set the 'new' directory for rtorrent as well? So it won't stop seeding just because it gets moved?
i dont think it sets the new direcory, but my torrents still seed after they have been moved.
il look in to having it set the new folder, if i cannot set it i will have the script make a link from where the original folder was to the new location,
Last edited by markp1989 (2010-02-03 19:46:13)
Desktop: E8400@4ghz - DFI Lanparty JR P45-T2RS - 4gb ddr2 800 - 30gb OCZ Vertex - Geforce 8800 GTS - 2*19" LCD
Server/Media Zotac GeForce 9300-ITX I-E - E5200 - 4gb Ram - 2* ecogreen F2 1.5tb - 1* wd green 500gb - PicoPSU 150xt - rtorrent - xbmc - ipazzport remote - 42" LCD
Offline
Offline
Something I put together not thirty seconds ago. I couldn't find any good cw suites, so I decided to throw together a Morse -> kdb led programme in python. It needs sudo/root priv. and python. Now that it's finished, I've realised how much harder it is to visually interpret Morse code - as opposed to listening to it. I might add that this is in no way limited to Morse code output, but I just cant think of anything else yet... Feel free to point out the bugs/bad style, though there shouldn't be any of either
#!/usr/bin/env python
from os import system
from sys import argv
from time import sleep
def setl(i,s,t):
a='-'
if s: a='+'
system("sudo setleds %s%s < /dev/tty%s" %(a,i,t))
# Arguments: ttyID (usually 0), led name (eg: scroll),
# dit length (s), dah length (s), gap length (s), space length (s)
# input as [.|-|/| ]
#Example:
#./led.py 0 scroll 0.2 0.4 0.25 0.6 '.... . .-.. .-.. ---/- --- -- ..--.'
ltr,cs,tty,id,dit,dah,gap,spc=True,0,argv[1],argv[2],float(argv[3]),float(argv[4]),float(argv[5]),float(argv[6])
setl(id,False,tty)
for k in argv[7]:
if k==' ': cs,ltr=gap,False
elif k=='/': cs,ltr=spc,False
elif k=='-': cs,ltr=dah,True
elif k=='.': cs,ltr=dit,True
if ltr: setl(id,True,tty)
sleep(cs)
if ltr:
setl(id,False,tty)
sleep(gap)
Offline
I use this when encoding videos for use on my ipod: because my server has a better cpu then my laptop i use scp to copy the file over to the server, use ffmpeg to convert the file (for some reason it still only uses 1 core, any one knows how to get it to use both cores i will appriciate it) then uses scp to copy it back, its simple , but makes my life alot easier
im sure a similar principle can be used for other cpu intensive tasks aswell
#Use remote cpu to encode a video
##chose what folder to use for tempory files on the host.
encodedir=/media/encode
#copy original file to the server for encoding
echo "copying file to server for encoding"
scp -r "$1" "mark@192.168.1.99:$encodedir"
#encoding the video for use on my ipod
ssh 192.168.1.99 ffmpeg -y -i "$encodedir/$1" -s 320x180 -threads 2 -vcodec mpeg4 -ab 128k -acodec libfaac -ac 2 -ab 64k -f mp4 "$encodedir/$1-ipod.mp4"
#Copys the result from the host to the client
echo "copying results from the server"
scp -r "mark@192.168.1.99:$encodedir/$1-ipod.mp4" "$1-ipod.mp4"
Last edited by markp1989 (2010-02-04 19:30:39)
Desktop: E8400@4ghz - DFI Lanparty JR P45-T2RS - 4gb ddr2 800 - 30gb OCZ Vertex - Geforce 8800 GTS - 2*19" LCD
Server/Media Zotac GeForce 9300-ITX I-E - E5200 - 4gb Ram - 2* ecogreen F2 1.5tb - 1* wd green 500gb - PicoPSU 150xt - rtorrent - xbmc - ipazzport remote - 42" LCD
Offline
Couldn't you avoid the intermediate file shuffling and use a pipe instead?
Something like
cat $1 | ssh server ffmpeg -i - $rest_of_flags - > $1-ipod.mp4
Offline
Function to make pacman ask for root privileges when required:
pacman() {
if [[ "$1" =~ ^-S[cuy]|^-S$|^-R|^-U ]]
then
sudo pacman-color $@
else
pacman-color $@
fi
}
NOTE:
Regex may need some work. It works for my common usage patterns though it could be missing a few options.
Might be an easier way to do this.
EDIT: Fixed regex. Made a couple of stupid mistakes.
Last edited by mikesd (2010-02-11 11:28:50)
Offline
^ Nice idea.
This one breaks less because it doesn't have to be the first operand, nor do the S,R,U operators need to be the first on the -xyz string:
shopt -s extglob
pacman() {
if [[ "$*" == *-@(*([^ilps ])S*([^ilps ])|*@(R|U)*)\ * ]]; then
sudo pacman "$@"
else
pacman "$@"
fi
}
e: hmm, might be even better to do this with compgen and comp_command..
Last edited by res (2010-02-07 05:16:34)
Offline
I'd use =~ and a regex rather than that fugly ==.
if [[ "$*" =~ -\w*[SRU] ]]; then
Not sure if it takes \w but if not you can always use a class.
[git] | [AURpkgs] | [arch-games]
Offline
Doesn't match the right pattern, nor does it take benign S options in account...
[[ '--S' =~ -\w*S ]]; echo $?
0
Thankfully, pacman just errs out... but running random commands with sudo is still running random commands with sudo.
Offline
This is my ABSGET w/ AUR support and integrated update query and package search:
absget() {
if ! (( $2 )); then
# Since I use this func at most once in a week, I want to be asked
read -en 1 -p "Synchronize ABS? [Yn]"
[[ $(tr '[[:lower:]]' '[[:upper:]]' <<<$REPLY) = "N" ]] || sudo abs
fi
item=$1
dest=$HOME/abs
OLDIFS="$IFS"
if [[ $item == /var/abs/* ]]; then
# copy the package from abs
cp -r $item $dest
echo "Package ${item##*/} has been copied to \"$dest\"."
else
# otherwise, display any matching package in /var/abs
arr=($(find /var/abs -type d -wholename "*$item*"))
if (( ${#arr[@]} == 1 )); then
# if it's only one, grab it right away
echo "found $item in ${arr[0]}"
absget ${arr[0]} 1
elif (( ${#arr[@]} == 0 )); then
# no package found here, look in AUR
entries=$(yaourt -Ss $item)
IFS=$'\n'
arr=($(\grep aur/ <<<"$entries"))
if (( "${#arr[@]}" == 0 )); then
echo "$item not found on AUR" >&2
elif (( "${#arr[@]}" == 1 )); then
# single entries can be downloaded from AUR
mkdir $dest/$item
( cd $dest/$item; yaourt -G $item; )
else
# multiple entries are listed
yaourt -Ss $item
fi
else
# display a list of packages
IFS=$'\n'
echo "${arr[*]}"
fi
fi
IFS="$OLDIFS"
}
Last edited by mar77i (2010-02-09 04:22:54)
<rickh> f(Arch) = ((Gentoo - Compiletime) + (Slackware + Depency resolution and Downloading))
Offline
Addiction to South Park
#!/bin/bash
# Play a random Sp episode.
cd '/media/disk/SOUTH PARK/';
smplayer "$( ls ./ | grep .avi | shuf -n1 )"
exit 0 # Respect my goddamn authoritah
Offline