Skip to content

Instantly share code, notes, and snippets.

@Gisleburt
Gisleburt / Vagrantfile
Last active June 14, 2016 11:28
WIP: Attempting to bring up rancher server + rancher host
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Install required plugins
system "echo We will need your root access"
system "sudo echo Thankies!"
required_plugins = %w( vagrant-hostsupdater )
required_plugins.each do |plugin|
system "vagrant plugin install #{plugin}" unless Vagrant.has_plugin? plugin
@Gisleburt
Gisleburt / pre-commit
Last active May 10, 2016 14:53
A pre-commit script for my PHP project for Git
#!/usr/bin/php
<?php
// Based on code by raphaelstolt and buddhamagnet https://gist.github.com/raphaelstolt/588697
class PreCommitHook {
protected $green = "\033[0;32m";
protected $red = "\033[0;31m";
protected $reset = "\033[0m";
@Gisleburt
Gisleburt / AbstractBehatContex.php
Created October 17, 2014 14:19
Use Laravel's Artisan to set the fixtures for your tests
class AbstractBehatContext extends MinkContext {
/**
* Slight hack to put beforeSuite code into beforeScenario
* @var bool
*/
protected static $databaseReady = false;
/**
* @BeforeScenario
@Gisleburt
Gisleburt / forkops.sh
Last active January 3, 2016 03:29
Usage "source forkops.sh [repo-name]". I wanted to fork opscode community recipes, but forking outside of github is a little difficult so I made this script.
# Credit to sehe
# url: http://stackoverflow.com/questions/5559321/fetch-all-in-a-git-bare-repository-doesnt-synchronize-local-branches-to-the#5559586
dir=$1
if [ "$dir" == "" ] ; then
echo "What are we forking?"
read dir
fi
url=https://github.com/opscode-cookbooks/$dir
git init --bare $dir.git
@Gisleburt
Gisleburt / commandSpinner.sh
Last active January 2, 2016 12:09
Show a rotating cursor while running long commands
#!/bin/bash
# Spinner Source: http://it.toolbox.com/blogs/locutus/bash-bits-nibbles-and-bytes-a-rotating-cursor-while-you-wait-22867
# Parallel process Source: http://stackoverflow.com/questions/6384013/run-bash-commands-in-parallel-track-results-and-count#6384467
# Hide job status source: http://superuser.com/questions/377775/how-do-i-keep-background-jobs-from-telling-me-theyre-done
# Spin the spinner. Must be called repeatedly to animate
function spin() {
case $toggle
in
@Gisleburt
Gisleburt / getParam.php
Last active December 27, 2015 11:18
Get a variable from request or url
/**
* Get the given variable from $_REQUEST or from the url
* @param string $variableName
* @param mixed $default
* @return mixed|null
*/
function getParam($variableName, $default = null) {
// Was the variable actually part of the request
if(array_key_exists($variableName, $_REQUEST))
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant::Config.run do |config|
# Every Vagrant virtual environment requires a box to build off of.
config.vm.box = "precise64"
# The url from where the 'config.vm.box' box will be fetched if it
# doesn't already exist on the user's system.
@Gisleburt
Gisleburt / .bash_profile
Last active December 17, 2015 07:19
Keeping track of useful alias'
!#/bin/bash
alias ll='ls -alph'
alias tarzip='tar -czfv'
alias untarzip='tar -xzfv'
sshagent () { eval `ssh-agent -s` && ssh-add; };
alias git-commit='git commit -S -m'
alias git-log='git log --show-signature'
alias git-tag='git tag -s'
@Gisleburt
Gisleburt / fixthisshit.sh
Last active December 15, 2015 04:50
Many Linux problems are caused by messed up permissions. This fixes that shit (sort of).
#!/bin/bash
# This bit is by Brian Campbell
# Source: http://stackoverflow.com/questions/699576/validating-parameters-to-a-bash-script
die () {
echo >&2 "$@"
exit 1
}
[ "$#" -eq 1 ] || die "This shit takes one arguement user[:group]"
@Gisleburt
Gisleburt / BundleJS.php
Last active December 11, 2015 03:48
Bundles all your JS files into one file.Point your html script src at this file, and put all your files in the $files array. Turn devMode on if you're updating your js files a lot and it will regenerate if any are newer than the current bundle.
<?php
//
// Edit these bits
//
$bundleFileName = __DIR__.'/_bundle.js';
$devMode = true;
$files = array(