Skip to main content

Posts

Casting an int to void pointer in c++

I was a bit confused with the following piece of code which just creates a number of threads and assigns them an id. #include "pthread.h" #include "stdio.h" #include "stdlib.h" #define N 5 void *worker_thread(void *arg) {     printf("This is worker_thread #%ld\n", (long) arg);     pthread_exit(NULL); } int main() {     pthread_t my_thread[N];     long id;     for (id = 1; id <= N; id++) {         int ret = pthread_create(&my_thread[id], NULL, &worker_thread, (void*) id);         if (ret != 0) {             printf("Error: pthread_create() failed\n");             exit(EXIT_FAILURE);         }     }     pthread_exit(NULL); } The function...

Disk Usage for Directories in Linux

The Linux command du -h --block-size=MiB --max-depth=3 | sort -rn shows the disk usage for each directory upto a depth of 3. MiB is required to avoid showing all those long bytes numbers. -h is for human readable format. sort -rn sorts on the reverse numeric order, i.e. the most disk usage first

Signal Handling - Linux

A program running always face unexpected situations, running out of memory, lost network connectivity, losing permissions, read write errors etc. Therefore a robust program should be resilient to these conditions and should gracefully exit if the program cannot continue. Signals should be handled.... I found this to be extremely resourceful and I'll just give a summary of what the author Alex says..... Signal is a notification, a message sent by either operating system or some application to your program (or one of its threads). In addition to informative nature of signals, they also interrupt your program. I.e to handle a signal, one of the threads in your program, stops its execution and temporarily switches to signal handler. Signals, as their name implies, used to signal something. There are several types of signals, each indicating something of its own. For instance SIGINT that I already mentioned, tells your program that someone tries to interrupt it with CTRL-C....

Vaadin vs GWT

From Chapter 1 of book of Vaadin I quote the following. Vaadin Framework is a Java web application development framework that is designed to make creation and maintenance of high quality web-based user interfaces easy. Vaadin supports two different programming models: server-side and client-side . The server-driven programming model is the more powerful one . It lets you forget the web and program user interfaces much like you would program a desktop application with conventional Java toolkits such as AWT, Swing, or SWT. But easier. While traditional web programming is a fun way to spend your time learning new web technologies, you probably want to be productive and concentrate on the application logic. The server-side Vaadin framework takes care of managing the user interface in the browser and the AJAX communications between the browser and the server . With the Vaadin approach, you do not need to learn and deal directly with browser technologies, such as HTML or JavaScript. ...

What is GWT ? Google Web Toolkit

The GWT project states that, GWT is a development toolkit for building and optimizing complex browser-based applications. Its goal is to enable productive development of high-performance web applications without the developer having to be an expert in browser quirks, XMLHttpRequest, and JavaScript. GWT is used by many products at Google, including AdWords, AdSense, Flights, Hotel Finder, Offers, Wallet, Blogger. It’s open source, completely free, and used by thousands of developers around the world. I quote the development lifecycle of GWT App from the project site as well. Write : The GWT SDK provides a set of core Java APIs and Widgets. These allow you to write AJAX applications in Java and then compile the source to highly optimized JavaScript that runs across all browsers, including mobile browsers for Android and the iPhone. Constructing AJAX applications in this manner is more productive thanks to a higher level of abstraction on top of common concepts like DOM...

Dynamic Web Content - From HTML to Servlets and beyond (Part II)

Towards Servlets  From the earlier post I've discussed about the techniques of dynamic web content loading. This post is about servlets, java servlet pages (jsps) and java. Java Servlets are an efficient and powerful solution for creating dynamic content for the Web. Over the past few years Servlets have become the fundamental building block of mainstream server-side Java. The power behind Servlets comes from the use of Java as a platform and from interaction with a Servlet container. The Java platform provides a Servlet developer with a robust API, object-orientated programming, platform neutrality, strict types, garbage collection, and all the security features of the JVM. Complimenting this, a Servlet container provides life cycle management, a single process to share and manage application-wide resources, and interaction with a Web server. Together this functionality makes Servlets a desirable technology for server-side Java developers.  ...

Dynamic Web Content - From HTML to Servlets and beyond (Part I)

Web development involves a typical client server model. Client Server communications is built on the OSI stack and different communication protocols exist at each layer. Internet is built upon TCP/IP as the transport and internet layer and HTTP/HTTPS as the application layer. A client communicating with a web server via a web browser needs to establish a TCP connection on the listening port of the serer. After establishing a TCP connection, the client communicates over HTTP. HTTP requests in the form of GET/POST are sent to the server and the server responds with metadata and HTML content. This HTML content is interpreted by the web browser to render web pages on client's browser. Web development is a vast field with thousands of libraries, frameworks, protocols and technologies. It's impossible to study all of them but the important thing to realize is that there are many ways to accomplish a similar outcome. All these techniques can be grouped into 2 aspects, Cl...