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 | |
$max_file_size = 5*1024*1024; //5MB | |
$path = "admin/upload/"; // Upload directory | |
//$count = 0; // nr.successfully uploaded files | |
$valid_formats = array("rar","zip","7z","pdf","xlsx","xls","docx","doc","txt"); | |
$valid_formats_server = array( | |
"application/pdf", | |
"application/octet-stream", |
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
<? | |
// Path to the project's root folder | |
echo base_path(); | |
// Path to the 'app' folder | |
echo app_path(); | |
// Path to the 'public' folder | |
echo public_path(); |
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 folderSize ($dir) | |
{ | |
$size = 0; | |
foreach (glob(rtrim($dir, '/').'/*', GLOB_NOSORT) as $each) { | |
$size += is_file($each) ? filesize($each) : folderSize($each); | |
} |
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
$ts1 = strtotime($start); | |
$ts2 = strtotime($end); | |
$seconds_diff = $ts2 - $ts1; | |
$time = ($seconds_diff/3600); |
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
.flex { | |
display: -webkit-box; | |
display: -webkit-flex; | |
display: -ms-flexbox; | |
display: flex; | |
-moz-box-wrap: nowrap; | |
-webkit-box-wrap: nowrap; | |
-webkit-flex-wrap: nowrap; | |
-ms-flexbox-wrap: nowrap; | |
-ms-flex-wrap: nowrap; |
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
$string = "some string that needs to be hashed"; | |
$hash = password_hash($string, PASSWORD_BCRYPT, array('cost' => 10)); |
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
function generateRandomString(length) { | |
var characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()-_+=;:,./?\\|`~[]{}'; | |
var randomString = ''; | |
for (var i = 0; i < length; i++) { | |
randomString += characters[Math.floor(Math.random() * (characters.length - 1))]; | |
} | |
return randomString; | |
} |
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 | |
//app/Http/Middleware/LoadSite.php | |
namespace App\Http\Middleware; | |
use App\Exceptions\SiteNotFoundException; | |
use App\Sites\SiteRepository; | |
use App\Sites\SiteService; | |
use Closure; |
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
I have made some researches on this subject recently. The way to implement it has to be different if the field is a TEXT field, a non unique field. | |
I have made some tests with a TEXT field. Considering the fact that we have a table with 1M entries. 37 entries are equal to 'something': | |
SELECT * FROM test WHERE texte LIKE '%something%' LIMIT 1 with mysql_num_rows() : 0.039061069488525s. (FASTER) | |
SELECT count(*) as count FROM test WHERE text LIKE '%something% : 16.028197050095s. | |
SELECT EXISTS(SELECT 1 FROM test WHERE text LIKE '%something%') : 0.87045907974243s. | |
SELECT EXISTS(SELECT 1 FROM test WHERE text LIKE '%something%' | |
LIMIT 1) : 0.044898986816406s. | |
But now, with a BIGINT PK field, only one entry is equal to '321321' : |
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
var test = moment.tz("2017-05-30 13:08:22", "UTC") | |
test.tz("Europe/Moscow") |