Skip to content

Instantly share code, notes, and snippets.

@bbrothers
bbrothers / detect-ajax
Created December 17, 2012 15:49
Detect if ajax request
$_SERVER['HTTP_X_REQUESTED_WITH'] == 'xmlhttprequest'
@bbrothers
bbrothers / gist:4441191
Last active December 10, 2015 13:29
Test Question 3
<?php
echo '<pre>';
for($i = 100;$i>=0;$i--){
print $i;
if($i % 2 === 0) {
print " is even";
if($i % 12 === 0) printf(" and is %d dozen",$i/12);
}
else print " is odd";
print ".\n";
.email {
unicode-bidi: bidi-override;
direction: rtl;
text-align: left;
}
@bbrothers
bbrothers / string-replace.sql
Created March 13, 2013 20:23
mysql string replace
UPDATE my_table
SET my_field = REPLACE(my_field, 'old-string', 'new-string')
WHERE my_field LIKE '%old-string%'
# laravel new-app
alias laravel="git clone -o laravel -b develop https://github.com/laravel/laravel.git"
alias artisan="php artisan"
alias migrate="php artisan migrate"
alias serve="php artisan serve"
alias dump="php artisan dump"
alias t="phpunit"
# Generators Package
@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
@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 / 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 / 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