You are not logged in.
Ooh, thanks, I was using your kimag.es script before, thanks for an update. I'm curious how to get it to show the progress of the upload, as it was before, if possible? Thanks!!
Offline
Ooh, thanks, I was using your kimag.es script before, thanks for an update. I'm curious how to get it to show the progress of the upload, as it was before, if possible? Thanks!!
To be honest, I don't know. I'm using the same switch (-#) in this one as the other one, so I'm stumped. You may want to try Zeist's one-lined script, but I haven't used it and don't know if it will show the progress.
curl -# -F userfile1=@$1 http://kimag.es/upload.php?action=upload && curl -# http://kimag.es/allimg.php | grep http://arch.kimag.es/share|cut -d '"' -f8
[ lamy + pilot ] [ arch64 | wmii ] [ ati + amd ]
Offline
Ooh, that worked perfectly! Thanks!! What an incredbily useful little function
Offline
I'm well aware that this following bit can be greatly refined, and I will at some point, but this will display a nicer list of upgrade targets (pacman -Qu), until pacman 3.3 comes out.
LC_ALL=C pacman -Qu |sed -n '/Targets/,/Total Download/p;' | sed 's/Targets ([[:digit:]]\+)://;$d' | sed 's/[[:space:]]\+/\n/g'| grep .|sort| perl -ne 'chomp; @toks = split /-/, $_; $pkgrel = pop @toks; $pkgver = pop @toks; $pkgname = join "-", @toks; print "$pkgname $pkgver-$pkgrel\n"'
[git] | [AURpkgs] | [arch-games]
Offline
^^^ Where do I put that line?
Offline
@colbert that can just be run on the command line.
...
So, it ain't pretty but it gets the job done. piratesearch will search/download certain small files from a certain small file sharing site; combine it with an rtorrent watch directory and you've got yourself an auto-magic torrent solution.
disclaimer: i do not condone nor promote copyright infringement
//github/
Offline
what?! Look at your avatar.
Don't be afraid of the man, man.
Offline
brisbin33, EXCELLENT SCRIPT.
I'm going to start using it really soon. To download linux isos, of course .
Offline
Wow, that's an amazing script indeed brisbin33!!
Offline
here's my simple commandline stopwatch program. It's got standard start/stop, reset, and lap functions
#!/usr/bin/python
#pystop stopwatch program
import time, sys, termios, fcntl, os
def printtime(starttime):
currtime = time.time()
milli = ((currtime - starttime) - int(currtime - starttime))* 100
sec = int(currtime - starttime) % 60
minutes = int(currtime - starttime) / 60
hours = int(currtime - starttime) / 3600
timing = str("%02d:%02d:%02d:%02d\r" % (hours, minutes, sec, milli))
return timing
if __name__ == "__main__":
fd = sys.stdin.fileno()
oldterm = termios.tcgetattr(fd)
newattr = termios.tcgetattr(fd)
newattr[3] = newattr[3] & ~termios.ICANON & ~termios.ECHO
termios.tcsetattr(fd, termios.TCSANOW, newattr)
oldflags = fcntl.fcntl(fd, fcntl.F_GETFL)
fcntl.fcntl(fd, fcntl.F_SETFL, oldflags | os.O_NONBLOCK)
print "-----------------------------------------------"
print "Stopwatch: (S)tart/Stop, (R)eset, (L)ap, (Q)uit"
print "-----------------------------------------------"
started = 0
initialized = 0
try:
while 1:
try:
test = sys.stdin.read(1)
if test == 'q':
print "\n" ,
break
elif test == 's':
if started:
started = 0
stoptime = time.time() - starttime
else:
if not initialized:
starttime = time.time()
initialized = 1
else:
starttime = time.time() - stoptime
started = 1
elif test == 'r':
if started:
starttime = time.time()
else:
timing = printtime(time.time())
print " Time:\t", timing, "\r" ,
initialized = 0
elif test == 'l':
print " Lap: \t", timing, "\r" ,
print
except IOError:
if started:
timing = printtime(starttime)
print " Time:\t", timing, "\r" ,
time.sleep(.01)
pass
finally:
termios.tcsetattr(fd, termios.TCSAFLUSH, oldterm)
fcntl.fcntl(fd, fcntl.F_SETFL, oldflags)
Offline
@Varreon and colbert
thanks for the encouragement... i threw it together yesterday afternoon when i went to get Revolution OS and found TPB has a nice consistent url format; some things i hope to improve on soon:
use something other than lynx --dump to hopefully speed it up
add options to search --audio, --video, etc EDIT: option support added, check --help
dunno when i'll get to it, but that link will always point to the most up to date version. thanks for enjoying it!
Last edited by brisbin33 (2009-05-01 15:48:42)
//github/
Offline
I was never happy with existing note taking apps because they store the contents in binary or xml format which makes reading them from the commandline difficult, as well as exporting them . So now I keep all my linux related notes as simple text (.txt) files organized in folders. I use this script to create a two-pane html page with a tree on the left. That way I can quickly browse through my notes on both firefox, and on the commandline if necessary. It's very basic but it works for me.
create_html_index.php :
<?php
function createPathArray($baseDir='',$regExInclude) {
if (!$baseDir or !is_dir($baseDir)) die ("missing arguments");
$arrPaths1 = opendir($baseDir);
$arrPaths2=array();
while ($file = readdir($arrPaths1)) {
if ($file <> ".." and $file <> "."){
if(is_dir($baseDir.'/'.$file)){
$arrPaths2[$baseDir.'/'.$file ] = createPathArray($baseDir.'/'.$file,$regExInclude);
}else{
if(isset($regExInclude)){
if(preg_match($regExInclude,$file))$arrPaths2[$baseDir."/".$file] = $file;
}
else $arrPaths2[$baseDir."/".$file] = $file;
}
}
}
closedir($arrPaths1);
if(sizeof($arrPaths2)>0){
ksort($arrPaths2);
return $arrPaths2;
}
}
function arrPathsToHtml($arrPaths){
if(!is_array($arrPaths))return;
$html ="<ul>\n";
foreach($arrPaths as $key=>$value){
if(is_array($value)){
preg_match("/[^\/]+(\.)*$/",$key,$matches);
$html .= "<li>".$matches[0]."</li>\n";
$html .= arrPathsToHtml($value);
}else{
preg_match("/([^.]+)/",$value,$matches);
$title = preg_replace("/_/"," ",$matches[0]);
$html .= "<li><a href=\"file://".$key."\">- ".$title."</a></li>\n";
}
}
$html.="</ul>\n";
return $html;
}
function writeToFile($strPath,$strContent,$mode="wb"){
if (!$handle = fopen($strPath, $mode)) {
echo "Cannot open file ($filename)";
return;
}
if (fwrite($handle, $strContent) === FALSE) {
echo "Cannot write to file ($strPath)";
}
fclose($handle);
}
$baseDir = $argv[1];
if (substr( $baseDir, -1 ) == '/') $baseDir = substr( $baseDir, 0, -1 );
$arr = createPathArray($baseDir,"/\.txt$/");
$HtmlList = arrPathsToHtml($arr);
$Html='<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head><title>Index</title>
<style type="text/css">
body{background:#f0f0f0;width:300px}
body,a{font-size:12px}
a{text-decoration:none;color:rgb(100,100,100)}
a:hover{color:orange}
li{list-style-type:none;position:relative;left:-40px}
</style>
<base target="contentframe"/>
</head>
<body>'.$HtmlList.'</body></html>';
writeToFile($baseDir."/textfile_index.htm",$Html);
$command = "cp \"".dirname(__FILE__)."/textfile_index_frameset.htm\" \"$baseDir\"" ;
exec($command);
?>
textfile_index_frameset.htm :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<html>
<frameset cols = "350px,*">
<frame frameborder="0" name="menuframe" src ="textfile_index.htm" />
<frame frameborder="0" name="contentframe" src ="" />
</frameset>
</html>
Last edited by rwd (2009-05-01 18:36:15)
Offline
very short script that uses googles define:word feature, to search for definitions of words
#!/bin/bash
echo Definitions of $1 on the Web:
curl -s -A 'Mozilla/4.0' 'http://www.google.co.uk/search?q=define%3A+'$1 | html2text -ascii -nobs -style compact -width 80 | grep "*"
example
[mark@markspc ~]$ ./dictionary.sh testing
Definitions of testing on the Web:
* the act of subjecting to experimental test in order to determine how well
* an examination of the characteristics of something; "there are
* examination: the act of giving students or candidates a test (as by
* This is a list of episodes of the Dilbert animated series in the order
* Debian ( ) is a computer operating system composed entirely of free and
* Optical fabrication and testing spans an enormous range of manufacturing
* test - put to the test, as for its quality, or give experimental use to;
* screen: test or examine for the presence of disease or infection; "screen
* test - trial: trying something to find out about it; "a sample for ten
* test - quiz: examine someone's knowledge of something; "The teacher tests
* test - any standardized procedure for measuring sensitivity or memory or
* test - show a certain characteristic when tested; "He tested positive for
* test - examination: a set of questions or exercises evaluating skill or
* test - achieve a certain score or rating on a test; "She tested high on
* test - the act of undergoing testing; "he survived the great test of
[mark@markspc ~]$ ./dictionary.sh arch+linux
Definitions of arch+linux on the Web:
* Arch Linux (or Arch) is an independently developed operating system intended to be lightweight and simple. ...
* is a Distribution Linux created by Judd Vinet which stresses simplicity. Judd was inspired by another Linux distribution called Crux Linux.
[mark@markspc ~]$
Last edited by markp1989 (2009-05-05 13:56:37)
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
I use this script for easy posting to the screenshot thread. I have it set up to save to the folder I use for screenshots, but you can modify the script to save wherever you want. It will take a screenshot, create a 40% thumbnail, upload both to kimag.es, and spit out the proper code for embedding. I'm sure it could be improved, but it's good enough for me.
scrot -cd 3 ~/pictures/screenshots/temp.png
curl -F userfile1=@~/pictures/screenshots/temp.png -D kimagtemp http://kimag.es/upload.php
echo -n "[url=http://kimag.es/share/"
cat kimagtemp|grep /view.php?i=|cut -c23-34|tr -d '[ \n]'
echo -n "]"
rm kimagtemp
mogrify -resize 40% ~/pictures/screenshots/temp.png
curl -F userfile1=@~/pictures/screenshots/temp.png -D kimagtemp http://kimag.es/upload.php
echo -n "[img]http://kimag.es/share/"
cat kimagtemp|grep /view.php?i=|cut -c23-34|tr -d '[ \n]'
echo "[/img][/url]"
rm kimagtemp
rm ~/pictures/screenshots/temp.png
[ lamy + pilot ] [ arch64 | wmii ] [ ati + amd ]
Offline
^^ That is the bomb, I really want to use it but I get this trying it:
┌─[ 19:26 ][ ~ ]
└─> kup
Taking shot in 3.. 2.. 1.. 0.
curl: (26) failed creating formpost data
[url=http://kimag.es/share/cat: kimagtemp: No such file or directory
]rm: cannot remove `kimagtemp': No such file or directory
curl: (26) failed creating formpost data
[img]http://kimag.es/share/cat: kimagtemp: No such file or directory[/img][/url]
rm: cannot remove `kimagtemp': No such file or directory
┌─[ 19:26 ][ ~ ]
Offline
^^ That is the bomb, I really want to use it but I get this trying it:
┌─[ 19:26 ][ ~ ] └─> kup Taking shot in 3.. 2.. 1.. 0. curl: (26) failed creating formpost data [url=http://kimag.es/share/cat: kimagtemp: No such file or directory ]rm: cannot remove `kimagtemp': No such file or directory curl: (26) failed creating formpost data [url]http://kimag.es/share/cat: kimagtemp: No such file or directory[/url][/url] rm: cannot remove `kimagtemp': No such file or directory ┌─[ 19:26 ][ ~ ]
haha i get that too
Offline
lyrics.py
It prints the lyrics of the song playing in xmms. Requires python, python-xmms-remote (it's in the AUR) and xmms, of course.
#!/usr/bin/env python
import xmms.control as xmms
import urllib2
import re, os
def get_lyrics(POS):
trackname = xmms.get_playlist_title(POS) # Get track name
trackname = re.sub("\(.*|\ $", "", trackname) # Remove the brackets, if any
artist = trackname.split(" - ")[0] # Artist
title = trackname.split(" - ")[1] # Title
# Create the URL, Open the page
url = "http://www.lyricsplugin.com/winamp03/plugin/?artist=%s&title=%s" % (
artist.replace(" ", "%20"), # replace empty spaces with "%20"
title.replace(" ", "%20") ) # the same
page = urllib2.urlopen(url, timeout=10).read()
# Do some editing
lyrics = re.split('<div id="lyrics">|</div>', page)[3]
lyrics = lyrics.replace("<br />", "")
lyrics = trackname + "\n" + lyrics
# Save the lyrics temporarily
file = open("/tmp/xmms_lyrics.temp", "w")
file.write(lyrics)
file.close()
# And finally, show them
os.system("less /tmp/xmms_lyrics.temp")
get_lyrics( xmms.get_playlist_pos() ) # pass the current song position
RichMood.py
Skype Rich Mood Text Editor. Change the font size, the color, make text bold, italic, etc... Requires python, Skype4Py (in the AUR again).
#!/usr/bin/env python
from Tkinter import *
import Skype4Py
class Skype:
def __init__(self, root):
self.root = root
self.root.title('Skype Rich Mood Text Editor')
self.root.resizable(0,0)
self.skype = Skype4Py.Skype()
self.skype.Attach()
Label(self.root, padx=5, text='You can use the <a>, <b>, <u>, <i>, <blink> and <font> tags.').pack()
self.text = Text(self.root, width=60, height=5, padx=1, pady=1, font=('Tahoma',10))
self.text.pack()
self.InsertCurrentMood('some event')
# current_mood = self.skype.CurrentUserProfile._GetRichMoodText()
# self.text.insert(1.0, current_mood)
button = Button(self.root, text='Submit', width=19, height=1)
button.pack(side=LEFT)
button.bind('<Button-1>', self.SetMood)
button2 = Button(self.root, text='Reset to current mood', width=19, height=1)
button2.pack(side=RIGHT)
button2.bind('<Button-1>', self.InsertCurrentMood)
button3 = Button(self.root, text='Exit', width=19, height=1)
button3.pack(side=RIGHT)
button3.bind('<Button-1>', self.Quit)
def Quit(self, event):
self.root.destroy()
def InsertCurrentMood(self, event):
current_mood = self.skype.CurrentUserProfile._GetRichMoodText()
self.text.delete(1.0, END)
self.text.insert(1.0, current_mood)
def SetMood(self, event):
value = self.text.get(1.0,END)[:-1]
self.skype.CurrentUserProfile._SetRichMoodText(value)
root = Tk()
app = Skype(root)
root.mainloop()
It has quite an ugly GUI, but that's because I made it for Vista and there it looks fine. (FYI, in XP it's even more ugly )
Last edited by Boris Bolgradov (2009-05-05 08:09:02)
Offline
@colbert and Boris
replace the curl command with this:
curl -F userfile1=@"$HOME/pictures/screenshots/temp.png" -D kimagtemp http://kimag.es/upload.php
@just colbert
i recognize that PS1! ;P
//github/
Offline
Ah, right it was missing the @HOME, I will try it when I, well.. get home
@ brisbin33 Oh yeah, lol I grabbed some of your configs a while ago, really excellent!
Last edited by colbert (2009-05-05 18:09:09)
Offline
Ah, right it was missing the @HOME...
i think the missing double quotes were what actually made the difference (i just prefer $HOME/ over ~/ when in scripts)
//github/
Offline
Hmm. Well, the version I use has the full paths specified, so maybe that's why I didn't notice that.
[ lamy + pilot ] [ arch64 | wmii ] [ ati + amd ]
Offline
useless but nice script to have a randomly picked picture from a list and link it to the desktop so that nautilus can preview it. running it under cron for a random pic every 7 minutes.
someone in the forums helped mi with sed, cant remember who;
#!/bin/bash
# Symbolic link path
LINK="/home/$USER/Desktop/link"
NEW_PHOTO=""
CANT_FOTOS=`wc -l ~/.photoswitchrc | awk '{print $1'}`
LINE_NUMBER=$[ ( $RANDOM%${CANT_FOTOS} ) + 1]
NEW_PHOTO=`cat -n /home/$USER/.photoswitchrc | grep " ${LINE_NUMBER} " | sed -n "s/[^']*'\([^']*\)'[^']*/\1/gp"`
#debugging crap:
echo $NEW_PHOTO
echo $CANT_FOTOS
echo $LINE_NUMBER
# The action is done here
ln -sf "$NEW_PHOTO" "$LINK"
Offline
@rwd
seems good to me,
by the way...how to run it? <-- this is a stupid question ==
do i need pacman -S php package first?
This silver ladybug at line 28...
Offline
@markp1989
html2text....that is...wow! never heard of it, nice one!
curl -s http://www.whatsthetime.net/result.php | sed '/<h3>/!d;s/<[^>]*>//g'
I had been expecting to get the time...then i got some fortune!
wwooo...while this one is fine to get the time as well as weather
#$1 be the name of city/country etc, like us or beijing
curl -s http://whatisthetime.in/$1 | html2text | sed -e '/Current time/,+4b' -e '/Current Conditions/,+11b' -e d | sed '/^$/d' | sed '/Images/d' |sed 's/^ *//'
Last edited by lolilolicon (2009-05-07 19:47:11)
This silver ladybug at line 28...
Offline
@lolilolicon: Also fun to play with is "html2" from the "xml2" package in AUR.
It will give you data like this:
$ curl -s http://whatisthetime.in/Seoul | html2 2>/dev/null | less
(...)
/html/body/form/div/div/div/div/@class=TimeBlock2
/html/body/form/div/div/div/div/span/@class=LabelTime
/html/body/form/div/div/div/div/span=Current time in Seoul, Korea, South is
/html/body/form/div/div/div/div/span/br
/html/body/form/div/div/div/div/span/span/@class=Time
/html/body/form/div/div/div/div/span/span=4:11:11 AM
/html/body/form/div/div/div/div/span/br
/html/body/form/div/div/div/div/span/span/@class=TimeZone
/html/body/form/div/div/div/div/span/span=Korean Standard Time,<A0>KST
/html/body/form/div/div/div/div/span/br
/html/body/form/div/div/div/div/span/span/@class=Date
/html/body/form/div/div/div/div/span/span=Friday, May 08, 2009
(...)
Offline