This file contains 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 | |
class Validate { | |
function chkValid($str,$min=3,$max='',$regex='',$attr='') { | |
if (is_numeric($min) and $min <> "") { | |
if (strlen($str) < $min) return false; | |
} | |
if (is_numeric($max) and $max <> "") { | |
if (strlen($str) > $max) return false; |
This file contains 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
/.idea | |
/node_modules | |
/vendor | |
composer.lock | |
.DS_Store | |
.env |
This file contains 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
DELETE FROM my_table | |
USING my_table, my_table mt1 | |
WHERE my_table.id > mt1.id | |
AND my_table.my_column = mt1.my_column -- the column which you're checking for duplicates on | |
AND my_table.`type` = 'greeting'; -- any other conditions that you need to filter by |
This file contains 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
SET @tableName = '<table_name>'; | |
SET @columnName = '<column_name>'; | |
SELECT table_name, column_name, referenced_table_name, referenced_column_name | |
FROM information_schema.key_column_usage | |
WHERE table_name = @tableName AND column_name = @columnName; |
This file contains 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
if (preg_match('/^dev[^\.]*?\./i', $_SERVER['HTTP_HOST'])) { | |
if (function_exists('dd')) { | |
dd('some dump ..', __FILE__.':'.__LINE__); | |
} else { | |
die(var_dump('some dump ..', __FILE__.':'.__LINE__)); | |
} | |
} |
This file contains 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\Errors; | |
class HttpErrorCodes | |
{ | |
/** | |
* Return all error codes as an array | |
* | |
* @return mixed |
This file contains 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
// Overwriting default action of render - Laravel 5.3 | |
public function render($request, Exception $exception) | |
{ | |
... | |
if (! $this->isHttpException($exception) && ! config('app.debug')) { | |
$exception = new \Symfony\Component\HttpKernel\Exception\HttpException(500); | |
} |
This file contains 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
var myArray = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19, 20, 21]; | |
function splitArray(array, numberOfChunks) { | |
arrayCount = array.length; | |
split = array.length / numberOfChunks; | |
chunks = []; | |
This file contains 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
#!/bin/bash | |
mkdir -p app/Contracts | |
mkdir -p app/Contracts/Repositories | |
mkdir -p app/Contracts/Services | |
mkdir -p app/Services | |
mkdir -p app/Store/Eloquent/Models | |
mkdir -p app/Store/Eloquent/Repositories | |
mkdir -p app/Store/Eloquent/Traits |
This file contains 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
SELECT CONCAT('ALTER TABLE `', table_name, '` ENGINE=InnoDB;') AS sql_statements | |
FROM information_schema.tables AS tb | |
WHERE table_schema = @DATABASE_NAME | |
AND `ENGINE` = 'MyISAM' | |
AND `TABLE_TYPE` = 'BASE TABLE' | |
ORDER BY table_name DESC; |
OlderNewer