Skip to content

Instantly share code, notes, and snippets.

View bhuvidya's full-sized avatar
💭
Mainly working on Laravel packages.

bhu Boue vidya bhuvidya

💭
Mainly working on Laravel packages.
  • Freelance
  • Melbourne, Australia
View GitHub Profile
@jdeathe
jdeathe / centos-6-enable-mysql-query-cache.md
Created August 10, 2017 18:26
How to Enable MySQL Query Cache on CentOS-6

MySQL Query Cache

How to add a 32M query cache with an item limit of 1M.

Enable on a Running MySQL Server

NOTE: You might need to add '-p' to the following command if 'root'@'localhost' requires a password on your environment.

# mysql \
@fideloper
fideloper / stream_file.php
Last active January 17, 2024 18:41
Stream file from S3 to browser, assume Laravel Filesystem usage
<?php
/*************************************************************************
* Get File Information
*/
// Assuming these come from some data source in your app
$s3FileKey = 's3/key/path/to/file.ext';
$fileName = 'file.ext';
/**
* 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
@pascalbaljet
pascalbaljet / imagick-3.4.0-PHP7-forge.sh
Last active November 26, 2020 09:10
Install Imagick 3.4.0 on PHP 7.0 server (Laravel Forge)
#!/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
@joecampo
joecampo / fail2ban.md
Last active April 25, 2024 18:20
fail2ban – stop HTTP(S) route abuse/brute forcing

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,

@protrolium
protrolium / ffmpeg.md
Last active May 15, 2024 18:27
ffmpeg guide

ffmpeg

Converting Audio into Different Formats / Sample Rates

Minimal example: transcode from MP3 to WMA:
ffmpeg -i input.mp3 output.wma

You can get the list of supported formats with:
ffmpeg -formats

You can get the list of installed codecs with:

@wouterds
wouterds / convert-mapstylejson-to-urlargs.php
Created January 27, 2015 14:42
Convert google maps style json to url arguments to use for google maps static images.
<?php
public function mapStylesUrlArgs($mapStyleJson)
{
$params = [];
foreach (json_decode($mapStyleJson, true) as $style) {
$styleString = '';
if (isset($style['stylers']) && count($style['stylers']) > 0) {
@jacktasia
jacktasia / imgix_purge.php
Created January 4, 2015 01:45
imgix PHP purge example
<?php
// find your api key on the bottom of page @ https://webapp.imgix.com
define('IMGIX_API_KEY', '');
// pass the url you want to purge
function imgix_purge($url) {
$headers = array(
'Content-Type:application/json',
'Authorization: Basic '. base64_encode(IMGIX_API_KEY.':')
@steve-jansen
steve-jansen / export-zone.sh
Created December 15, 2014 19:11
Export DNS records from Rackspace Cloud DNS to zone files on disk
#!/bin/bash
# exports DNS records from Rackspace Cloud DNS to text files
# Depends on https://github.com/wichert/clouddns/blob/master/src/clouddns.py
set -e
me=export-zone
base_domain=
rackspace_region=
rackspace_rate_limit_delay=3