Skip to content

Instantly share code, notes, and snippets.

@bbrothers
bbrothers / create_ftp_user.sh
Last active June 17, 2023 11:20
Bash for creating vsftp users
#!/bin/bash
# Create ftp user, create folders and set permissions
# Shamelessly coppied from http://dev.n0ise.net/2012/09/vsftpd-add-user-automation-bash-script/
# Usage: ./create_ftp_user.sh [username] "[password]"
#
NAME=$1
PASS=$2
<?php
Collection::macro('diffRecursive', function ($comparate) {
return $this->map(function ($item, $key) use ($comparate) {
$comparate = $this->getArrayableItems($comparate);
if (! isset($comparate[$key])) {
return $item;
}
if (Arr::accessible($item)) {
$item = $this->getArrayableItems($item);
<?php
namespace Vehikl\Feature\Tests;
use PHPUnit\Framework\TestCase;
class FeatureToggleTest extends TestCase
{
public function test_it_executes_the_on_method_when_the_feature_is_on()
openssl rsa -in ~/.ssh/id_rsa -outform pem > id_rsa.pem
@bbrothers
bbrothers / MimeTypeException.php
Created April 13, 2016 15:12
Should Exceptions handler their own assertion logic?
<?php
class MimeTypeException extends Exception
{
const SUPPORTED_MIME_TYPES = ['image/gif', 'image/jpeg', 'impage/png'];
public static function isOfSupportedMimeType($mimeType)
{
if (!in_array($mimeType, SUPPORTED_MIME_TYPES)) {
throw new static(
@bbrothers
bbrothers / reminder
Created February 24, 2016 19:12
Virtual Box: make the client use the host computer as a proxy for resolving hosts
VBoxManage modifyvm "VM name" --natdnshostresolver1 on
@bbrothers
bbrothers / sendmail
Created January 15, 2014 07:30
Test sendmail
echo "My test email being sent from sendmail" | /usr/sbin/sendmail myemail@domain.com
@bbrothers
bbrothers / mysql.sh
Last active January 3, 2016 06:49
Vagrant mysql script from fideloper / Vaprobash with permissions for remote access
#!/usr/bin/env bash
echo ">>> Setting MySQL Permissions"
[[ -z "$1" ]] && { echo "!!! MySQL root password not set. Check the Vagrant file."; exit 1; }
sudo sed -i '/^bind-address/s/bind-address.*=.*/bind-address = 0.0.0.0/' /etc/mysql/my.cnf
mysql -u root -p$1 -e "GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '$1' WITH GRANT OPTION; FLUSH PRIVILEGES;"
sudo service mysql restart
@bbrothers
bbrothers / php.sh
Created January 14, 2014 20:55
Vagrant php config extended from fideloper / Vaprobash
#!/usr/bin/env bash
# Add repo for latest PHP
sudo add-apt-repository -y ppa:ondrej/php5
# Update Again
sudo apt-get update
# Install PHP
sudo apt-get install -y php5-cli php5-mysql php5-pgsql php5-sqlite php5-curl php5-gd php5-mcrypt php5-xdebug php5-memcached
@bbrothers
bbrothers / 0_reuse_code.js
Created October 28, 2013 14:50
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console