Simple Document Repository Using RESTlet

REST architecture basically utilized URI for a restricted set of operation done via HTTP vocabulary. The most common vocabulary is GET, POST, PUT and DELETE. In my current project we need to have a simple way to store and retrieve PDF documents via a web server.

You might ask why I choose to use REST and not simply code a simple PHP upload script. Currently where I work its often difficult to add or install application to a server. I have a web server on Server#1, in which storage is limited and I can’t use it to store files other than web pages/scripts. I have another server Server#2 which is a database and processing server that has large amount of free space but doesn’t have any web server on it. So I think why not make a simple web server on Server#2 and expose POST/GET API to store/retrieve pdf.

I use Restlets, a simple REST framework build with Java. Using Restlets every URI is represented with a Resources class which will return a Representation if called. For this project I have two REST URI

POST : http://server/docs/
GET : http://server/docs/{documentName}

Its very simple, if I want to upload a document I just need to do a POST with form and <input type="file">. If the operation is successful it will return the file name. For download I would just do a usual get to the specified URL e.g.

GET http://server/docs/sample.pdf HTTP/1.1 

or I would just direct my browser to the specified URL. I add a simple listing if you direct your URL to http://server/docs/. The code is hosted on Github, you can fork it and enhanced it as you wish.

Loading mentions Retweet
Filed under  //   java   rest   restlet  

Comments [0]

Google DNS vs OpenDNS: Google Rocks for International Users

Reader Stevan Bajić sent in an awesome bash script which gives you nicely formatted results.

#!/bin/sh
isp=$(dig +noall +stats 2>&1 | awk '$2~/^SERVER:$/{split($3,dnsip,"#");print dnsip[1]}');
m="-------------------------------------------------------------------------------";
s="                                                                               ";
h="+${m:0:25}+${m:0:12}+${m:0:12}+${m:0:12}+${m:0:12}+${m:0:12}+";
header=("Domain${s:0:23}" "Your ISP${s:0:10}" "Google${s:0:10}" "4.2.2.2${s:0:10}" "OpenDNS${s:0:10}" "DNS Adv.${s:0:10}");
echo "${h}";
echo "| ${header[0]:0:23} | ${header[1]:0:10} | ${header[2]:0:10} | ${header[3]:0:10} | ${header[4]:0:10} | ${header[5]:0:10} |";
echo "${h}";
for i in "lifehacker.com" "facebook.com" "manu-j.com"  "reddit.com" "tb4.fr" "bbc.co.uk";
do
  ii="${i}${s:23}";
  echo -ne "| ${ii:0:23} |";
  for j in "${isp}"  "8.8.8.8"  "4.2.2.2" "208.67.222.222" "156.154.70.1";
  do
    r="${s:10}$(dig +noall +stats +time=9 @${j} ${i} 2>&1 | awk '$2~/^Query$/{print $4" "$5}')";
    echo -ne " ${r:${#r}-10} |";
  done
  echo -ne "\n${h}\n";
done

The following result when testing from Jakarta, Indonesia.

+-------------------------+------------+------------+------------+------------+------------+
| Domain                  | Your ISP   | Google     | 4.2.2.2    | OpenDNS    | DNS Adv.   |
+-------------------------+------------+------------+------------+------------+------------+
| lifehacker.com          |            |   111 msec |   366 msec |   297 msec |   123 msec |
+-------------------------+------------+------------+------------+------------+------------+
| facebook.com            |            |   111 msec |   343 msec |   297 msec |   127 msec |
+-------------------------+------------+------------+------------+------------+------------+
| manu-j.com              |            |   107 msec |   342 msec |   297 msec |   121 msec |
+-------------------------+------------+------------+------------+------------+------------+
| reddit.com              |            |   108 msec |   347 msec |   298 msec |   120 msec |
+-------------------------+------------+------------+------------+------------+------------+
| tb4.fr                  |            |   106 msec |   320 msec |   242 msec |   122 msec |
+-------------------------+------------+------------+------------+------------+------------+
| bbc.co.uk               |            |   117 msec |   317 msec |   266 msec |   122 msec |
+-------------------------+------------+------------+------------+------------+------------+

