How to add a 32M query cache with an item limit of 1M.
NOTE: You might need to add '-p' to the following command if 'root'@'localhost' requires a password on your environment.
# mysql \
| <?php | |
| /************************************************************************* | |
| * Get File Information | |
| */ | |
| // Assuming these come from some data source in your app | |
| $s3FileKey = 's3/key/path/to/file.ext'; | |
| $fileName = 'file.ext'; |
Granted, this is little more than an obfuscated way of having a publicly writable S3 bucket, but if you don’t have a server which can pre-sign URLs for you, this might be an acceptable solution.
For this to work, you take the following steps:
| // XMLHttpRequest | |
| var xhr = new XMLHttpRequest(); | |
| xhr.open('POST', url, true); | |
| xhr.responseType = 'arraybuffer'; | |
| xhr.onload = function () { | |
| if (this.status === 200) { | |
| var filename = ""; | |
| var disposition = xhr.getResponseHeader('Content-Disposition'); | |
| if (disposition && disposition.indexOf('attachment') !== -1) { | |
| var filenameRegex = /filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/; |
| <?php | |
| namespace App\Http\Middleware; | |
| use Closure; | |
| class RewriteLinks | |
| { | |
| /** | |
| * Handle an incoming request. |
| /** | |
| * Scope a query to only include models matching the supplied ID or UUID. | |
| * Returns the model by default, or supply a second flag `false` to get the Query Builder instance. | |
| * | |
| * @throws \Illuminate\Database\Eloquent\ModelNotFoundException | |
| * | |
| * @param \Illuminate\Database\Schema\Builder $query The Query Builder instance. | |
| * @param string $uuid The UUID of the model. | |
| * @param bool|true $first Returns the model by default, or set to `false` to chain for query builder. | |
| * @return \Illuminate\Database\Eloquent\Model|\Illuminate\Database\Eloquent\Builder |
| #!/bin/bash | |
| if [ "$EUID" -ne 0 ] | |
| then echo "Please run as root" | |
| exit | |
| fi | |
| apt-get install pkg-config libmagickwand-dev -y | |
| cd /tmp | |
| wget https://pecl.php.net/get/imagick-3.4.0.tgz | |
| tar xvzf imagick-3.4.0.tgz |
If you're not familiar: What is fail2ban? fail2ban is an awesome linux service/monitor that scans log files (e.g. auth.log for SSH) for potentially malicious behavior. Once fail2ban is tripped it will ban users for a specified duration by adding rules to Iptables. If you're unfamiliar with fail2ban Chris Fidao has a wonderful (& free!) series about security including setting up fail2ban here.
Recently Laravel released a new feature in 5.1 to throttle authentication attempts by simply adding a trait to your authentication controller. The Laravel throttle trait uses the inputted username, and IP address to throttle attempts. I love seeing this added to a framework out of the box, but what about some of our other apps not built on Laravel? Like a WordPress login? Or even an open API etc.? Ultimately,
| <?php | |
| public function mapStylesUrlArgs($mapStyleJson) | |
| { | |
| $params = []; | |
| foreach (json_decode($mapStyleJson, true) as $style) { | |
| $styleString = ''; | |
| if (isset($style['stylers']) && count($style['stylers']) > 0) { |