Mysql Query Example to calculate Age

Mysql Query Example to calculate Age in years, months and days:

– (
RIGHT(dob,5)) AS age,
case when ((MONTH(CURDATE())- MONTH(dob))
– (RIGHT(CURDATE(),2)<RIGHT(dob,2)))>0 then ((MONTH(CURDATE())- MONTH(dob))
– (RIGHT(CURDATE(),2)<RIGHT(dob,2))) else ((MONTH(CURDATE())- MONTH(dob))
– (RIGHT(CURDATE(),2)<RIGHT(dob,2))) + 12 end AS Months,
(DAY(CURDATE() – DAY(dob))) AS Days;

Mysql function to Check if an year is leap year or not

Mysql function to Check if an year is leap year or not:

drop function if exists is_leapyear;
delimiter |
CREATE FUNCTION is_leapyear(y1 int(4))
RETURNS int(1)
declare r int;
set r = case when (y1%4=0) then 1 else 0 end;
return r;

Register Post Types, Using Capabilities:

Register Post Types, Using Capabilities:

When using custom post types in wordpress, I did some research and found some permission levels. These things are not exclusively explained in WordPress documentation ( ).

For example, I am adding a custom post type called book, then I would add following code to my plugin:

add_action('init', 'add_books_init');
function add_books_init()
  $labels = array(
    'name' => _x('Books', 'post type general name'),
    'singular_name' => _x('Book', 'post type singular name'),
    'add_new' => _x('Add New', 'book'),
    'add_new_item' => __('Add New Book'),
    'edit_item' => __('Edit Book'),
    'new_item' => __('New Book'),
    'view_item' => __('View Book'),
    'search_items' => __('Search Books'),
    'not_found' =>  __('No books found'),
    'not_found_in_trash' => __('No books found in Trash'),
    'parent_item_colon' => '',
    'menu_name' => 'Books'

  $args = array(
    'labels' => $labels,
    'public' => true,
    'publicly_queryable' => true,
    'show_ui' => true,
    'show_in_menu' => true,
    'query_var' => true,
    'rewrite' => array('slug'=>'mybooks'),
    'capability_type' => array('book','books'),
    'has_archive' => true,
    'hierarchical' => false,
    'menu_position' => null,
    'supports' => array('title', 'comments', 'editor'),

Notice the argument capability_type, which is optional in register post type. However, if we do not add this argument, the new book section will be registered with permissions as that of posts.

Now, in our case, the books sections is registered as a new entity, having its own permission set. We need to assign some new permissions to any user to access this entity (to an administrator also!)

In our case, the permissions that need to be assigned are mentioned below:


We can use some sort of plugins or use wp_capability variable to assign these permissions. I used capsman plugin for the same. Have a look at the screenshot:

Zero Knowledge Proof

Zero-Knowledge proofs are fascinating and extremely useful constructs. Their fascinating nature is due to their seemingly contradictory definition; zero-knowledge proofs are both convincing and yet yield nothing beyond the validity of the assertion being proven. Their applicability in the domain of cryptography is vast; they are typically used to force malicious parties to behave according to a predetermined protocol. In addition to their direct applicability in Cryptography, zero-knowledge proofs serve as a good bench-mark for the study of various problems regarding cryptographic protocols (e.g., “secure composion of protocols” and the “use of of the adversary’s program within the proof of security”).

In this tutorial we will present the basic definitions and results regarding zero-knowledge as well as some recent developments regarding this notion.

The Basics

Loosely speaking, zero-knowledge proofs are proofs that yield nothing beyond the validity of the assertion. That is, a verifier obtaining such a proof only gains conviction in the validity of the assertion. This is formulated by saying that anything that is feasibly computable from a zero-knowledge proof is also feasibly computable from the (valid) assertion itself (by a so-called simulator). Variants on the basic definition include:

  • Consideration of auxiliary inputs.
  • Universal and black-box simulations.
  • Restricting attention to honest verifiers.
  • The level of similarity required of the simulation.

It is well-known that zero-knowledge proofs exist for any NP-set, provided that one-way functions exist. This result is a powerful tool in the design of cryptographic protocols, because it enables to force parties to behave according to a predetermined protocol (i.e., the protocol requires parties to provide zero-knowledge proofs of the correctness of their secret-based actions, without revealing these secrets).

Advanced Topics

We focus on two basic problems regarding zero-knowledge, which actually arise also with respect to the security of other cryptographic primitives. The first question refers to the preservation of security (i.e., zero-knowledge in our case) under various types of composition operations. We survey the known results regarding sequential, parallel and concurrent execution of (arbitrary and/or specific) zero-knowledge protocols. The main facts are:

  • Zero-knowledge (w.r.t auxiliary inputs) is closed under sequential composition.
  • In general, zero-knowledge is not closed under parallel composition. Yet, some zero-knowledge proofs (for NP) preserve their security when many copies are executed in parallel. Furthermore, some of these protocol use a constant number of rounds.
  • Some zero-knowledge proofs (for NP) preserve their security when many copies are executed concurrently, but such a result is not known for constant-round protocols.

The second basic question regarding zero-knowledge refers to the usage of the adversary’s program within the proof of security (i.e., demonstration of the zero-knowledge property). For 15 years, all known proofs of security used the adversary’s program as a black-box (i.e., a universal simulator was presented using the adversary’s program as an oracle). Furthermore, it was believed that there is no advantage in having access to the code of the adversary’s program. Consequently it was conjectured that negative results regarding black-box simulation represent an inherent limitation of zero-knowledge. This belief has been refuted recently by a zero-knowledge argument (for NP) that has important properties that are unachievable by black-box simulation.

Other topics treated in the full version of the tutorial (but not in its oral presentation) include proofs of knowledge, Non-Interactive Zero-Knowledge proofs, Statistical Zero-Knowledge, Knowledge Complexity, and the resettability of a party’s random-tape.