Wednesday, February 27, 2008

Cross domain Ajax call

The JSONP approach is necessitated, as I mentioned by the browsers' SOP (Same-origin policy) which prohibits XMLHttpRequests from crossing domains.

There are three ways to make cross domain calls
1. Using Local Proxy : We send the request to another service side page(like php,jsp etc) that makes a request from the server to the web service. But this ultimately result in double bandwidth and latency
2. Flash : NEED Flash
3. Script tag (JSON with Padding. JSONP approach) injection: I am only left with this approach of creating script tag dynamically and setting src attribute to a web service API call. It can be considered as security risk.

Yahoo Using same approach
Article: http://developer.yahoo.com/common/json.html#callbackparam
Example request: http://api.local.yahoo.com/MapsService/V1/geocode?appid=dantheurer&location=la&output=json&callback=getLocation

Delicious is also using JSONP approach
http://feeds.delicious.com/feeds/json/bob/javascript+hack?jsonp=delicious_callbacks%5B12345%5D

Google also uses same approach. I read it in this thread.
http://groups.google.com/group/Google-Maps-API/browse_thread/thread/1e1cecf679dd7c5a
So, google api also uses JSONP(i.e the same script tag hack) approach

Thursday, February 21, 2008

Genuine Windows Validation Test

Have you ever thought how Microsoft perform test to find weather copy is genuine or not......

good guess!!!!! one and only LOGIC registry :)

Hardest LOGIC they can ever think

they find the Product key from registry and compare with "V2C47-MK7JD-3R89F-D2KXW-VPK3J" if matches
validation fails

