Skip to content

Instantly share code, notes, and snippets.

View mtthlm's full-sized avatar
🐉

Matt Helm mtthlm

🐉
View GitHub Profile
@mtthlm
mtthlm / gist:8403494
Last active January 3, 2016 03:39
How to setup a CentOS 6.4 x86_64 virtual machine in VirtualBox for Vagrant

This guide is a compilation of resources (#1, #2) provided by Vagrant, and assumes you already have a fresh install of CentOS 6.4 x86_64 (1 Core/512MB RAM/12MB Video RAM/8GB Dynamic Drive/NAT Network/No audio or USB) with a root password of vagrant.

Step 1: Update openssh-server and sudo

$ yum update openssh-server sudo

Step 2: Edit /etc/ssh/sshd_config

Change #UseDNS yes to UseDNS no

@mtthlm
mtthlm / gist:8402668
Last active January 3, 2016 03:29
How to setup a CentOS 6.4 x86_64 virtual machine in VirtualBox

Step 1: Edit /etc/sysconfig/network-scripts/ifcfg-eth0

Change ONBOOT=no to ONBOOT=yes

Step 2: Restart network

$ service network restart

Step 3: Update kernel

@mtthlm
mtthlm / gist:7342905
Last active December 27, 2015 14:49
How to sort a collection by column in descending order in Laravel.
<?php
$array = User::find( $id )->{ $collection }->sortBy( function ( $model )
{
return $model->{ $column };
} )->reverse();
foreach ( $array as $model ) ...
@mtthlm
mtthlm / .vimrc
Created November 1, 2013 19:47
Vim Configuration
"
" Vim Configuration
" -----------------
"
" Matt Helm <[email protected]>
"
" ------------------------------------------------------------------------------
"aleph " ASCII code of the letter Aleph (Hebrew)
@mtthlm
mtthlm / gist:6674783
Created September 23, 2013 18:27
Shell Search and Replace To use, replace <ext>, <search>, and <replace> placeholders.
find . -type f -name '*.<ext>' -exec sed -i '' 's/<search>/<replace>/' {} +
@mtthlm
mtthlm / deploy.php
Last active December 20, 2015 03:59
`$ php deploy <env>` Deploy project to SFTP server
<?php
echo PHP_EOL;
if ( array_key_exists( 1 , $argv ) == false ) {
echo 'Usage: ' . $argv[ 0 ] . ' <env>' . PHP_EOL . PHP_EOL;
exit(1);
@mtthlm
mtthlm / deploy.sh
Created July 22, 2013 22:47
A little script I wrote to use for deploying projects to Rackspace Cloud Sites using SFTP, facilitated by SSHFS and rsync. To use: create a file called '.environment' with the variables SERVER_HOST, SERVER_USER, SERVER_PASS, and SERVER_PATH, and create another file called '.exclude' with a list of files to exclude.
#!/bin/bash
#
# VARIABLES
# ---------
#
DIRECTORY=$( cd $( dirname $0 ) && pwd)
MOUNTPOINT=/tmp/deploy
source $DIRECTORY/.environment
@mtthlm
mtthlm / autoload.php
Last active October 13, 2015 15:57
PSR-0 Shorter Autoload Implementation
<?php
// autoload.php
class framework {
public function __construct() {
spl_autoload_register(function ($class) {
include dirname(__DIR__) . DIRECTORY_SEPARATOR . implode(DIRECTORY_SEPARATOR, array_slice(explode('\\', $class), 0, -1)) . DIRECTORY_SEPARATOR . str_replace('_', DIRECTORY_SEPARATOR, implode('', array_slice(explode('\\', $class), -1, 1))) . '.php';
});
}
}