Wednesday, July 13, 2016

Countdown Timer / Days count in Business days code in PHP

<?php
$start = new DateTime(null, new DateTimeZone('America/New_York'));
$end = new DateTime('2017-05-05');
// otherwise the  end date is excluded (bug?)
$end->modify('+1 day');

$interval = $end->diff($start);

// total days
$days = $interval->days;

// create an iterateable period of date (P1D equates to 1 day)
$period = new DatePeriod($start, new DateInterval('P1D'), $end);

// best stored as array, so you can add more than one
//$holidays = array('2012-09-07');

foreach($period as $dt) {
    $curr = $dt->format('D');

    // for the updated question
   // if (in_array($dt->format('Y-m-d'), $holidays)) {
     //  $days--;
   // }

    // substract if Saturday or Sunday
    if ($curr == 'Sat' || $curr == 'Sun') {
        $days--;
    }
}


echo $days; // 4?>

Sunday, March 13, 2016

The Future of Angular - Write Code. Learn Angular.

The  Angular is the most important in future for any web applications, it has more features and easy to implement what you want. In the future the trend of web desing is going off and using the latest platform  like bootstrap and Angular Js. these are most important in present trend.

There are lot of predefined codes are available to just do plug and play. So better to focus on latest frameworks and learn and use them on your works for better quality output.

Here are few website to follow:
http://www.learn-angular.org/
https://thinkster.io/a-better-way-to-learn-angularjs
https://www.codecademy.com/learn/learn-angularjs
http://www.w3schools.com/angular/


Monday, February 29, 2016

RGB to CMYK: how to prepare photos for print in Photoshop

In this photo editing tutorial we show you how to convert images from RGB to CMYK in Photoshop to produce perfect colour prints.
RGB to CMYK: how to prepare photos for print in Photoshop
After processing a photo to look good on screen, you may end up with a print that suffers from shifts in colour. The discrepancy between the screen and print colour is caused by a variety of factors.
Your computer’s screen produces millions of colours by mixing reds, greens and blues (RGB) together, while most domestic printers combine cyan, magenta, black and yellow (CMYK) inks to create a narrower range of colours. Colours that can’t be printed are referred to as ‘out-of-gamut’ colours.
In this tutorial we’ll demonstrate how to prepare a picture for print and avoid colour-related disappointments. By default, Photoshop uses the screen-friendly colour space called sRGB (standard RGB).
You can change this colour space to a narrower, more printable one called Adobe RGB (1998) that helps you reduce the number of out-of-gamut colours. There’s also a handy gamut warning that you can summon to identify unprintable colours.
We’ll show you how to set up Photoshop’s colour management tools so that you can convert files that have an unprintable sRGB colour space to the printer-compatible Adobe RGB (1998) colour space.
We’ll also demonstrate how to change Photoshop’s colour mode so it’s compatible with the printer’s CMYK ink-mixing technique, so that your images have a vibrant, printable range of colours.

How to convert photos from RGB to CMYK

How to convert photos from RGB to CMYK: step 1
01 Manage your colours
Go to Edit > Color Settings. In the Color Settings window, choose an appropriate location-based profile such as Europe Prepress 3. This will ensure Photoshop uses a print-friendly colour space called Adobe RGB (1998) instead of the default sRGB one. Leave the Profile Mismatch boxes ticked.
How to convert photos from RGB to CMYK: step 2
02 Convert the embedded profile
Download our start file and follow along! Open print_start.jpg. The embedded colour profile of this image describes its colours using the screen-friendly sRGB colour space. You can change the sRGB profile to a printer-compatible one by ticking the ‘Convert document’s colors to the working space’ button. Click OK to close the dialog box.
How to convert photos from RGB to CMYK: step 3
03 Gamut warning
To discover remaining unprintable colours, choose View > Gamut Warning. Problematic colours will appear as patches of grey. You could use a Vibrance adjustment layer to reduce the saturation of the colours. The gamut warning patches would vanish, but other colours may look a bit drab.
How to convert photos from RGB to CMYK: step 4
04 Change the mode
Go to Mode and choose CMYK Color. Click OK. This forces the colours into a print-compatible CMYK colour space. The gamut warning patches will vanish. Choose Mode > RGB Color. You can now use a Vibrance adjustment layer to boost the saturation without producing warnings.

Wednesday, February 24, 2016

jQuery to match an input field value against a pre-defined value on focusout | Drupal Den

Here is how to show a message on a form when the input field loses focus and it matches a predefined value. In this example a message appears if the user enters an email address that matches the domain of a free email provider, eg. Hotmail, Yahoo & Gmail.
NOTE: this doesn't validate and stop the user from being able to submit the form, it's just a message that appears. If you use the Webform module and want to prevent a user from submitting a form you can do this by also enabling the Webform Validation module and adding a Form Validation Rule of the type Words Blacklist.
Anyway back to creating a jQuery message which appears when a form input value matches a predefined value...
The below script checks for a match when the field loses focus - in this instance it's checking for '@hotmail.', '@yahoo.' & '@gmail.'. It was done in this way so that it matches for both '@yahoo.com' and '@yahoo.co.uk', and isn't case sensitive. You can build quite complex rules for matching using JavaScript regular expressions (RegEx).
The message is inserted directly after the email input field, and is removed once the match isn't found anymore.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<form>
    <input class="form-email" type="email" id="edit-submitted-email-address" name="submitted[email_address]" size="60">
</form>
 
<script>
(function ($) {     
    $('input.form-email').focusout(function(){
        var match = $(this).val().match(/@hotmail\.|@yahoo\.|@gmail\./gi);
        if(match){
                $(this).not('.emailAlertActive').after( '<p class="emailAlert">Please use your business email address.</p>' ).addClass('emailAlertActive');
        } else {
            $(this).siblings('.emailAlert').remove();
            $(this).removeClass('emailAlertActive')
        }
    })})(jQuery);
</script>