then they fixed it:(

BUT by adding another key "FCKGW-RHQQ2-YXRKT-8TG6W-2B7Q8"

then "Q6TD9-9FMQ3-FRVF4-VPF7Y-38JV3"

Finely they come up with solution :(


by keeping and updating database of pirated keys :) LOL

so if you know any single product key which is not in their database you can make your copy original

More info

Handle Active Tab and Screen Capture in IE6 & IE7

SHDocVw.ShellWindows shellWindows = new SHDocVw.ShellWindowsClass();

IntPtr activeWindowHandle;
mshtml.IHTMLDocument2 myDoc;
mshtml.IHTMLDocument3 myDoc1;
activeWindowHandle = GetForegroundWindow();
IntPtr myIntptr = activeWindowHandle;
int hwndInt = myIntptr.ToInt32();
IntPtr hwnd = myIntptr;
IntPtr hwnd1 = IntPtr.Zero;
hwnd = GetWindow(hwnd, GW_CHILD);
StringBuilder sbc = new StringBuilder(256);
IEnumerator windows = new SHDocVw.ShellWindowsClass().GetEnumerator();
while (windows.MoveNext())
{
if ((windows.Current is SHDocVw.IWebBrowser2) && ((windows.Current as SHDocVw.IWebBrowser2).HWND.ToString() == activeWindowHandle.ToString()))
{
((windows.Current as SHDocVw.IWebBrowser2).Document as IOleWindow).GetWindow(out hwnd);

if (IsWindowVisible(hwnd))
{
break;
}
}
}
myDoc = ((windows.Current as SHDocVw.IWebBrowser2).Document as mshtml.IHTMLDocument2);
myDoc1 = ((windows.Current as SHDocVw.IWebBrowser2).Document as mshtml.IHTMLDocument3);

Find Actice TAB in IE7

if (sbc.ToString().IndexOf("TabWindowClass", 0) > -1)
{
StringBuilder childsb = new StringBuilder(100);
IntPtr hChildWnd = GetWindow(hwnd, GW_CHILD);
while (IntPtr.Zero != hChildWnd)
{
GetClassName(hChildWnd.ToInt32(), childsb, 100);

if (childsb.ToString().Contains("Shell DocObject View"))
{
IntPtr visWin = FindWindowEx(hChildWnd, IntPtr.Zero, "Internet Explorer_Server", IntPtr.Zero);
if (IsWindowVisible(visWin))
{
hwnd = visWin;
break ;
}

}
hChildWnd = GetWindow(hChildWnd, GW_HWNDNEXT);
}

Get inner browser window in IE6 and IE7

int hwndInt = myIntptr.ToInt32();
IntPtr hwnd = myIntptr;
while (hwndInt != 0)
{
hwndInt = hwnd.ToInt32();
GetClassName(hwndInt, sbc, 256);

if (sbc.ToString().IndexOf("TabWindowClass", 0) > -1)
{
hwnd = FindWindowEx(hwnd, IntPtr.Zero, "Shell DocObject View", IntPtr.Zero);
hwnd = FindWindowEx(hwnd, IntPtr.Zero, "Internet Explorer_Server", IntPtr.Zero);
break;
}

else if (sbc.ToString().IndexOf("Shell DocObject View", 0) > -1)
{
hwnd = FindWindowEx(hwnd, IntPtr.Zero, "Internet Explorer_Server", IntPtr.Zero);
break;
}
hwnd = GetWindow(hwnd, GW_HWNDNEXT);
}

Wednesday, February 20, 2008

AMR to mp3

Here is a code that you can use to convert AMR file to various other files:

Pre-requisites

Emerge sox, Vorbis-tools and lame. Build the the 3GPP reference converter files (compiled with these changes: make file without -DETSI and add #include "sp_dec.h" to decoder.c).

Convert AMR to OGG Vorbis

File: /usr/local/bin/amrtoogg

#!/bin/bash
 
# By Aquarion - Aquarion@Aquarionics.com
# Do what you want with it, it's not rocket science.
 
##Change these:
#Wherever you put encode and decode when you compiled them:
CODEC=/usr/local/bin
 
#Temporary directory. Chances are you've already got this set
TEMP=/tmp
 
#Where do the final MP3s go?
FINAL=/home/user/media/siemens/ogg
 
for file in *.amr; do 
        FILE=`echo $file | sed -e "s/.amr//"`; 
        echo -n "$FILE [AMR] -> [RAW]"
        $CODEC/decoder $file $TEMP/$FILE.raw > log.std 2> log.err; 
        echo -n " -> [WAV] "
        sox -r 8000 -w -c 1 -s $TEMP/$FILE.raw -r 44100 \
               -w -c 1 $TEMP/$FILE.wav > log.std 2> log.err; 
        echo -n " -> [OGG] "
        oggenc $TEMP/$FILE.wav -q 5 -o $FINAL/$FILE.ogg --quiet \
               -t "$FILE" -a "Sanda" -l "Anul nou" -d `date +%Y`
        echo  " :-) "
        rm $TEMP/$FILE.wav;
        rm $TEMP/$FILE.raw;
done

Convert AMR to MP3

File: /usr/local/bin/amrtomp3

#!/bin/bash
 
# By Aquarion - Aquarion@Aquarionics.com
# Do what you want with it, it's not rocket science.
 
##Change these:
#Wherever you put encode and decode when you compiled them:
CODEC=/usr/local/bin
 
#Temporary directory. Chances are you've already got this set
TEMP=/tmp
 
#Where do the final MP3s go?
FINAL=/home/user/media/siemens/mp3
 
for file in *.amr; do 
        FILE=`echo $file | sed -e "s/.amr//"`; 
        echo -n "$FILE [AMR] -> [RAW]"
        $CODEC/decoder $file $TEMP/$FILE.raw > log.std 2> log.err; 
        echo -n " -> [WAV] "
        sox -r 8000 -w -c 1 -s $TEMP/$FILE.raw -r 44100 \
               -w -c 1 $TEMP/$FILE.wav > log.std 2> log.err; 
        echo -n " -> [MP3] "
        lame $TEMP/$FILE.wav $FINAL/$FILE.mp3 --preset standard --silent \
               --tt $FILE --ta Sanda --tl Anul\ Nou --ty `date +%Y`
        echo  " :-) "
        rm $TEMP/$FILE.wav;
        rm $TEMP/$FILE.raw;
done

Tuesday, February 19, 2008

Microsoft DreamSpark - Get free microsoft softwares

"DreamSpark is simple, it's all about giving students Microsoft professional-level developer and design tools at no charge so you can chase your dreams and create the next big breakthrough in technology - or just get a head start on your career. "

But it doesn't work for India at all. Only China is listed in Asia.

Microsoft DreamSpark