Posts Tagged: web


6
Mar 08

iPaper

iPaper: iPaper is a document viewer built for the modern web. It’s the first full-featured viewer that runs in a web page with no additional software. — Software as a service is really picking up. Why hope that the user has slow and inconvenient Adobe Reader installed when you can convert any PDF (and any document at all) to a format comfortably viewable with a Flash-based viewer provided by a third-party? This also shows just how important Flash has become, lately it’s fueling a lot of the “web 2.0″ innovation. I wonder if Sun will be able to catch up with Consumer JRE and JavaFX?


28
Feb 08

JavaScript Puzzlers

I have just attended a great course on JavaScript soft typing by Peter Thiemann. No doubt I’ll write more about it later, but today I want to show how fun and quirky can JavaScript be.

Note that all puzzles are given in succession and every next one includes all the code of the previous ones. Also note that I tested the puzzles in Mozilla Rhino, and can’t be held responsible for how standards non-compliant browsers (read Internet Explorer) will behave.

Puzzle 1

> var obj = {x : 1}

What are the values of

1) obj.y
2) print(obj.y)
3) obj.y.z

[Answer]

Puzzle 2

> var x = "x"
> obj.undefined = "gotcha"

What are the values of

1) obj[x]
2) obj[obj.y]

[Answer]

Puzzle 3

> var a = 17
> a.x = 42

What are the values of

1) a.x

[Answer]

Puzzle 4

> var flag = new Boolean(false);
> result = flag ? true : false;

What are the values of

1) result

[Answer]

Puzzle 5

> function f() {return this.x}

What are the values of

1) f()
2) obj.f = f; obj.f()
3) new f()

[Answer]

Puzzle 6

> function g1() {
>   u = 2;
>   print(u);
>   var u;
>   u = 3;
>   print(u);
> }
>
> function g2() {
>   u = 4;
>   print(u);
>   eval("var u");
>   u = 5;
>   print(u);
> }
> u = 1;
> g1();
> print(u);
> g2();
> print(u);

1) What values are printed out?

[Answer]


19
Feb 08

Aptana Jaxer or sliced bread?

Sometimes a technology appears that is just so damn cool you are amazed. More often than not the ideas behind it can be quite simple.

Aptana Jaxer is exactly such a technology. There is nothing new about having a server-side API. There is nothing new about building applications in HTML and JavaScript. The genius part is running Mozilla engine on the server-side and having access to full server resources from the browser via a controlled environment with no extra layers.

As far as I understood the communication between server and client is done by:

  • DOM updates are seamlessly propagated from the server to the client
  • Function calls can be proxied to call to the server. All marshalling is done automagically

This pretty much means that code runs seamlessly in a mixed, secure environment.

Although the “runat” attribute that controls whether code is run server-side or client-side can be a bit unlogical at first, the setup can allow to build powerful applications with only one (count it, one) technology — HTML and JavaScript. And this is the technology you have to use anyway to even deploy something on the web.

Of course “the one technology” suffers from being dynamically typed and generally known for its quirkiness, but with JavaScript 2.0 support on the way to Mozilla and good IDE support (which Aptana is in a good position to provide) this technology might yet give a fresh meaning to the word web application.

An interesting question I’d like to ask from the Aptana developers is if we can add a third environment to the mix — desktop applications? Having the same API to use on the server, in the browser and (with less restrictions) on the desktop could give Adobe AIR a run for their money.


14
Feb 08

Getting Files to Remote Places

Every now and then I need to share files with others. Either need to upload something to an accessible place or just give somebody a link to a set of files. Two handy scripts:

[perl]### BASH function, copy to ~/.bashrc ###
putfile(){
basename=${1##*/}
scp $1 user@host:/home/user/public_html/tmp/$basename
echo http://host/tmp/$basename
}[/perl]

Now this function is accessible from the terminal session. Just write putfile fileName and it will scp the file to the remote machine and output the URL that you can give to your friends. Be sure to have key based authentication enabled.

Do you want to quickly share a folder from your HDD without creating a quick link to your /var/www? Fire up a webserver with python.
[python]
python -c "from SimpleHTTPServer import test; test()"
[/python]

You can't remember you ip or don't want to type it every time to give the link? Echo the IP also to your console. Mind that this example uses the eth1 device, so if you have a different one be sure to change it.

[python]
### add it to ~/.bashrc
alias web='python -c "from SimpleHTTPServer import test;
import socket,fcntl,struct;
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM);
print \"http://\"+socket.inet_ntoa(fcntl.ioctl(
s.fileno(),0x8915, struct.pack(\"256s\", \"eth1\"))[20:24])+\":8000\";
test()"'
[/python]

Now you can share any folder by just typing web and you can copy the URL to your friend on LAN.