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 (array['hello', 'world'])[trunc(1 + random() * @len)]; |
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
document.querySelector('.datepicker').value = (new Date()).toISOString().substr(0, 10); |
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
-- Lua implementation of PHP scandir function | |
-- special thanks to: | |
-- rhoster (https://stackoverflow.com/users/974053/rhoster) | |
-- ulmangt (https://stackoverflow.com/users/1212363/ulmangt) | |
function scandir(directory) | |
local i, t, popen = 0, {}, io.popen | |
local pfile = popen('ls -a "'..directory..'"') | |
for filename in pfile:lines() do | |
i = i + 1 | |
t[i] = filename |
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 elt(floor(1 + (rand() * @len)), "hello", "world", "this", "is", "a", "random", "list"); |
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 * from information_schema.COLUMNS | |
where TABLE_SCHEMA = 'schema' | |
and TABLE_NAME = 'table' -- optionally specify the table | |
and IS_NULLABLE = 'NO' -- optionally set to 'YES' to find nullable columns | |
and COLUMN_DEFAULT is null; -- optionally specify columns without a default |
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
export default (...fields) => [...fields].reduce((sum, { length }) => sum + length, 0) === 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
<?php | |
namespace App\Providers; | |
use Illuminate\Http\Request; | |
use Illuminate\Routing\Route; | |
use Illuminate\Support\ServiceProvider; | |
use App\Http\Middleware\CaptureRequestExtension; | |
class AppServiceProvider extends ServiceProvider |
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
#!/usr/bin/env bash | |
# | |
# ... commands ... | |
# | |
exit $? |
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
SHOW ENGINE INNODB STATUS; |
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
Collection::macro('peekMap', function (callable $callback) { | |
$lastValue = null; | |
return $this->map(function ($value, $key) use ($callback, $lastValue) { | |
$newValue = $callback($value, $key, $lastValue); | |
$lastValue = $newValue; | |
return $newValue; | |
}); | |
}); |