Rectangle 27 1

Scalable System Design Patterns - Scatter and Gather

In this model, the dispatcher multicast the request to all workers of the pool. Each worker will compute a local result and send it back to the dispatcher, who will consolidate them into a single response and then send back to the client.

This pattern is used in Search engines like Yahoo, Google to handle user's keyword search request ... etc.


Note system design architectural patterns scalability
Rectangle 27 1

Scalable System Design Patterns - Load Balancer

In this model, there is a dispatcher that determines which worker instance will handle the request based on different policies. The application should best be "stateless" so any worker instance can handle the request.
This pattern is deployed in almost every medium to large web site setup.




Note system design scalability
Rectangle 27 1

Get Permissions in octal form

Use the stat command to get a file's permissions in octal form:

$stat -c "%a %n" file

From the man page of stat:

-c --format=FORMAT
%a Access rights in local
%n File name

Example of files:

$ stat -c "%a %n" .ssh/id_rsa
600 .ssh/id_rsa

Folders:

$ stat -c "%a %n" /var/www
755 /var/www/


Note user permissions stat how to
Rectangle 27 1

List your IPv6 configuration

To see the IPv6 configuration on a linux server using the ip tool:

ip -6 addr show dev <interface>
ip -6 addr show dev eth0

Or, using the ifconfig tool:
ifconfig <interface> | grep "inet6"
ifconfig eth0 | grep "inet6"
Note Linux ipv6 how to
Rectangle 27 1

Java Annotations

Java annotations are used to provide meta data for your Java code. Being meta data, Java annotations do not directly affect the execution of code, although some types of annotations can actually be used for that purpose.

Topic Java annotations metadata
Rectangle 27 1

Javascript Core

JavaScriptCore is the built-in JavaScript engine for WebKit. It currently implements ​ECMAScript.

Topic JavaScript javascriptcore
Rectangle 27 0

Create PDF with EPS drwaing,C#

I am currently working on a desktop application where I need to create a pdf with an image in it, whose reference is taken from an eps file. I haven't found any link or any reference for doing such an activity. I have done it with JPG format, but not EPS. Can anyone provide a solution for the issue?

Topic eps pdf
Rectangle 27 1

Python Tuples


tup1 = ('physics', 'chemistry', 1997, 2000);
tup2 = (1, 2, 3, 4, 5 );
tup3 = "a", "b", "c", "d";

A tuple is a sequence of immutable Python objects. Tuples are sequences, just like lists. The differences between tuples and lists are, the tuples cannot be changed unlike lists and tuples use parentheses, whereas lists use square brackets.

Creating a tuple is as simple as putting different comma-separated values. Optionally you can put these comma-separated values between parentheses also. For example

Like string indices, tuple indices start at 0, and they can be sliced, concatenated, and so on.

Note Python tuples
Rectangle 27 1

Shuffle an array using sort and random

Given the array:

var array = [1,2,3,4,5,6,7,8,9];

Sort randomly with:

array.sort(function(){     return Math.random() - 0.5 });

The - 0.5 means the returned value exists between the range -0.5 < x < 0.5, allowing the sort function to decide where to position the next item.

An example result:

array = [4,3,1,2,9,5,6,8,7]
Note JavaScript Array sorting
Rectangle 27 2

Restricting an annotation's application by using @Target

The type of element that an annotation can be applied to can be restricted using the @Target meta-annotation.

The @Target declaration takes the form of @Target(ElementType.<ELEMENT_TYPE>), where <ELEMENT_TYPE> is an element type from a predefined list. The available elements are:

  1. ANNOTATION_TYPE
  2. CONSTRUCTOR
  3. FIELD
  4. LOCAL_VARIABLE
  5. METHOD
  6. PARAMETER
  7. TYPE (any type of element)

For example:

@Target(ElementType.CONSTRUCTOR)

The annotation that is annotated with this will only be able to be applied to constructors.

Note Java annotations restrictions