Showing posts with label unix. Show all posts
Showing posts with label unix. Show all posts

Sunday, December 13, 2009

Mail Notification

One of the problems of using Unix based OS is that it becomes damn difficult to check office mails. Outlook still doesnt have an equivalent on Linux. Neither Thunderbird nor Evolution support Exchange 2007. I am left with using Outlook Webaccess that sucks. I have been living with this for almost a year now hoping that Thunderbird or Evolution will support Exchange 2007 sooner than later but to no avail.

So, this weekend I wrote this small Mail notifier that checks my Outlook & GMail account and pops up a notifier when there is a new mail. I find it extremely useful. Hope you find it too.

http://code.google.com/p/newmail-notify/

Thursday, December 6, 2007

Hey there Delilah

PG tells me about this song that she has been listening to lately, "Hey there Delilah". I ask my office folks if they have the song and a few others that I had been looking for since a past few days. Nobody seems to have these [Either I have an obscure taste or the office folks >:) ]. However, one of the more philanthropic types came to my seat to tell me about this site eSnips.com which she claimed has about every song that I might be interested in listening to. Soon enough I found that to be true, it really has a good collection of Hindi as well as English songs.

Happy with the discovery, I come back home and spend the next few hours in finding the songs I had been looking for since ages now. Make a playlist, all set to go... But... the playlist wont play... !!!! Googling around seemed futile after killing a lot of time.. I guessed that it was time to do some scripting :) Skip the dinner and now I have this script which downloads the songs in the playlist :) Thought it might be of some use to someone out there.

esnips-playlist-save
******************

#!/bin/sh
if [ $# -lt 3 ]
then
echo "Usage: $0 "
exit 1
fi

EMAIL="$1"
PASSWD="$2"
PLAYLIST="$3"

ESNIPS='http://www.esnips.com'
LOGIN_URL=$ESNIPS'/UserSignInAction.ns?action=signin'
PLAYLIST_ID=`echo $PLAYLIST | sed 's/.*\///g'`
PLAYLIST_URL=$ESNIPS'/plxml/'$PLAYLIST_ID


# Log in to the server.
rm -f cookies.txt
echo "Logging in to eSnips"
wget --keep-session-cookies --save-cookies cookies.txt \
--post-data "ns_EventTarget=&ns_EventArgument=&referrer=&rememberMe=off&email=$EMAIL&password=$PASSWD" \
--output-document 'junk.html' \
-q \
-p $LOGIN_URL

# Now grab the page or pages we care about.
echo "Loading the playlist"
wget --load-cookies cookies.txt \
--output-document 'playlist.xml' \
-q \
-p $PLAYLIST_URL

# Get the commands for downloading the files
mkdir -p downloads
xsltproc --nodtdattr esnips.xslt playlist.xml | grep -v "

cat esnips.xslt
**************

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/playlist/trackList">
<xsl:for-each select="track">
echo "Downloading <xsl:value-of select="title"/>";ext=`wget -O '<xsl:value-of select="title"/>' --load-cookies cookies.txt <xsl:value-of select="location"/> <xsl:text disable-output-escaping="yes"> 2>&1| grep audio | sed 's/.*audio\///;s/]//'`;mv '</xsl:text><xsl:value-of select="title"/>' downloads/'<xsl:value-of select="title"/>'.$ext
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>

I am impressed with myself... As I usually am..

Saturday, September 1, 2007

On watching movies

Yesternight I was trying to watch this movie when I realised that the subtitle is way out of sync. I tried to use VLC's Subtitles advanced setting but turns out that it is unable to sync it. I tried hunting for a few more subtitles track but after finding two of them I realised that both of them were identical, I am sure that there would be many souls out there who dont have easy net access or there are many movies with not many different subtitles track. Being a geek that I am, at 1:00 in the night I decided it is time to do something permanent :) and I came up with this script that syncs up the subtitles track for me. It takes 4 inputs, a time (T1) towards the start of the movie and the corresponding time (t1) in the subtitles file [If you didnt know, subtitles file can be edited (.srt)] when the same dialog is being played and two similiar times towards the end of the movie.

Run the script like this:
awk -f lipsync.awk Subtitles.srt > ModifiedSubtitles.srt

Play the movie with the new file.

The script: [Save it as lipsync.awk]
# --------------------------------------- Start of lipsync.awk
#
# Author: Fasihullah Askiri
#
# Movie: ----T1---------------------------------------T2---
# File: --t1---------------------------------t2--
#
# T1 - T2
# -------
# t1 - t2
#

BEGIN {
T1 = 745
t1 = 721

T2 = 7530
t2 = 7227

scale = (T1 - T2) / (t1 - t2)
delaySec = T2 - t2 * scale
# print "Scale: " scale
# print "DelaySec: " delaySec
}

{ processed = 0 }

function formatTime (timeInSecs)
{
hr = int (timeInSecs/3600)
min = int (timeInSecs/60) - hr * 60
sec = int (timeInSecs) - min * 60 - hr * 3600
msecs = int (1000 * (timeInSecs - int (timeInSecs)))
return hr ":" min ":" sec "," msecs
}

function getTimeInSecs (str)
{
split (str, time, ":")
split (time [3], timeLast, ",")
return time [1] * 3600 + time [2] * 60 + timeLast [1] + timeLast [2] / 1000
}

/ --> / {
newStartTime = formatTime(getTimeInSecs($1) * scale + delaySec)
newEndTime = formatTime(getTimeInSecs($3) * scale + delaySec)
print newStartTime, $2, newEndTime
processed = 1
}

!processed {
print $0
}

# --------------------------------------- End of lipsync.awk



I assume that you have a unix based system or a cygwin on your windoze or at least a running version of awk on windoze

Hope it helps

Monday, August 20, 2007

My love

The first computer I worked on was a VT100 terminal attached to a central server in the sacred server room which we could only look at from outside. We had a slot of not more than an hour to work on it. This was at my campus 7 years back. Computers really have changed a lot, and so have the interfaces and the softwares that we interact with. But a few things will never change at least for me. Top of the list I guess is Vi. I am a Vi fan. Three years of working in the industry and four years at the campus, I found Vi incredibly powerful and easy.

Some time back NB was talking about this cool dood friend of his who used to do everything imaginable in Emacs; right from writing, debugging source code to checking his mails. He said he had done a plugin which could rip out the attachment off a multi-part mail and save it to a directory which he could go look into. Emacs I believe has a lot of popularity and fan following so I thought I would give it a shot. For a month I "tried" religiously to use emacs for editing it is a good editor, but it does not beat Vi. It might be my love for Vi which hides the goodness of Emacs ;) but the fact remains that to do Emacs you really have to press a bit too many keys. One of my favourite "shortcuts" was "CTRL-x a i g" inverse-add-global-abrev [Ok Ok.... It is a pretty fancy feature... If you want to use it you have sacrifice a little bit... On the plus side you will get more flexible fingers >:)] Anyways, after a month I gave up... I am back to Vi now...