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 | |
| //merge sort example | |
| function merge_sort($unsortedArray){ | |
| $arrayCount = count($unsortedArray); | |
| //check if one element (passed by merge function or main function) | |
| if($arrayCount === 1){ | |
| //already sorted |
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 | |
| function quickSort($unsortedArray){ | |
| $leftArray = []; | |
| $rightArray = []; | |
| $arrayCount = count($unsortedArray); | |
| //considering middle of array | |
| $pivot = $unsortedArray[(int)floor($arrayCount / 2)]; | |
| for($i = 0; $i < $arrayCount ; $i++){ |
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 | |
| function quick_sort($unsortedArray) | |
| { | |
| $left = $right = array(); | |
| if(count($unsortedArray) < 2) | |
| { | |
| return $unsortedArray; | |
| } | |
| $pivot_key = key($unsortedArray); | |
| $pivot = array_shift($unsortedArray); |
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
| let ip = [1,2,34,5,6,7,34]; | |
| let maxValue = 0; | |
| let indexMaxValue = 0; | |
| var lastElement = false; | |
| const lastIndex = ip.length-1; | |
| ip.forEach((value,key) => { | |
| if(value >= maxValue){ |
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
| #Create user with prefix (privileges) | |
| # c_ for create only | |
| # r_ for read only | |
| # u_ for update only | |
| # de_ for delete only | |
| # dr_ for drop only | |
| # grants can be mereged | |
| # Eg : User with CREATE, READ, UPDATE access | |
| # c_r_u_<user_name>@host |
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
| public function getUserData(Request $request) { | |
| $rules = [ | |
| "userId" => "required" | |
| ]; | |
| $validatedResponse = $this->validate($request,$rules); | |
| $data = DB::table("users") | |
| ->where("id",$validatedResponse["userId"]) |
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
| public function getUserData(Request $request) { | |
| $rules = [ | |
| "userId" => "required" | |
| ]; | |
| $validatedResponse = $this->validate($request,$rules); | |
| try { | |
| $data = DB::table("users") |
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\Providers; | |
| use Illuminate\Routing\ResponseFactory; | |
| use Illuminate\Support\ServiceProvider; | |
| class ResponseServiceProvider extends ServiceProvider | |
| { | |
| /** |
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
| public function getUserData(Request $request) { | |
| $rules = [ | |
| "userId" => "required" | |
| ]; | |
| $validatedResponse = $this->validate($request,$rules); | |
| $data = DB::table("users") | |
| ->where("id",$validatedResponse["userId"]) |
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
| public function getUserData(Request $request) { | |
| $rules = [ | |
| "userId" => "required" | |
| ]; | |
| $validatedResponse = $this->validate($request,$rules); | |
| try { | |
| $data = DB::table("users") |
OlderNewer