Pages

Tuesday, June 25, 2013

xml-rpc vs soap vs rest pros and cons

Ok well as in some of the posts I've done, I'm going to redirect you to a url that has described this topic in very nice simple but in a detail manner. Hats off to the person who wrote this article in a such cool yet very analytic manner. So checkout the below link.

http://maxivak.com/rest-vs-xml-rpc-vs-soap/

Thursday, June 20, 2013

How to stop some images loading from chache

In some cases we need to stop loading resources from cache. Say for an example, when we need to update a profile picture, we should not allow the cache to load the image again. So how are we going to do this. You can achieve this in two different ways.

  1. Add a parameter to the end of the url. Eg: http://your.site.com?random=98798987987 Important thing to notice here is you need to add a random variable in order to make the url different from the previous one
  2. The other method is to configure the headers in the request . But the downside of this approach is, You will need to set different headers parameters based on different browsers. eg. header("Pragma-directive: no-cache"); header("Cache-directive: no-cache"); header("Cache-control: no-cache"); header("Pragma: no-cache");  header("Expires: 0")

Tuesday, June 18, 2013

Spring properties place holder configurer example

Often we need to put configuration parameters independently to the code. Because you do not need to lookup the code in order to configure the system and it allows to maintain the system without much trouble.  In such cases it is good to keep a properties file. A good example of the usage of this is, configuration properties of a database.

Now this can be achieved in several methods. One is to use spring's PropertiesLoaderUtils class. Another is to use the spring properties place holder configurer.

Now lets see how you can achieve this using spring properties place holder configurer.

create a database.properties file in your classpath and put the following properties in it.

jdbc.driverClassName=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/dbname
jdbc.username=root
jdbc.password=password


Then you need to declare the bean as following PropertyPlaceholderConfigurer

<beanclass="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
  <property name="location">
    <value>database.properties</value>
  </property>
</bean>

Now you can access the values of the properties as following.

<bean id="dataSource"class="org.springframework.jdbc.datasource.DriverManagerDataSource">    <property name="driverClassName" value="${jdbc.driverClassName}" />
<property name="url" value="${jdbc.url}" />
<property name="username" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
</bean>

Now what you need to access these properties in your java code too.

then you can simply use @value annotation. something like @Value("${valueKey}")


Tuesday, June 4, 2013

What is a SIP server?

SIP stands for session initiation protocol. These servers are used for serving voice, audio and other communications over internet protocol. Network elements of  SIP server can be found in this link.

http://en.wikipedia.org/wiki/Session_Initiation_Protocol#Network_elements

big O complexities of common algorithms

The following link summarizes the complexities of common computer science algorithms stating weather they are good or not for specific tasks. This could be very useful.

http://bigocheatsheet.com/

RTMP

RTMP is a real time messaging protocol owned by macromedia. This protocol is used to stream video, audio and data over internet between a flash player and a server.  It uses 1935 port by default. Another variant of this protocol is RTMPT (real time messaging protocol with tunneling) and it is encapsulated within an http request to traverse firewalls.