Classic debounce function:
const debounce = (fn, delay) => {
let timer = null;
return function (...args) {
const context = this;
timer && clearTimeout(timer);
timer = setTimeout(() => {
==== | |
config\cache.php: | |
==== | |
'file-compressed' => [ | |
'driver' => 'file-compressed', | |
'path' => storage_path('framework/cache/data'), | |
'file_chmod' => 0774, | |
], | |
==== |
SELECT id, title | |
FROM table | |
ORDER BY | |
CASE | |
WHEN title regexp '^[a-zA-Z]+' THEN | |
1 | |
WHEN title regexp '^[0-9]+' THEN | |
2 | |
WHEN title regexp '^[^\w]+' THEN | |
3 |
The birch canoe slid on the smooth planks | |
Glue the sheet to the dark blue background | |
It's easy to tell the depth of a well | |
These days a chicken leg is a rare dish | |
Rice is often served in round bowls | |
The juice of lemons makes fine punch | |
The box was thrown beside the parked truck | |
The hogs were fed chopped corn and garbage | |
Four hours of steady work faced us | |
A large size in stockings is hard to sell |
<?php | |
namespace App\Traits; | |
/** | |
* Fulltext search trait. Requires column to have a FULLTEXT index | |
* Customizable weighted relevance per column | |
* | |
* Add to model: | |
* |
[EditionID] | |
Professional | |
[Channel] | |
Retail |
<?php | |
use Symfony\Component\Console\Helper\ProgressBar; | |
use Symfony\Component\Console\Output\ConsoleOutput; | |
class DoSomething extends Migration | |
{ | |
public function up() | |
{ | |
$output = new ConsoleOutput(); |
# this requires that MySQL is accessed through TCP/IP, not the unix socket. | |
# run tcpdump for 30 seconds capturing traffic on port 3306 | |
timeout 30 tcpdump -s 65535 -x -nn -q -tttt -i any port 3306 > mysql.tcp.txt | |
# run pt-query-digest on collected file | |
pt-query-digest --type tcpdump mysql.tcp.txt >pt.out |
#!/bin/bash | |
# Improved as per feedback from @pascal - https://gist.github.com/julianxhokaxhiu/c0a8e813eabf9d6d9873#gistcomment-3086462 | |
find . -type f -iname "*.png" -exec optipng -nb -nc {} \; | |
find . -type f -iname "*.png" -exec advpng -z4 {} \; | |
find . -type f -iname "*.png" -exec pngcrush -rem gAMA -rem alla -rem cHRM -rem iCCP -rem sRGB -rem time -ow {} \; | |
find . -type f \( -iname "*.jpg" -o -iname "*.jpeg" \) -exec jpegoptim -f --strip-all {} \; |
<?php | |
/** | |
* @param $baseUrl - non protected part of the URL including hostname, e.g. http://example.com | |
* @param $path - protected path to the file, e.g. /downloads/myfile.zip | |
* @param $secret - the shared secret with the nginx server. Keep this info secure!!! | |
* @param $ttl - the number of seconds until this link expires | |
* @param $userIp - ip of the user allowed to download | |
* @return string | |
*/ |