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 | |
for($i=1;$i<=100;$i++) { | |
if (($i % 3) == 0 AND ($i % 5) != 0) { | |
echo 'Fizz'."<br>"; | |
} | |
elseif (($i%3)!=0 AND ($i%5)==0) { | |
echo 'Buzz'."<br>"; | |
} | |
elseif (($i%3)==0 AND ($i%5)==0) { |
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
$('img.swap').click(function() { | |
var src = ($(this).attr('src')); | |
var swap = ($(this).data('swap')); | |
$(this).attr('src', swap ); | |
$(this).data('swap', src ); | |
}); | |
// <img src="images/pic1.jpg" data-swap="images/pic2.jpg" class="swap"> |
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
function words($value, $words = 100, $end = '...') | |
{ | |
preg_match('/^\s*+(?:\S++\s*+){1,'.$words.'}/u', $value, $matches); | |
if ( ! isset($matches[0]) || strlen($value) === strlen($matches[0])) return $value; | |
return rtrim($matches[0]).$end; | |
} | |
/* | |
Usage: |
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
Str::macro('readingTime', function (...$text) { | |
$totalWords = str_word_count(implode(" ", $text)); | |
$minutesToRead = round($totalWords / 200); // Avg WPM of adult | |
return (int)max(1, $minutesToRead); | |
}); |
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
// Add this in the register() method. | |
// Credit to @trovster -> https://twitter.com/trovster/status/1537082202709803008 | |
if (! $this->app->isProduction()) { | |
DB::listen(function ($query): void { | |
$date = Carbon::today()->toDateString(); | |
$filepath = storage_path("logs/queries-{$date}.log"); | |
File::append( | |
$filepath, | |
$query->sql . '[' . implode(', ', $query->bindings) . ']' . PHP_EOL |