Skip to content

Instantly share code, notes, and snippets.

View imanilchaudhari's full-sized avatar
💻
Learning Dart On Flutter

Anil Chaudhari imanilchaudhari

💻
Learning Dart On Flutter
View GitHub Profile
@imanilchaudhari
imanilchaudhari / PHP Version Manager On Ubuntu 18.04
Created November 20, 2018 05:23
PHP Version Manager On Ubuntu 18.04
Get the information of PHP
==========================
$ sudo apt show php
OR
$ sudo apt show php -a
$ sudo apt install php // this will install default php version ( may be 7.2 )
T0 Install Different Versions Of PHP
@imanilchaudhari
imanilchaudhari / getElementsByClass
Created October 9, 2018 09:42
DOMElement getElementsByClass
<?php
public function getElementsByClass(&$parentNode, $tagName, $className)
{
$nodes = array();
$childNodeList = $parentNode->getElementsByTagName($tagName);
for ($i = 0; $i < $childNodeList->length; $i++) {
$temp = $childNodeList->item($i);
if (stripos($temp->getAttribute('class'), $className) !== false) {
@imanilchaudhari
imanilchaudhari / mysql-table-schema-debugger.txt
Created September 21, 2018 07:26
MySQL table schema debugger
LIST OF MYSQL FUNCTIONS
=======================
show create table <table>; // displays the sql query similar to sql while creating
show fields from <table>; // displays the fields of table
show indexes from <table>; // displays the indexed of tabe ( foreign, unique, index etc. )
@imanilchaudhari
imanilchaudhari / get random user agent.php
Created August 21, 2018 05:14
Get random user agent using php
<?php
class RandomUserAgent
{
public $browser_frequency = [
"Internet Explorer" => 11.8,
"Firefox" => 28.2,
"Chrome" => 52.9,
"Safari" => 3.9,
"Opera"=>1.8
@imanilchaudhari
imanilchaudhari / ActiveQuery.php
Last active May 3, 2018 06:37
Yii2 active query compatible with geometrical data types.
<?php
namespace common\components;
use yii\db\ActiveQuery as YiiActiveQuery;
/**
* Class providing additional features for yii\db\ActiveQuery. Add support for JSON and spatial data types.
*
* @since 0.0.1
@imanilchaudhari
imanilchaudhari / ActiveRecord.php
Created May 3, 2018 06:27
Yii2 active record compatible with geometrical data types.
<?php
namespace common\components;
use Yii;
use yii\db\Expression;
use yii\db\ActiveRecord as YiiActiveRecord;
use yii\base\InvalidCallException;
/**
@imanilchaudhari
imanilchaudhari / yii2-rest-usefull-links.txt
Last active April 17, 2018 03:41
Yii2 Rest Usefull Links
@imanilchaudhari
imanilchaudhari / json-file-search.php
Last active June 10, 2022 10:23
Yii2 filter from JSON field example
<?php $item = FileMeta::find()->where("JSON_EXTRACT(data, '$.user_id') = {$user_id} and JSON_EXTRACT(data, '$.type') = 'video'")->andWhere(['key' => 'showcase'])->one(); ?>
@imanilchaudhari
imanilchaudhari / lemp-install.sh
Created February 15, 2018 05:25
Lemp stack for Ubuntu 16.04 (PHP7, Nginx, MongoDB, Git, Node.js, Bower, Gulp, Composer(with asset plugin))
#!/bin/bash
echo "Please, enter your username, it will be added to 'sudo' and 'docker' groups during the process."
read USERNAME
if [ -z "$USERNAME" ] ; then
echo "Exiting... Done."
exit
else
echo "Adding user to 'sudo' group..."
@imanilchaudhari
imanilchaudhari / yii2-add-jquery-error-message.js
Created December 6, 2017 07:30
Yii2 add custom error message on form
jQuery("#{form-id}").yiiActiveForm("add",{
"id": "field-id",
"name": "{field-name}",
"container": ".field-{field-id}",
"input": "#{field-id}",
"error": ".help-block",
"validate": function(attribute, value, messages, deferred, $form) {
yii.validation.required(value, messages, {
"message": "{message}"
});