So what are you waiting for, change your DNS setting to
8.8.8.8 and 8.8.8.4

Loading mentions Retweet

Comments [0]

I can haz SkiFree on Snow Leopard

I can play SkiFree on Snow Leopard, yippieee!

Loading mentions Retweet

Comments [0]

Loading mentions Retweet

Comments [0]

Apple's Mistake

Should Apple care what people like me think? What difference does it make if they alienate a small minority of their users?

There are a couple reasons they should care. One is that these users are the people they want as employees. If your company seems evil, the best programmers won't work for you. That hurt Microsoft a lot starting in the 90s. Programmers started to feel sheepish about working there. It seemed like selling out. When people from Microsoft were talking to other programmers and they mentioned where they worked, there were a lot of self-deprecating jokes about having gone over to the dark side. But the real problem for Microsoft wasn't the embarrassment of the people they hired. It was the people they never got. And you know who got them? Google and Apple. If Microsoft was the Empire, they were the Rebel Alliance. And it's largely because they got more of the best people that Google and Apple are doing so much better than Microsoft today.

Another great essay by Paul Graham, in it he argue that until now Apple doesn't realize all the App Store rejection is actually hurting them deep. I especially like the Star Wars analogy he put into his article in a company to developer relationship, because its so true.

Loading mentions Retweet
Filed under  //   app store   apple   paul graham  

Comments [0]

Top 10 Bad Messages From Good Movies

10. If you’re not born with special abilities, you’re never going to be any good at some things, no matter how hard you try (from the Harry Potter movies, and, of course, books). 
9. No matter how appallingly bad conditions on Earth get, so long as there is one tiny plant on the planet, it can still be restored to its former beauty and sustainability (from WALL-E). 
8. Technology is fundamentally evil (from lots of movies, including the The Lord of the Rings trilogy). 
7. Arrogance, brash self-confidence and having had a heroic father are much more indicative of a competent leader than are experience and knowledge (from the 2009 Star Trek movie). 
6. Kissing sleeping women you don’t know will wake them up and lead to them falling in love with you (from Sleeping Beauty and Snow White and the Seven Dwarfs). 
5. If you’re a really good person, but in a lousy situation, simply wait around and eventually good things will just happen to you (from Cinderella). 
4. Unconventional creative play is very, very wrong (from Toy Story).
3. Even tough women who aren’t afraid to fight aren’t as important as the men they fight alongside (from the Star Wars movies).
2. It’s OK to completely change your physical appearance and way of life for the person you love, even if he makes no sacrifices at all (from The Little Mermaid). 
1. If you’re not a member of the elite, you’re basically inconsequential, even if you die heroically trying to save your people and your way of life (from the Star Wars movies).

When we watch movies, unconsciously we try to get values from what we see. Even 'Good' movies sometimes give bad or wrong message if you look further. But again this doesn't mean we must condemned the movie, as civil man we should filter out good from bad by ourself.

Loading mentions Retweet

Comments [0]

Loading mentions Retweet

Comments [0]

Q: Where do I put tnsnames.ora on Mac OSX?

A: Copy your tnsnames.ora to /etc with

sudo cp tnsnames.ora /etc 

Loading mentions Retweet

Comments [0]

Cookie Monster Doodle

Yesterday it was Big Bird, today Cookie Monster. Happy 40th birthday Sesame Street!

Loading mentions Retweet

Comments [0]

This is Broadband, When Can We Have This?

I really wish someday we Indonesian can have a cheap broadband line.

Loading mentions Retweet

Comments [0]

About

My name is Hendra Saputra, I'm an avid fan of Technology. I love programming, it's what I think of day and night. I also enjoy my time by reading a lot of things, the Internet just provide me with unlimited amount of things to read.