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
jQuery.validator.addMethod("alphanumeric", function(value, element) { // allow only alpha numric validation | |
return this.optional(element) || /^[a-zA-Z0-9]+$/.test(value); | |
}); | |
jQuery.validator.addMethod("letterwithspaces", function(value, element) { // allow only latters with space validation | |
return this.optional(element) || /^[a-zA-Z]+$/.test(value); | |
}); | |
jQuery.validator.addMethod("imagetype", function(value, element) { // allow image validation | |
return this.optional(element) || /^.*\.(jpg|png|jpeg|gif)$/i.test(value); |
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
Yii::$app->errorHandler->errorAction = 'studconsult/default/error'; | |
<?php | |
namespace app\modules\admin; | |
class Module extends \yii\base\Module | |
{ | |
public $controllerNamespace = 'app\modules\admin\controllers'; |
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 hashlib as hasher | |
import datetime as date | |
# Define what a Snakecoin block is | |
class Block: | |
def __init__(self, index, timestamp, data, previous_hash): | |
self.index = index | |
self.timestamp = timestamp | |
self.data = data | |
self.previous_hash = previous_hash |
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
1. by model : | |
[['attribute', 'second_attribute'], 'default', 'value' => 'something_here'], | |
2. load attributes in model | |
$model = new Post(); | |
$model->loadDefaultValues(); |
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
// SMTP settings to send mail in yii2 | |
'mailer' => [ | |
'class' => 'yii\swiftmailer\Mailer', | |
// send all mails to a file by default. You have to set | |
// 'useFileTransport' to false and configure a transport | |
// for the mailer to send real emails. | |
'useFileTransport' => false, | |
'transport' => [ | |
'class' => 'Swift_SmtpTransport', | |
'host' => 'smtp.gmail.com', |
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
// To create custom admin layout template , Go to config/web.php and add below lines | |
'modules' => [ | |
'gii' => [ | |
'class' => 'yii\gii\Module', //adding gii module | |
'allowedIPs' => ['127.0.0.1','192.168.1.*'], //allowing ip's | |
'generators' => [ | |
'crud' => [ // generator name | |
'class' => 'yii\gii\generators\crud\Generator', // generator class | |
'templates' => [ //setting for out templates |
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
/** | |
* Send a bulk update to Firebase from an array or an object literal. | |
* | |
* When .push() is called on a Firebase reference without a parameter passed no | |
* trip to the server is made. | |
* | |
* ex: | |
* var childRef = ref.push(); | |
* | |
* A reference is returned which has a push-id that can be returned by calling .name(). |