This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // get the user's timezone | |
| var tz = moment.tz.guess(); | |
| console.info('Timezone: ' + tz); | |
| // returns: Timezone: Europe/London | |
| // set the default user timezone | |
| moment.tz.setDefault(tz); | |
| // set custom timezone | |
| moment.tz.setDefault('America/Los_Angeles'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # location of keystore | |
| storeFile=/path/to/app.keystore | |
| # Key alias | |
| keyAlias=alias_name | |
| # Store password | |
| storePassword=Password1 | |
| # Key password |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // include composer packages | |
| include "vendor/autoload.php"; | |
| // Create new Landscape PDF | |
| $pdf = new FPDI('l'); | |
| // Reference the PDF you want to use (use relative path) | |
| $pagecount = $pdf->setSourceFile( 'certificate.pdf' ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Regex example to validate the format of a Emirates | |
| * ID number. Does not validate the checkbit (Luhn Algorithm). | |
| * | |
| * @author Niraj Shah <[email protected]> | |
| */ | |
| // regex to validate the format xxx-xxxx-xxxxxxx-x (Emirates ID) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php namespace App\Http\Controllers; | |
| use App\Http\Controllers\Controller; | |
| use Input; | |
| use Auth; | |
| use View; | |
| use Session; | |
| use Validator; | |
| use Redirect; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # location of keystore | |
| storeFile=/path/to/app.keystore | |
| # Key alias | |
| keyAlias=alias_name | |
| # Store password | |
| storePassword=Password1 | |
| # Key password |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // validate that mobile number starts with '07' | |
| $rules = [ | |
| 'mobile' => 'required|numeric|startswith:07', | |
| ]; | |
| // custom validator called startswith | |
| Validator::extend('startswith', function( $attribute, $value, $parameters ) { | |
| return substr( $value, 0, strlen( $parameters[0] ) ) == $parameters[0]; | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Remember to include the required classes, e.g. Hash, Validator, Redirect, User model | |
| // define validation rules, 'password' will be our custom rule | |
| $rules = [ | |
| 'current_password' => 'required|password', | |
| 'password' => 'required|confirmed|min:6', | |
| ]; | |
| // custom rule for 'password' | |
| Validator::extend('password', function( $attribute, $value, $parameters ) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Start MongoDB Shell | |
| mongo | |
| # Get MongoDB version | |
| mongo --version | |
| # Show Mongo Databases (from MongoDB Shell) | |
| show dbs | |
| # Create DB `parse` and Insert Data to `users` collection |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Import the Public Key for Official MongoDB Repo | |
| sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10 | |
| # Update apt-get to get latest MongoDB packages | |
| echo "deb http://repo.mongodb.org/apt/ubuntu "$(lsb_release -sc)"/mongodb-org/3.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.0.list | |
| # Update apt-get package list with new repo details | |
| sudo apt-get update | |
| # Install the latest version of MongoDB |